|
|
@ -126,21 +126,23 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
"Invalid payload. Application creating payload should contains one application release, but "
|
|
|
|
"Invalid payload. Application creating payload should contains one application release, but "
|
|
|
|
+ "the payload contains more than one");
|
|
|
|
+ "the payload contains more than one");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
applicationRelease = application.getApplicationReleases().get(0);
|
|
|
|
applicationRelease = application.getApplicationReleases().get(0);
|
|
|
|
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO().
|
|
|
|
applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO().
|
|
|
|
createRelease(applicationRelease, application.getId(), tenantId);
|
|
|
|
createRelease(applicationRelease, application.getId(), tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
LifecycleState lifecycleState = new LifecycleState();
|
|
|
|
LifecycleState lifecycleState = new LifecycleState();
|
|
|
|
lifecycleState.setAppId(application.getId());
|
|
|
|
|
|
|
|
lifecycleState.setReleaseId(applicationRelease.getId());
|
|
|
|
|
|
|
|
lifecycleState.setUpdatedBy(userName);
|
|
|
|
lifecycleState.setUpdatedBy(userName);
|
|
|
|
lifecycleState.setTenantId(tenantId);
|
|
|
|
|
|
|
|
lifecycleState.setCurrentState(AppLifecycleState.CREATED.toString());
|
|
|
|
lifecycleState.setCurrentState(AppLifecycleState.CREATED.toString());
|
|
|
|
lifecycleState.setPreviousState(AppLifecycleState.CREATED.toString());
|
|
|
|
lifecycleState.setPreviousState(AppLifecycleState.CREATED.toString());
|
|
|
|
addLifecycleState(application.getId(), applicationRelease.getUuid(), lifecycleState);
|
|
|
|
addLifecycleState(application.getId(), applicationRelease.getUuid(), lifecycleState);
|
|
|
|
|
|
|
|
LifecycleStateDAO lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
|
|
|
|
|
|
|
|
lifecycleStateDAO.addLifecycleState(lifecycleState, application.getId(), applicationRelease.getId(), tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
applicationRelease.setLifecycleState(lifecycleState);
|
|
|
|
applicationRelease.setLifecycleState(lifecycleState);
|
|
|
|
applicationReleases.add(applicationRelease);
|
|
|
|
applicationReleases.add(applicationRelease);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
@ -155,6 +157,11 @@ 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);
|
|
|
|
|
|
|
|
} catch (LifeCycleManagementDAOException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while adding application lifecycle state";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
}finally {
|
|
|
|
}finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -399,7 +406,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
LifecycleState newAppLifecycleState = new LifecycleState();
|
|
|
|
LifecycleState newAppLifecycleState = new LifecycleState();
|
|
|
|
newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState());
|
|
|
|
newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState());
|
|
|
|
newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString());
|
|
|
|
newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString());
|
|
|
|
newAppLifecycleState.setTenantId(tenantId);
|
|
|
|
|
|
|
|
newAppLifecycleState.setUpdatedBy(userName);
|
|
|
|
newAppLifecycleState.setUpdatedBy(userName);
|
|
|
|
addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState);
|
|
|
|
addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState);
|
|
|
|
storedLocations.add(applicationRelease.getAppHashValue());
|
|
|
|
storedLocations.add(applicationRelease.getAppHashValue());
|
|
|
@ -437,7 +443,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
LifecycleState newAppLifecycleState = new LifecycleState();
|
|
|
|
LifecycleState newAppLifecycleState = new LifecycleState();
|
|
|
|
newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState());
|
|
|
|
newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState());
|
|
|
|
newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString());
|
|
|
|
newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString());
|
|
|
|
newAppLifecycleState.setTenantId(tenantId);
|
|
|
|
|
|
|
|
newAppLifecycleState.setUpdatedBy(userName);
|
|
|
|
newAppLifecycleState.setUpdatedBy(userName);
|
|
|
|
addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState);
|
|
|
|
addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
@ -710,17 +715,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
Application application = validateApplication(applicationId);
|
|
|
|
Application application = validateApplication(applicationId);
|
|
|
|
ApplicationRelease applicationRelease = validateApplicationRelease(applicationId, applicationUuid);
|
|
|
|
ApplicationRelease applicationRelease = validateApplicationRelease(applicationId, applicationUuid);
|
|
|
|
LifecycleStateDAO lifecycleStateDAO;
|
|
|
|
LifecycleStateDAO lifecycleStateDAO;
|
|
|
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
|
|
|
|
|
|
|
if (application != null) {
|
|
|
|
|
|
|
|
state.setAppId(applicationId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (applicationRelease != null) {
|
|
|
|
|
|
|
|
state.setReleaseId(applicationRelease.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state.getCurrentState() != null && state.getPreviousState() != null && state.getUpdatedBy() != null) {
|
|
|
|
if (state.getCurrentState() != null && state.getPreviousState() != null && state.getUpdatedBy() != null) {
|
|
|
|
validateLifecycleState(state);
|
|
|
|
validateLifecycleState(state);
|
|
|
|
lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
|
|
|
|
lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
|
|
|
|
lifecycleStateDAO.addLifecycleState(state);
|
|
|
|
lifecycleStateDAO.addLifecycleState(state, application.getId(), applicationRelease.getId(), tenantId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (LifeCycleManagementDAOException | DBConnectionException e) {
|
|
|
|
} catch (LifeCycleManagementDAOException | DBConnectionException e) {
|
|
|
|
throw new ApplicationManagementException("Failed to add lifecycle state", e);
|
|
|
|
throw new ApplicationManagementException("Failed to add lifecycle state", e);
|
|
|
|