|
|
@ -32,13 +32,16 @@ import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Concrete implementation for Application Release Management related tasks.
|
|
|
|
|
|
|
|
*/
|
|
|
|
public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager {
|
|
|
|
public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager {
|
|
|
|
private static Log log = LogFactory.getLog(ApplicationReleaseManagerImpl.class);
|
|
|
|
private static Log log = LogFactory.getLog(ApplicationReleaseManagerImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ApplicationRelease createRelease(String UUID, ApplicationRelease applicationRelease) throws
|
|
|
|
public ApplicationRelease createRelease(String appicationUuid, ApplicationRelease applicationRelease) throws
|
|
|
|
ApplicationManagementException {
|
|
|
|
ApplicationManagementException {
|
|
|
|
Application application = validateReleaseCreateRequest(UUID, applicationRelease);
|
|
|
|
Application application = validateReleaseCreateRequest(appicationUuid, applicationRelease);
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Application release request is received for the application " + application.toString());
|
|
|
|
log.debug("Application release request is received for the application " + application.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -58,30 +61,31 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ApplicationRelease getRelease(String UUID, String version) throws ApplicationManagementException {
|
|
|
|
public ApplicationRelease getRelease(String applicationUuid, String version) throws
|
|
|
|
Application application = validationGetReleaseRequest(UUID);
|
|
|
|
ApplicationManagementException {
|
|
|
|
|
|
|
|
Application application = validationGetReleaseRequest(applicationUuid);
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Application release retrieval request is received for the application " +
|
|
|
|
log.debug("Application release retrieval request is received for the application " +
|
|
|
|
application.toString() + " and version " + version);
|
|
|
|
application.toString() + " and version " + version);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
return DAOFactory.getApplicationReleaseDAO().getRelease(UUID, version);
|
|
|
|
return DAOFactory.getApplicationReleaseDAO().getRelease(applicationUuid, version);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<ApplicationRelease> getReleases(String UUID) throws ApplicationManagementException {
|
|
|
|
public List<ApplicationRelease> getReleases(String applicationUuid) throws ApplicationManagementException {
|
|
|
|
Application application = validationGetReleaseRequest(UUID);
|
|
|
|
Application application = validationGetReleaseRequest(applicationUuid);
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request is received to retrieve all the releases related with the application " +
|
|
|
|
log.debug("Request is received to retrieve all the releases related with the application " +
|
|
|
|
application.toString());
|
|
|
|
application.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
return DAOFactory.getApplicationReleaseDAO().getApplicationReleases(UUID);
|
|
|
|
return DAOFactory.getApplicationReleaseDAO().getApplicationReleases(applicationUuid);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -100,17 +104,18 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* To validate the pre-request of the ApplicationRelease.
|
|
|
|
* To validate the pre-request of the ApplicationRelease.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param UUID UUID of the Application.
|
|
|
|
* @param applicationUuid UUID of the Application.
|
|
|
|
* @return Application related with the UUID
|
|
|
|
* @return Application related with the UUID
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private Application validationGetReleaseRequest(String UUID) throws ApplicationManagementException {
|
|
|
|
private Application validationGetReleaseRequest(String applicationUuid) throws ApplicationManagementException {
|
|
|
|
if (UUID == null) {
|
|
|
|
if (applicationUuid == null) {
|
|
|
|
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
|
|
|
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
|
|
|
+ "parameter to get the releases related to a particular application.");
|
|
|
|
+ "parameter to get the releases related to a particular application.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Application application = DataHolder.getInstance().getApplicationManager().getApplication(UUID);
|
|
|
|
Application application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUuid);
|
|
|
|
if (application == null) {
|
|
|
|
if (application == null) {
|
|
|
|
throw new ApplicationManagementException("Application with UUID " + UUID + " does not exist. Cannot "
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
|
|
|
|
"Application with UUID " + applicationUuid + " does not exist. Cannot "
|
|
|
|
+ "retrieve the releases for a non-existing application.");
|
|
|
|
+ "retrieve the releases for a non-existing application.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
@ -119,29 +124,31 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* To validate a create release request to make sure all the pre-conditions satisfied.
|
|
|
|
* To validate a create release request to make sure all the pre-conditions satisfied.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param UUID UUID of the Application.
|
|
|
|
* @param applicationUuid UUID of the Application.
|
|
|
|
* @param applicationRelease ApplicationRelease that need to be created.
|
|
|
|
* @param applicationRelease ApplicationRelease that need to be created.
|
|
|
|
* @return the Application related with the particular Application Release
|
|
|
|
* @return the Application related with the particular Application Release
|
|
|
|
* @throws ApplicationManagementException Application Management Exception.
|
|
|
|
* @throws ApplicationManagementException Application Management Exception.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private Application validateReleaseCreateRequest(String UUID, ApplicationRelease applicationRelease)
|
|
|
|
private Application validateReleaseCreateRequest(String applicationUuid, ApplicationRelease applicationRelease)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
if (UUID == null) {
|
|
|
|
if (applicationUuid == null) {
|
|
|
|
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
|
|
|
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
|
|
|
+ "parameter to do the application release");
|
|
|
|
+ "parameter to do the application release");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Application application = DataHolder.getInstance().getApplicationManager().getApplication(UUID);
|
|
|
|
Application application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUuid);
|
|
|
|
if (application == null) {
|
|
|
|
if (application == null) {
|
|
|
|
throw new ApplicationManagementException("Application with UUID " + UUID + " does not exist. Cannot "
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
|
|
|
|
"Application with UUID " + applicationUuid + " does not exist. Cannot "
|
|
|
|
+ "release an application that is not existing");
|
|
|
|
+ "release an application that is not existing");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (applicationRelease == null || applicationRelease.getVersionName() == null) {
|
|
|
|
if (applicationRelease == null || applicationRelease.getVersionName() == null) {
|
|
|
|
throw new ApplicationManagementException("ApplicationRelease version name is a mandatory parameter for "
|
|
|
|
throw new ApplicationManagementException("ApplicationRelease version name is a mandatory parameter for "
|
|
|
|
+ "creating release. It cannot be found.");
|
|
|
|
+ "creating release. It cannot be found.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (getRelease(UUID, applicationRelease.getVersionName()) != null){
|
|
|
|
if (getRelease(applicationUuid, applicationRelease.getVersionName()) != null) {
|
|
|
|
throw new ApplicationManagementException("Application Release for the Application UUID " + UUID + " "
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
+ "with the version " + applicationRelease.getVersionName() + " already exists. Cannot create an "
|
|
|
|
"Application Release for the Application UUID " + applicationUuid + " " + "with the version "
|
|
|
|
|
|
|
|
+ applicationRelease.getVersionName() + " already exists. Cannot create an "
|
|
|
|
+ "application release with the same version.");
|
|
|
|
+ "application release with the same version.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|