Adding App storing functionalities

Adding App deleting, editing and storing fucntionalities and fixed related bugs. To delete application artifacts, used recursive method and validation application is removed from the storage management. Since application validation is doing at application management and it is guaranteed that storage management is called after the application management removed the application validation from storage management
feature/appm-store/pbac
lasantha 7 years ago
parent 2cbf78d464
commit c3d0b375a5

@ -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. * Represents the exception that will be thrown when there is an issue while managing the resources.
*/ */
public class ResourceManagementException extends Exception { public class ResourceManagementException extends Exception {
ResourceManagementException(String message, Throwable ex) { public ResourceManagementException(String message, Throwable ex) {
super(message, ex); super(message, ex);
} }

@ -19,6 +19,7 @@
package org.wso2.carbon.device.application.mgt.common.services; 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.ApplicationRelease;
import org.wso2.carbon.device.application.mgt.common.ImageArtifact; 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.ApplicationManagementException;
@ -46,14 +47,13 @@ public interface ApplicationStorageManager {
/** /**
* To upload image artifacts related with an Application. * To upload image artifacts related with an Application.
* *
* @param applicationId ID of the application * @param applicationRelease Release of the application
* @param uuid Unique Identifier of the application
* @param iconFile Icon File input stream * @param iconFile Icon File input stream
* @param bannerFile Banner File input stream * @param bannerFile Banner File input stream
* @param screenshots Input Streams of screenshots * @param screenshots Input Streams of screenshots
* @throws ResourceManagementException Resource Management Exception. * @throws ResourceManagementException Resource Management Exception.
*/ */
ApplicationRelease updateImageArtifacts(int applicationId, String uuid, InputStream iconFile, ApplicationRelease updateImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFile,
InputStream bannerFile, List<InputStream> screenshots) InputStream bannerFile, List<InputStream> screenshots)
throws ResourceManagementException, ApplicationManagementException; throws ResourceManagementException, ApplicationManagementException;
@ -70,60 +70,27 @@ public interface ApplicationStorageManager {
/** /**
* To upload release artifacts for an Application. * To upload release artifacts for an Application.
* *
* @param applicationId Id of the application. * @param applicationRelease applicationRelease Application release of a particular application.
* @param applicationUuid UUID of the application related with the release.
* @param binaryFile Binary File for the release. * @param binaryFile Binary File for the release.
* @throws ResourceManagementException Resource Management Exception. * @throws ApplicationStorageManagementException 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.
*/ */
InputStream getReleasedArtifacts(String applicationUUID, String versionName) ApplicationRelease updateReleaseArtifacts(ApplicationRelease applicationRelease, InputStream binaryFile)
throws ApplicationStorageManagementException; 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. * To delete the artifacts related with particular Application Release.
* *
* @param applicationUUID UUID of the Application. * @param directoryPath Hash value of the application artifact.
* @param version Version of ApplicationRelease that need to be deleted. * @throws ApplicationStorageManagementException Not Found Exception.
* @throws ApplicationStorageManagementException Application Storage Management Exception.
*/ */
void deleteApplicationReleaseArtifacts(String applicationUUID, String version) void deleteApplicationReleaseArtifacts(String directoryPath) throws ApplicationStorageManagementException;
throws ApplicationStorageManagementException;
/** /**
* To delete all release artifacts related with particular Application Release. * 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 * @throws ApplicationStorageManagementException Application Storage Management Exception
*/ */
void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws ApplicationStorageManagementException; void deleteAllApplicationReleaseArtifacts(List<String> 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;
} }

@ -24,25 +24,17 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext; 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.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.ApplicationStorageManagementException;
import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException; 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.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.ConnectionManagerUtil;
import org.wso2.carbon.device.application.mgt.core.util.Constants; import org.wso2.carbon.device.application.mgt.core.util.Constants;
import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil; import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Arrays;
import java.util.List; import java.util.List;
import static org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil.saveFile; import static org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil.saveFile;
@ -69,9 +61,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
@Override @Override
public ApplicationRelease uploadImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFileStream, public ApplicationRelease uploadImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFileStream,
InputStream bannerFileStream, List<InputStream> screenShotStreams) InputStream bannerFileStream, List<InputStream> screenShotStreams)
throws ResourceManagementException { throws ResourceManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String artifactDirectoryPath = null; String artifactDirectoryPath;
String iconStoredLocation; String iconStoredLocation;
String bannerStoredLocation; String bannerStoredLocation;
String scStoredLocation; String scStoredLocation;
@ -112,11 +104,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
return applicationRelease; return applicationRelease;
} catch (IOException e) { } catch (IOException e) {
throw new ApplicationStorageManagementException( throw new ApplicationStorageManagementException("IO Exception while saving the screens hots for " +
"IO Exception while saving the screens hots for the " + "application " + "the application " + applicationRelease.getUuid(), e);
applicationRelease.getUuid(), e);
} catch (ApplicationStorageManagementException e) { } catch (ApplicationStorageManagementException e) {
ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationStorageManagementException("Application Management DAO exception while trying to " throw new ApplicationStorageManagementException("Application Management DAO exception while trying to "
+ "update the screen-shot count for the application " + applicationRelease.getUuid() + + "update the screen-shot count for the application " + applicationRelease.getUuid() +
" for the tenant id " + tenantId, e); " for the tenant id " + tenantId, e);
@ -124,28 +114,44 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
@Override @Override
public ApplicationRelease updateImageArtifacts(int applicationId, String uuid, InputStream iconFileStream, public ApplicationRelease updateImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFileStream,
InputStream bannerFileStream, List<InputStream> screenShotStreams) InputStream bannerFileStream, List<InputStream> screenShotStreams)
throws ResourceManagementException, ApplicationManagementException { throws ResourceManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
try { 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); applicationRelease = uploadImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, screenShotStreams);
return applicationRelease; return applicationRelease;
} catch (ApplicationStorageManagementException e) { } catch (ApplicationStorageManagementException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationStorageManagementException("Application Storage exception while trying to" throw new ApplicationStorageManagementException("Application Storage exception while trying to"
+ " update the screen-shot count for the application " + applicationId + " for the tenant " + " update the screen-shot count for the application Release " + applicationRelease.getUuid() +
+ tenantId, e); " 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);
} }
} }
@Override @Override
@ -165,7 +171,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
+ "application UUID " + applicationRelease.getUuid() + " is " + artifactDirectoryPath); + "application UUID " + applicationRelease.getUuid() + " is " + artifactDirectoryPath);
} }
try { try {
saveFile(binaryFile, artifactDirectoryPath); saveFile(binaryFile, artifactDirectoryPath + Constants.RELEASE_ARTIFACT);
applicationRelease.setAppStoredLoc(artifactDirectoryPath); applicationRelease.setAppStoredLoc(artifactDirectoryPath);
applicationRelease.setAppHashValue(md5OfApp); applicationRelease.setAppHashValue(md5OfApp);
} catch (IOException e) { } catch (IOException e) {
@ -181,183 +187,43 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
@Override @Override
public ApplicationRelease updateReleaseArtifacts(int applicationId, String applicationUuid, InputStream binaryFile) public ApplicationRelease updateReleaseArtifacts(ApplicationRelease applicationRelease, InputStream binaryFile)
throws ResourceManagementException { throws ApplicationStorageManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
ApplicationRelease applicationRelease = null; if (binaryFile != null) {
try { try {
applicationRelease = validateApplicationRelease(applicationUuid); deleteApplicationReleaseArtifacts(applicationRelease.getAppStoredLoc());
applicationRelease = uploadReleaseArtifacts(applicationRelease, binaryFile); applicationRelease = uploadReleaseArtifacts(applicationRelease, binaryFile);
return applicationRelease; } catch (ApplicationStorageManagementException e) {
} catch (ApplicationManagementException e) { throw new ApplicationStorageManagementException("Application Artifact doesn't contains in the System", e);
throw new ApplicationStorageManagementException("Application Management exception while trying to" } catch (ResourceManagementException e) {
+ " update the Application artifact for the application " + applicationId + " for the tenant " throw new ApplicationStorageManagementException("Application Artifact Updating failed", e);
+ tenantId, e); }
} }
}
//todo return applicationRelease;
@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);
// }
}
//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<ApplicationRelease> 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 @Override
public ImageArtifact getImageArtifact(String applicationUUID, String name, int count) throws public void deleteApplicationReleaseArtifacts(String directoryPath) throws ApplicationStorageManagementException {
ApplicationStorageManagementException { String artifactPath = storagePath + directoryPath;
return null; File artifact = new File(artifactPath);
// 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);
// }
// }
}
/** if (artifact.exists()) {
* To validate the image artifact names. StorageManagementUtil.deleteDir(artifact);
* } else {
* @param name Name of the image artifact. throw new ApplicationStorageManagementException("Tried to delete application release, but it doesn't exist " +
* @throws ApplicationStorageManagementException Application Storage Management Exception "in the system");
*/
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));
} }
} }
/** @Override
* To validate the Application before storing and retrieving the artifacts of a particular application. public void deleteAllApplicationReleaseArtifacts(List<String> directoryPaths) throws ApplicationStorageManagementException {
* for (String directoryBasePath : directoryPaths) {
* @param appId ID of the Application deleteApplicationReleaseArtifacts(directoryBasePath);
* @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.");
} }
return applicationRelease;
} }
private String getMD5(InputStream binaryFile) throws ApplicationStorageManagementException { private String getMD5(InputStream binaryFile) throws ApplicationStorageManagementException {

@ -60,4 +60,9 @@ public class Constants {
* Name of the image artifacts that are saved in the file system. * Name of the image artifacts that are saved in the file system.
*/ */
public static final String[] IMAGE_ARTIFACTS = {"icon", "banner", "screenshot"}; 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";
} }

@ -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);
}
Loading…
Cancel
Save