diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ResourceManagementException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ResourceManagementException.java index 11ecb5a2cd..fa25484f38 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ResourceManagementException.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ResourceManagementException.java @@ -23,7 +23,7 @@ package org.wso2.carbon.device.application.mgt.common.exception; * Represents the exception that will be thrown when there is an issue while managing the resources. */ public class ResourceManagementException extends Exception { - ResourceManagementException(String message, Throwable ex) { + public ResourceManagementException(String message, Throwable ex) { super(message, ex); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java index 7745836875..33b76ce5dc 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java @@ -19,6 +19,7 @@ package org.wso2.carbon.device.application.mgt.common.services; +import javassist.NotFoundException; import org.wso2.carbon.device.application.mgt.common.ApplicationRelease; import org.wso2.carbon.device.application.mgt.common.ImageArtifact; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; @@ -46,14 +47,13 @@ public interface ApplicationStorageManager { /** * To upload image artifacts related with an Application. * - * @param applicationId ID of the application - * @param uuid Unique Identifier of the application + * @param applicationRelease Release of the application * @param iconFile Icon File input stream * @param bannerFile Banner File input stream * @param screenshots Input Streams of screenshots * @throws ResourceManagementException Resource Management Exception. */ - ApplicationRelease updateImageArtifacts(int applicationId, String uuid, InputStream iconFile, + ApplicationRelease updateImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFile, InputStream bannerFile, List screenshots) throws ResourceManagementException, ApplicationManagementException; @@ -70,60 +70,27 @@ public interface ApplicationStorageManager { /** * To upload release artifacts for an Application. * - * @param applicationId Id of the application. - * @param applicationUuid UUID of the application related with the release. + * @param applicationRelease applicationRelease Application release of a particular application. * @param binaryFile Binary File for the release. - * @throws ResourceManagementException Resource Management Exception. - */ - ApplicationRelease updateReleaseArtifacts(int applicationId, String applicationUuid, InputStream binaryFile) - throws ResourceManagementException; - - /** - * To get released artifacts for the particular version of the application. - * - * @param applicationUUID UUID of the Application - * @param versionName Version of the release to be retrieved - * @return the artifact related with the Application Release. - * @throws ApplicationStorageManagementException Application Storage Management Exception. + * @throws ApplicationStorageManagementException Resource Management Exception. */ - InputStream getReleasedArtifacts(String applicationUUID, String versionName) + ApplicationRelease updateReleaseArtifacts(ApplicationRelease applicationRelease, InputStream binaryFile) throws ApplicationStorageManagementException; - /** - * To delete all the artifacts related with a particular Application. - * - * @param applicationUUID UUID of the Application. - * @throws ApplicationStorageManagementException Application Storage Management Exception. - */ - void deleteApplicationArtifacts(String applicationUUID) throws ApplicationStorageManagementException; - /** * To delete the artifacts related with particular Application Release. * - * @param applicationUUID UUID of the Application. - * @param version Version of ApplicationRelease that need to be deleted. - * @throws ApplicationStorageManagementException Application Storage Management Exception. + * @param directoryPath Hash value of the application artifact. + * @throws ApplicationStorageManagementException Not Found Exception. */ - void deleteApplicationReleaseArtifacts(String applicationUUID, String version) - throws ApplicationStorageManagementException; + void deleteApplicationReleaseArtifacts(String directoryPath) throws ApplicationStorageManagementException; /** * To delete all release artifacts related with particular Application Release. * - * @param applicationUUID UUID of the Application. + * @param directoryPaths Hash values of the Application. * @throws ApplicationStorageManagementException Application Storage Management Exception */ - void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws ApplicationStorageManagementException; + void deleteAllApplicationReleaseArtifacts(List directoryPaths) throws ApplicationStorageManagementException; - /** - * To get particular image artifact of the application. - * - * @param applicationUUID UUID of the application, to retrieve the image artifact. - * @param name Name of the artifact - icon/banner/screenshot - * @param count Position of a parameter to get the image artifact. - * @return the relevant image artifact. - * @throws ApplicationStorageManagementException Application Storage Management Exception. - */ - ImageArtifact getImageArtifact(String applicationUUID, String name, int count) - throws ApplicationStorageManagementException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java index bb8e370ed9..91d9b3566a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -24,25 +24,17 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.application.mgt.common.Application; import org.wso2.carbon.device.application.mgt.common.ApplicationRelease; -import org.wso2.carbon.device.application.mgt.common.ImageArtifact; -import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException; import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException; import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; -import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException; -import org.wso2.carbon.device.application.mgt.core.internal.DataHolder; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.Constants; import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.util.Arrays; import java.util.List; import static org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil.saveFile; @@ -69,9 +61,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager @Override public ApplicationRelease uploadImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFileStream, InputStream bannerFileStream, List screenShotStreams) - throws ResourceManagementException { + throws ResourceManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - String artifactDirectoryPath = null; + String artifactDirectoryPath; String iconStoredLocation; String bannerStoredLocation; String scStoredLocation; @@ -112,11 +104,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager return applicationRelease; } catch (IOException e) { - throw new ApplicationStorageManagementException( - "IO Exception while saving the screens hots for the " + "application " + - applicationRelease.getUuid(), e); + throw new ApplicationStorageManagementException("IO Exception while saving the screens hots for " + + "the application " + applicationRelease.getUuid(), e); } catch (ApplicationStorageManagementException e) { - ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationStorageManagementException("Application Management DAO exception while trying to " + "update the screen-shot count for the application " + applicationRelease.getUuid() + " for the tenant id " + tenantId, e); @@ -124,28 +114,44 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } @Override - public ApplicationRelease updateImageArtifacts(int applicationId, String uuid, InputStream iconFileStream, + public ApplicationRelease updateImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFileStream, InputStream bannerFileStream, List screenShotStreams) - throws ResourceManagementException, ApplicationManagementException { + throws ResourceManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); try { - ApplicationRelease applicationRelease = validateApplicationRelease(uuid); + if (iconFileStream != null) { + deleteApplicationReleaseArtifacts(applicationRelease.getIconLoc()); + } + if (bannerFileStream != null) { + deleteApplicationReleaseArtifacts(applicationRelease.getBannerLoc()); + } + if (screenShotStreams.size() > screenShotMaxCount) { + throw new ApplicationStorageManagementException("Maximum limit for the screen-shot exceeds"); + } else if (!screenShotStreams.isEmpty() && screenShotStreams.size() <= screenShotMaxCount) { + int count = 1; + while (count < screenShotStreams.size()) { + if (count == 1) { + deleteApplicationReleaseArtifacts(applicationRelease.getScreenshotLoc1()); + } + if (count == 2) { + deleteApplicationReleaseArtifacts(applicationRelease.getScreenshotLoc2()); + } + if (count == 3) { + deleteApplicationReleaseArtifacts(applicationRelease.getScreenshotLoc3()); + } + count++; + } + } applicationRelease = uploadImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, screenShotStreams); return applicationRelease; } catch (ApplicationStorageManagementException e) { ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationStorageManagementException("Application Storage exception while trying to" - + " update the screen-shot count for the application " + applicationId + " for the tenant " - + tenantId, e); - } catch (ApplicationManagementException e) { - ConnectionManagerUtil.rollbackDBTransaction(); - throw new ApplicationManagementException("Application Management DAO exception while trying to" - + " update the screen-shot count for the application " + applicationId + " for the tenant " - + tenantId, e); + + " update the screen-shot count for the application Release " + applicationRelease.getUuid() + + " for the tenant " + tenantId, e); } - } @Override @@ -165,7 +171,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager + "application UUID " + applicationRelease.getUuid() + " is " + artifactDirectoryPath); } try { - saveFile(binaryFile, artifactDirectoryPath); + saveFile(binaryFile, artifactDirectoryPath + Constants.RELEASE_ARTIFACT); applicationRelease.setAppStoredLoc(artifactDirectoryPath); applicationRelease.setAppHashValue(md5OfApp); } catch (IOException e) { @@ -181,183 +187,43 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } @Override - public ApplicationRelease updateReleaseArtifacts(int applicationId, String applicationUuid, InputStream binaryFile) - throws ResourceManagementException { - - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + public ApplicationRelease updateReleaseArtifacts(ApplicationRelease applicationRelease, InputStream binaryFile) + throws ApplicationStorageManagementException { - ApplicationRelease applicationRelease = null; - try { - applicationRelease = validateApplicationRelease(applicationUuid); - applicationRelease = uploadReleaseArtifacts(applicationRelease, binaryFile); - return applicationRelease; - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException("Application Management exception while trying to" - + " update the Application artifact for the application " + applicationId + " for the tenant " - + tenantId, e); + if (binaryFile != null) { + try { + deleteApplicationReleaseArtifacts(applicationRelease.getAppStoredLoc()); + applicationRelease = uploadReleaseArtifacts(applicationRelease, binaryFile); + } catch (ApplicationStorageManagementException e) { + throw new ApplicationStorageManagementException("Application Artifact doesn't contains in the System", e); + } catch (ResourceManagementException e) { + throw new ApplicationStorageManagementException("Application Artifact Updating failed", e); + } } - } - //todo - @Override - public InputStream getReleasedArtifacts(String applicationUUID, String versionName) - throws ApplicationStorageManagementException { - return null; - // todo this should be validate application release - // Application application = validateApplication(applicationUUID); - // String artifactPath = storagePath + application.getId() + File.separator + versionName; - // - // if (log.isDebugEnabled()) { - // log.debug("ApplicationRelease artifacts are searched in the location " + artifactPath); - // } - // - // File binaryFile = new File(artifactPath); - // - // if (!binaryFile.exists()) { - // throw new ApplicationStorageManagementException("Binary file does not exist for this release"); - // } else { - // try { - // return new FileInputStream(artifactPath); - // } catch (FileNotFoundException e) { - // throw new ApplicationStorageManagementException( - // "Binary file does not exist for the version " + versionName + " for the application ", e); - // } - // } - } - - //todo - @Override - public void deleteApplicationArtifacts(String applicationUUID) throws ApplicationStorageManagementException { - // todo this should be validate application release - // Application application = validateApplication(applicationUUID); - // String artifactDirectoryPath = storagePath + application.getId(); - // File artifactDirectory = new File(artifactDirectoryPath); - // - // if (artifactDirectory.exists()) { - // StorageManagementUtil.deleteDir(artifactDirectory); - // } - } + return applicationRelease; - //todo - @Override - public void deleteApplicationReleaseArtifacts(String applicationUUID, String version) - throws ApplicationStorageManagementException { - // todo this should be validate application release - // Application application = validateApplication(applicationUUID); - // String artifactPath = storagePath + application.getId() + File.separator + version; - // File artifact = new File(artifactPath); - // - // if (artifact.exists()) { - // StorageManagementUtil.deleteDir(artifact); - // } } - //todo - @Override - public void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws - ApplicationStorageManagementException { - // todo this should be validate application release - // validateApplication(applicationUUID); - // try { - // List applicationReleases = DataHolder.getInstance().getApplicationReleaseManager() - // .getReleases(applicationUUID); - // for (ApplicationRelease applicationRelease : applicationReleases) { - // deleteApplicationReleaseArtifacts(applicationUUID, applicationRelease.getVersion()); - // } - // } catch (ApplicationManagementException e) { - // throw new ApplicationStorageManagementException( - // "Application Management Exception while getting releases " + "for the application " - // + applicationUUID, e); - // } - } - //todo @Override - public ImageArtifact getImageArtifact(String applicationUUID, String name, int count) throws - ApplicationStorageManagementException { - return null; - // todo this should be validate application release - // Application application = validateApplication(applicationUUID); - // validateImageArtifactNames(name); - // String imageArtifactPath = storagePath + application.getId() + File.separator + name.toLowerCase(); - // - // if (name.equalsIgnoreCase(Constants.IMAGE_ARTIFACTS[2])) { - // imageArtifactPath += count; - // } - // File imageFile = new File(imageArtifactPath); - // if (!imageFile.exists()) { - // throw new ApplicationStorageManagementException( - // "Image artifact " + name + " does not exist for the " + "application with UUID " + applicationUUID); - // } else { - // try { - // return StorageManagementUtil.createImageArtifact(imageFile, imageArtifactPath); - // } catch (FileNotFoundException e) { - // throw new ApplicationStorageManagementException( - // "File not found exception while trying to get the image artifact " + name + " for the " - // + "application " + applicationUUID, e); - // } catch (IOException e) { - // throw new ApplicationStorageManagementException("IO Exception while trying to detect the image " - // + "artifact " + name + " for the application " + applicationUUID, e); - // } - // } - } + public void deleteApplicationReleaseArtifacts(String directoryPath) throws ApplicationStorageManagementException { + String artifactPath = storagePath + directoryPath; + File artifact = new File(artifactPath); - /** - * To validate the image artifact names. - * - * @param name Name of the image artifact. - * @throws ApplicationStorageManagementException Application Storage Management Exception - */ - private void validateImageArtifactNames(String name) throws ApplicationStorageManagementException { - if (name == null || name.isEmpty()) { - throw new ApplicationStorageManagementException("Image artifact name cannot be null or empty. It is a " - + "required parameter"); - } - if (!Arrays.asList(Constants.IMAGE_ARTIFACTS).contains(name.toLowerCase())) { - throw new ApplicationStorageManagementException("Provide artifact name is not valid. Please provide the " - + "name among " + Arrays.toString(Constants.IMAGE_ARTIFACTS)); + if (artifact.exists()) { + StorageManagementUtil.deleteDir(artifact); + } else { + throw new ApplicationStorageManagementException("Tried to delete application release, but it doesn't exist " + + "in the system"); } } - /** - * To validate the Application before storing and retrieving the artifacts of a particular application. - * - * @param appId ID of the Application - * @return boolean if it is validated - * @throws ApplicationStorageManagementException Application Storage Management Exception will be thrown if a - * valid application related with the specific UUID - * could not be found. - */ - private Boolean validateApplication(int appId) throws ApplicationStorageManagementException { - Boolean isAppExist; - try { - isAppExist = DataHolder.getInstance().getApplicationManager().verifyApplicationExistenceById(appId); - } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException( - "Exception while verifing the application existence for the application with ID " + appId); - } - - return isAppExist; - } - - /** - * To validate the pre-request of the ApplicationRelease. - * - * @param applicationUuid UUID of the Application. - * @return Application related with the UUID - */ - private ApplicationRelease validateApplicationRelease(String applicationUuid) throws ApplicationManagementException { - if (applicationUuid == null) { - throw new ApplicationManagementException("Application UUID is null. Application UUID is a required " - + "parameter to get the relevant application."); - } - ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager(). - getReleaseByUuid(applicationUuid); - if (applicationRelease == null) { - throw new NotFoundException( - "Application with UUID " + applicationUuid + " does not exist."); + @Override + public void deleteAllApplicationReleaseArtifacts(List directoryPaths) throws ApplicationStorageManagementException { + for (String directoryBasePath : directoryPaths) { + deleteApplicationReleaseArtifacts(directoryBasePath); } - return applicationRelease; } private String getMD5(InputStream binaryFile) throws ApplicationStorageManagementException { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java index 6d55e999e4..e01914eaf7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java @@ -60,4 +60,9 @@ public class Constants { * Name of the image artifacts that are saved in the file system. */ public static final String[] IMAGE_ARTIFACTS = {"icon", "banner", "screenshot"}; + + /** + * Directory name of the release artifacts that are saved in the file system. + */ + public static final String RELEASE_ARTIFACT = "artifact"; } 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/LifecycleManagementAPI.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/LifecycleManagementAPI.java deleted file mode 100644 index 12c8d42452..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/LifecycleManagementAPI.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * you may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.device.application.mgt.publisher.api.services; - -import io.swagger.annotations.*; -import org.wso2.carbon.apimgt.annotations.api.Scope; -import org.wso2.carbon.apimgt.annotations.api.Scopes; -import org.wso2.carbon.device.application.mgt.publisher.api.beans.ErrorResponse; -import org.wso2.carbon.device.application.mgt.common.Application; -import org.wso2.carbon.device.application.mgt.common.LifecycleState; - -import java.util.List; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -/** - * Lifecycle management related APIs. - */ -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "Lifecycle Management Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "LifecycleManagementService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/lifecycles"), - }) - } - ), - tags = { - @Tag(name = "lifecycle_management", description = "Lifecycle Management related APIs") - } -) -@Scopes( - scopes = { - @Scope( - name = "Get Lifecycle Details", - description = "Get lifecycle details", - key = "perm:lifecycle:get", - permissions = {"/device-mgt/lifecycles/get"} - ), - @Scope( - name = "Add a lifecycle state", - description = "Add a lifecycle state", - key = "perm:lifecycle:add", - permissions = {"/device-mgt/lifecycles/add"} - ), - @Scope( - name = "Delete a lifecycle state", - description = "Delete a lifecycle state", - key = "perm:lifecycle:delete", - permissions = {"/device-mgt/lifecycles/delete"} - ) - } -) -@Path("/lifecycles") -@Api(value = "Lifecycle Management", description = "This API carries all lifecycle management related operations.") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public interface LifecycleManagementAPI { - - String SCOPE = "scope"; - - @GET - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get lifecycle states", - notes = "Get all lifecycle states", - tags = "Lifecycle Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:lifecycle:get") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved lifecycle states.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the lifecycle list.", - response = ErrorResponse.class) - }) - Response getLifecycleState(@PathParam("appId") int applicationId, - @PathParam("uuid") String applicationUuid); - - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Add a lifecycle state", - notes = "This will add a new lifecycle state", - tags = "Lifecycle Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:lifecycle:add") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully add a lifecycle state.", - response = Application.class), - @ApiResponse( - code = 304, - message = "Not Modified. \n " + - "Empty body because the client already has the latest version of the requested " - + "resource."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred adding a lifecycle state.", - response = ErrorResponse.class) - }) - Response addLifecycleState(@PathParam("appId") int applicationId, - @PathParam("uuid") String applicationUuid, - LifecycleState state); - - @Path("/{identifier}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "Remove lifecycle state", - notes = "Remove lifecycle state", - tags = "Lifecycle Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:platform:remove") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully deleted the platform"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting the platform.", - response = ErrorResponse.class) - }) - Response deleteLifecycleState(@PathParam("identifier") String identifier); - - @PUT - @Consumes("application/json") - @Path("/{uuid}/lifecycle") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Change the life cycle state of the application", - notes = "This will change the life-cycle state of the application", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:application-mgt:login") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully changed application state."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the application list.", - response = ErrorResponse.class) - }) - Response changeLifecycleState( - @ApiParam( - name = "UUID", - value = "Unique identifier of the Application", - required = true) - @PathParam("uuid") String applicationUUID, - @ApiParam( - name = "state", - value = "Lifecycle State that need to be changed to", - required = true) - @QueryParam("state") String state); - - @GET - @Consumes("application/json") - @Path("/{uuid}/lifecycle") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Change the life cycle state of the application", - notes = "This will retrieve the next life cycle states of the application based on the user and the " - + "current state", - tags = "Application Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:application-mgt:login") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved the lifecycle states.", - response = List.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the life-cycle states.", - response = ErrorResponse.class) - }) - Response getNextLifeCycleStates( - @ApiParam( - name = "UUID", - value = "Unique identifier of the Application", - required = true) - @PathParam("uuid") String applicationUUID); -}