|
|
@ -100,17 +100,15 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Create Application received for the tenant : " + tenantId + " From" + " the user : " + userName);
|
|
|
|
log.debug("Create Application received for the tenant : " + tenantId + " From" + " the user : " + userName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
|
|
|
|
validateAppCreatingRequest(application, tenantId);
|
|
|
|
validateAppCreatingRequest(application, tenantId);
|
|
|
|
validateAppReleasePayload(application.getApplicationReleases().get(0));
|
|
|
|
validateAppReleasePayload(application.getApplicationReleases().get(0));
|
|
|
|
DeviceType deviceType;
|
|
|
|
DeviceType deviceType;
|
|
|
|
ApplicationRelease applicationRelease;
|
|
|
|
ApplicationRelease applicationRelease;
|
|
|
|
List<ApplicationRelease> applicationReleases = new ArrayList<>();
|
|
|
|
List<ApplicationRelease> applicationReleases = new ArrayList<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
|
|
|
// Getting the device type details to get device type ID for internal mappings
|
|
|
|
// Getting the device type details to get device type ID for internal mappings
|
|
|
|
deviceType = Util.getDeviceManagementService().getDeviceType(application.getDeviceType());
|
|
|
|
deviceType = Util.getDeviceManagementService().getDeviceType(application.getDeviceType());
|
|
|
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
if (deviceType == null) {
|
|
|
|
if (deviceType == null) {
|
|
|
|
log.error("Device type is not matched with application type");
|
|
|
|
log.error("Device type is not matched with application type");
|
|
|
@ -165,7 +163,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
LifecycleState lifecycleState = new LifecycleState();
|
|
|
|
LifecycleState lifecycleState = new LifecycleState();
|
|
|
|
lifecycleState.setCurrentState(AppLifecycleState.CREATED.toString());
|
|
|
|
lifecycleState.setCurrentState(AppLifecycleState.CREATED.toString());
|
|
|
|
lifecycleState.setPreviousState(AppLifecycleState.CREATED.toString());
|
|
|
|
lifecycleState.setPreviousState(AppLifecycleState.CREATED.toString());
|
|
|
|
changeLifecycleState(appId, applicationRelease.getUuid(), lifecycleState, false);
|
|
|
|
lifecycleState.setUpdatedBy(userName);
|
|
|
|
|
|
|
|
this.lifecycleStateDAO.addLifecycleState(lifecycleState, appId, applicationRelease.getUuid(), tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
applicationRelease.setLifecycleState(lifecycleState);
|
|
|
|
applicationRelease.setLifecycleState(lifecycleState);
|
|
|
|
applicationReleases.add(applicationRelease);
|
|
|
|
applicationReleases.add(applicationRelease);
|
|
|
@ -192,8 +191,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -693,19 +690,30 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
* @param application Application that need to be validated
|
|
|
|
* @param application Application that need to be validated
|
|
|
|
* @throws ValidationException Validation Exception
|
|
|
|
* @throws ValidationException Validation Exception
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void validateApplicationExistence(Application application, int tenantId) throws ApplicationManagementException {
|
|
|
|
private void validateApplicationExistence(Application application, int tenantId)
|
|
|
|
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
Filter filter = new Filter();
|
|
|
|
Filter filter = new Filter();
|
|
|
|
filter.setFullMatch(true);
|
|
|
|
filter.setFullMatch(true);
|
|
|
|
filter.setAppName(application.getName().trim());
|
|
|
|
filter.setAppName(application.getName().trim());
|
|
|
|
filter.setOffset(0);
|
|
|
|
filter.setOffset(0);
|
|
|
|
filter.setLimit(1);
|
|
|
|
filter.setLimit(1);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
|
|
|
|
ApplicationList applicationList = applicationDAO.getApplications(filter, tenantId);
|
|
|
|
|
|
|
|
if (applicationList != null && applicationList.getApplications() != null && !applicationList
|
|
|
|
|
|
|
|
.getApplications().isEmpty()) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
|
|
|
|
"Already an application registered with same name - " + applicationList.getApplications().get(0)
|
|
|
|
|
|
|
|
.getName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementException("test 1");
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationList applicationList = applicationDAO.getApplications(filter, tenantId);
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
if (applicationList != null && applicationList.getApplications() != null && !applicationList.getApplications()
|
|
|
|
throw new ApplicationManagementException("test 2");
|
|
|
|
.isEmpty()) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
} finally {
|
|
|
|
"Already an application registered with same name - " + applicationList.getApplications().get(0)
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
.getName());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -919,6 +927,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
throw new ApplicationManagementException("Failed to get application and application management", e);
|
|
|
|
throw new ApplicationManagementException("Failed to get application and application management", e);
|
|
|
|
} catch (LifeCycleManagementDAOException e) {
|
|
|
|
} catch (LifeCycleManagementDAOException e) {
|
|
|
|
throw new ApplicationManagementException("Failed to get lifecycle state from database", e);
|
|
|
|
throw new ApplicationManagementException("Failed to get lifecycle state from database", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lifecycleState;
|
|
|
|
return lifecycleState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|