|
|
@ -138,11 +138,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public <T> Application createApplication(T app) throws ApplicationManagementException {
|
|
|
|
public <T> Application createApplication(T app, boolean isPublished) throws ApplicationManagementException {
|
|
|
|
ApplicationDTO applicationDTO = uploadReleaseArtifactIfExist(app);
|
|
|
|
ApplicationDTO applicationDTO = uploadReleaseArtifactIfExist(app);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
Application application = addAppDataIntoDB(applicationDTO);
|
|
|
|
Application application = addAppDataIntoDB(applicationDTO, isPublished);
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
@ -167,7 +167,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ApplicationRelease createEntAppRelease(int appId, EntAppReleaseWrapper releaseWrapper)
|
|
|
|
public ApplicationRelease createEntAppRelease(int appId, EntAppReleaseWrapper releaseWrapper, boolean isPublished)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(), releaseWrapper.getScreenshots(),
|
|
|
|
ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(), releaseWrapper.getScreenshots(),
|
|
|
@ -177,7 +177,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
releaseDTO = uploadEntAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName(), true);
|
|
|
|
releaseDTO = uploadEntAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName(), true);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.ENTERPRISE);
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.ENTERPRISE, isPublished);
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
String msg = "Error occurred while creating ent app release for application with the name: " + applicationDTO.getName();
|
|
|
|
String msg = "Error occurred while creating ent app release for application with the name: " + applicationDTO.getName();
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -187,7 +187,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ApplicationRelease createWebAppRelease(int appId, WebAppReleaseWrapper releaseWrapper)
|
|
|
|
public ApplicationRelease createWebAppRelease(int appId, WebAppReleaseWrapper releaseWrapper, boolean isPublished)
|
|
|
|
throws ApplicationManagementException, ResourceManagementException {
|
|
|
|
throws ApplicationManagementException, ResourceManagementException {
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
@ -196,7 +196,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
releaseDTO = uploadWebAppReleaseArtifacts(releaseDTO, artifact);
|
|
|
|
releaseDTO = uploadWebAppReleaseArtifacts(releaseDTO, artifact);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.WEB_CLIP);
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.WEB_CLIP, isPublished);
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
String msg = "Error occurred while creating web app release for application with the name: " + applicationDTO.getName();
|
|
|
|
String msg = "Error occurred while creating web app release for application with the name: " + applicationDTO.getName();
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -206,7 +206,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ApplicationRelease createPubAppRelease(int appId, PublicAppReleaseWrapper releaseWrapper) throws
|
|
|
|
public ApplicationRelease createPubAppRelease(int appId, PublicAppReleaseWrapper releaseWrapper, boolean isPublished) throws
|
|
|
|
ResourceManagementException, ApplicationManagementException {
|
|
|
|
ResourceManagementException, ApplicationManagementException {
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
@ -216,7 +216,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
releaseDTO = uploadPubAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName());
|
|
|
|
releaseDTO = uploadPubAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName());
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.PUBLIC);
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.PUBLIC, isPublished);
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
String msg = "Error occurred while creating ent public release for application with the name: " + applicationDTO.getName();
|
|
|
|
String msg = "Error occurred while creating ent public release for application with the name: " + applicationDTO.getName();
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -226,7 +226,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ApplicationRelease createCustomAppRelease(int appId, CustomAppReleaseWrapper releaseWrapper)
|
|
|
|
public ApplicationRelease createCustomAppRelease(int appId, CustomAppReleaseWrapper releaseWrapper, boolean isPublished)
|
|
|
|
throws ResourceManagementException, ApplicationManagementException {
|
|
|
|
throws ResourceManagementException, ApplicationManagementException {
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
@ -236,7 +236,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
releaseDTO = uploadCustomAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName());
|
|
|
|
releaseDTO = uploadCustomAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName());
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.CUSTOM);
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.CUSTOM, isPublished);
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
String msg = "Error occurred while creating custom app release for application with the name: " + applicationDTO.getName();
|
|
|
|
String msg = "Error occurred while creating custom app release for application with the name: " + applicationDTO.getName();
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -1192,7 +1192,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Application addAppDataIntoDB(ApplicationDTO applicationDTO) throws
|
|
|
|
public Application addAppDataIntoDB(ApplicationDTO applicationDTO, boolean isPublished) throws
|
|
|
|
ApplicationManagementException {
|
|
|
|
ApplicationManagementException {
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
ApplicationReleaseDTO applicationReleaseDTO = null;
|
|
|
|
ApplicationReleaseDTO applicationReleaseDTO = null;
|
|
|
@ -1258,12 +1258,21 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<ApplicationReleaseDTO> applicationReleaseEntities = new ArrayList<>();
|
|
|
|
List<ApplicationReleaseDTO> applicationReleaseEntities = new ArrayList<>();
|
|
|
|
if (applicationReleaseDTO != null) {
|
|
|
|
if (applicationReleaseDTO != null) {
|
|
|
|
String initialLifecycleState = lifecycleStateManager.getInitialState();
|
|
|
|
String lifeCycleState = lifecycleStateManager.getInitialState();
|
|
|
|
applicationReleaseDTO.setCurrentState(initialLifecycleState);
|
|
|
|
String[] publishStates= {"IN-REVIEW", "APPROVED", "PUBLISHED"};
|
|
|
|
applicationReleaseDTO = this.applicationReleaseDAO
|
|
|
|
|
|
|
|
.createRelease(applicationReleaseDTO, appId, tenantId);
|
|
|
|
applicationReleaseDTO.setCurrentState(lifeCycleState);
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstance(initialLifecycleState, initialLifecycleState);
|
|
|
|
applicationReleaseDTO = this.applicationReleaseDAO.createRelease(applicationReleaseDTO, appId, tenantId);
|
|
|
|
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstance(lifeCycleState, lifeCycleState);
|
|
|
|
this.lifecycleStateDAO.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId);
|
|
|
|
this.lifecycleStateDAO.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId);
|
|
|
|
|
|
|
|
if(isPublished){
|
|
|
|
|
|
|
|
for (String state: publishStates) {
|
|
|
|
|
|
|
|
LifecycleChanger lifecycleChanger = new LifecycleChanger();
|
|
|
|
|
|
|
|
lifecycleChanger.setAction(state);
|
|
|
|
|
|
|
|
lifecycleChanger.setReason("Updated to " + state);
|
|
|
|
|
|
|
|
this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
applicationReleaseEntities.add(applicationReleaseDTO);
|
|
|
|
applicationReleaseEntities.add(applicationReleaseDTO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applicationDTO.setId(appId);
|
|
|
|
applicationDTO.setId(appId);
|
|
|
@ -1296,7 +1305,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public <T> ApplicationRelease createRelease(ApplicationDTO applicationDTO, ApplicationReleaseDTO applicationReleaseDTO,
|
|
|
|
public <T> ApplicationRelease createRelease(ApplicationDTO applicationDTO, ApplicationReleaseDTO applicationReleaseDTO,
|
|
|
|
ApplicationType type)
|
|
|
|
ApplicationType type, boolean isPublished)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
@ -1322,13 +1331,23 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
String initialState = lifecycleStateManager.getInitialState();
|
|
|
|
String lifeCycleState = lifecycleStateManager.getInitialState();
|
|
|
|
applicationReleaseDTO.setCurrentState(initialState);
|
|
|
|
String[] publishStates = {"IN-REVIEW", "APPROVED", "PUBLISHED"};
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstance(initialState, initialState);
|
|
|
|
|
|
|
|
|
|
|
|
applicationReleaseDTO.setCurrentState(lifeCycleState);
|
|
|
|
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstance(lifeCycleState, lifeCycleState);
|
|
|
|
applicationReleaseDTO = this.applicationReleaseDAO
|
|
|
|
applicationReleaseDTO = this.applicationReleaseDAO
|
|
|
|
.createRelease(applicationReleaseDTO, applicationDTO.getId(), tenantId);
|
|
|
|
.createRelease(applicationReleaseDTO, applicationDTO.getId(), tenantId);
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId);
|
|
|
|
.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId);
|
|
|
|
|
|
|
|
if(isPublished){
|
|
|
|
|
|
|
|
for (String state: publishStates) {
|
|
|
|
|
|
|
|
LifecycleChanger lifecycleChanger = new LifecycleChanger();
|
|
|
|
|
|
|
|
lifecycleChanger.setAction(state);
|
|
|
|
|
|
|
|
lifecycleChanger.setReason("Updated to " + state);
|
|
|
|
|
|
|
|
this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
ApplicationRelease applicationRelease = APIUtil.releaseDtoToRelease(applicationReleaseDTO);
|
|
|
|
ApplicationRelease applicationRelease = APIUtil.releaseDtoToRelease(applicationReleaseDTO);
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
return applicationRelease;
|
|
|
|
return applicationRelease;
|
|
|
|