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();