From 27e4dc14d3a53546228c52d3b50f8cf187690acc Mon Sep 17 00:00:00 2001 From: inoshperera Date: Sun, 23 Sep 2018 16:20:48 +0530 Subject: [PATCH] add created related fixes --- .../mgt/common/services/ApplicationManager.java | 6 +++++- .../api/services/impl/ApplicationManagementAPIImpl.java | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java index 4df7b50d33..549475a2bb 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java @@ -148,9 +148,13 @@ public interface ApplicationManager { * * @param applicationId ID of the Application. * @param applicationUuid UUID of the Application Release. + * @param state Lifecycle state to change the app + * @param checkExist whether it is needed to check if the app and release already exist in the database + * @param releaseId The release ID of the application(optional) * @throws ApplicationManagementException Application Management Exception. */ - void changeLifecycleState(int applicationId, String applicationUuid, LifecycleState state) throws ApplicationManagementException; + void changeLifecycleState(int applicationId, String applicationUuid, LifecycleState state, Boolean checkExist, + int releaseId) throws ApplicationManagementException; /** * Get the application if application is an accessible one. diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementAPIImpl.java index 2b4c758e19..9e27fa77a6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementAPIImpl.java @@ -136,6 +136,8 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { if (!isValidAppCreatingRequest(binaryFile, iconFile, bannerFile, attachmentList, application)) { return Response.status(Response.Status.BAD_REQUEST).build(); } + + // The application executable artifacts such as apks are uploaded. if (!ApplicationType.ENTERPRISE.toString().equals(application.getType())) { applicationRelease = application.getApplicationReleases().get(0); applicationRelease = applicationStorageManager @@ -157,11 +159,15 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { for (Attachment screenshot : attachmentList) { attachments.add(screenshot.getDataHandler().getInputStream()); } + + // Upload images applicationRelease = applicationStorageManager.uploadImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, attachments); applicationRelease.setUuid(UUID.randomUUID().toString()); applicationReleases.add(applicationRelease); application.setApplicationReleases(applicationReleases); + + // Created new application entry Application createdApplication = applicationManager.createApplication(application); if (createdApplication != null) { return Response.status(Response.Status.CREATED).entity(createdApplication).build(); @@ -460,7 +466,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { LifecycleState state) { ApplicationManager applicationManager = APIUtil.getApplicationManager(); try { - applicationManager.changeLifecycleState(applicationId, applicationUuid, state); + applicationManager.changeLifecycleState(applicationId, applicationUuid, state, true, 0); } catch (ApplicationManagementException e) { String msg = "Error occurred while adding lifecycle state."; log.error(msg, e);