From f83b466955116990cd07b53b539ad689d848b8a6 Mon Sep 17 00:00:00 2001 From: lasantha Date: Mon, 12 Mar 2018 11:00:29 +0530 Subject: [PATCH] Format the application management API source --- .../services/impl/ApplicationManagementAPIImpl.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 ef03bdca3a5..91010f8c076 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 @@ -327,9 +327,18 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { try { Application application = applicationManager.validateApplication(applicationId); + if (!applicationManager.isApplicationReleaseUpdateAcceptable(application.getId(), + applicationRelease.getUuid())) { + String msg = "Application release is in the " + applicationRelease.getCurrentState() + " state. Hence" + + " updating is not acceptable when application in this state"; + log.error(msg); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } if (binaryFile != null) { applicationRelease = applicationStorageManager.updateReleaseArtifacts(applicationRelease, - application.getType(), binaryFile.getDataHandler().getInputStream()); + application.getType(), + binaryFile.getDataHandler() + .getInputStream()); } if (iconFile != null) { iconFileStream = iconFile.getDataHandler().getInputStream();