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