Adding AP improvements(incomplete)

feature/appm-store/pbac
lasantha 7 years ago
parent c21ddceae1
commit 11ea50e8ab

@ -795,115 +795,4 @@ public interface ApplicationManagementAPI {
value = "Whether to make it default or not",
required = false)
@QueryParam("isDefault") boolean isDefault);
//
// @POST
// @Path("/category")
// @Produces(MediaType.APPLICATION_JSON)
// @Consumes(MediaType.APPLICATION_JSON)
// @ApiOperation(
// consumes = MediaType.APPLICATION_JSON,
// produces = MediaType.APPLICATION_JSON,
// httpMethod = "POST",
// value = "Create an application category",
// notes = "This will create a new category",
// tags = "Application Management",
// extensions = {
// @Extension(properties = {
// @ExtensionProperty(name = SCOPE, value = "perm:application-category:create")
// })
// }
// )
// @ApiResponses(
// value = {
// @ApiResponse(
// code = 201,
// message = "OK. \n Successfully created a new category.",
// response = Category.class),
// @ApiResponse(
// code = 400,
// message = "Bad request. Required parameters are not provided"),
// @ApiResponse(
// code = 500,
// message = "Internal Server Error. \n Error occurred while creating application category.",
// response = ErrorResponse.class)
// })
// Response createCategory(
// @ApiParam(
// name = "category",
// value = "The category that need to be created.",
// required = true)
// @Valid Category category);
// @GET
// @Path("/category")
// @Produces(MediaType.APPLICATION_JSON)
// @Consumes(MediaType.APPLICATION_JSON)
// @ApiOperation(
// consumes = MediaType.APPLICATION_JSON,
// produces = MediaType.APPLICATION_JSON,
// httpMethod = "GET",
// value = "Get existing application categories",
// notes = "This will retrieve the existing categories",
// tags = "Application Management",
// extensions = {
// @Extension(properties = {
// @ExtensionProperty(name = SCOPE, value = "perm:application:create")
// })
// }
// )
// @ApiResponses(
// value = {
// @ApiResponse(
// code = 200,
// message = "OK. \n Successfully retrieved existing categories.",
// response = List.class),
// @ApiResponse(
// code = 400,
// message = "Bad request. Required parameters are not provided"),
// @ApiResponse(
// code = 500,
// message = "Internal Server Error. \n Error occurred while getting the application "
// + "categories.",
// response = ErrorResponse.class)
// })
// Response getCategories();
// @DELETE
// @Path("/category/{name}")
// @Produces(MediaType.APPLICATION_JSON)
// @Consumes(MediaType.APPLICATION_JSON)
// @ApiOperation(
// consumes = MediaType.APPLICATION_JSON,
// produces = MediaType.APPLICATION_JSON,
// httpMethod = "DELETE",
// value = "Delete application category with the given name",
// notes = "This will delete the application category with the given name",
// tags = "Application Management",
// extensions = {
// @Extension(properties = {
// @ExtensionProperty(name = SCOPE, value = "perm:application-category:delete")
// })
// }
// )
// @ApiResponses(
// value = {
// @ApiResponse(
// code = 200,
// message = "OK. \n Successfully deleted the application with the given name.",
// response = Application.class),
// @ApiResponse(
// code = 400,
// message = "Bad request. Required parameters are not provided"),
// @ApiResponse(
// code = 500,
// message = "Internal Server Error. \n Error occurred while deleting applcation category.",
// response = ErrorResponse.class)
// })
// Response deleteCategory(
// @ApiParam(
// name = "Name",
// value = "Name of the application category",
// required = true)
// @PathParam("name") String name);
}

@ -71,8 +71,10 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
@GET
@Consumes("application/json")
public Response getApplications(@QueryParam("offset") int offset, @QueryParam("limit") int limit,
@QueryParam("query") String searchQuery) {
public Response getApplications(
@QueryParam("query") String searchQuery,
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
@ -171,6 +173,47 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
}
}
@PUT
@Consumes("application/json")
public Response editApplication(@Valid Application application) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
application = applicationManager.editApplication(application);
} catch (NotFoundException e) {
return APIUtil.getResponse(e, Response.Status.NOT_FOUND);
} catch (ApplicationManagementException e) {
String msg = "Error occurred while creating the application";
log.error(msg, e);
return APIUtil.getResponse(e, Response.Status.BAD_REQUEST);
}
return Response.status(Response.Status.OK).entity(application).build();
}
@DELETE
@Path("/{appuuid}")
public Response deleteApplication(@PathParam("appuuid") String uuid) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager();
try {
applicationReleaseManager.deleteApplicationReleases(uuid);
applicationStorageManager.deleteApplicationArtifacts(uuid);
applicationManager.deleteApplication(uuid);
String responseMsg = "Successfully deleted the application: " + uuid;
return Response.status(Response.Status.OK).entity(responseMsg).build();
} catch (NotFoundException e) {
return APIUtil.getResponse(e, Response.Status.NOT_FOUND);
} catch (ApplicationManagementException e) {
String msg = "Error occurred while deleting the application: " + uuid;
log.error(msg, e);
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
} catch (ApplicationStorageManagementException e) {
log.error("Error occurred while deleteing the image artifacts of the application with the uuid " + uuid, e);
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
// ToDo
@PUT
@ -354,45 +397,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
}
}
@PUT
@Consumes("application/json")
public Response editApplication(@Valid Application application) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
application = applicationManager.editApplication(application);
} catch (NotFoundException e) {
return APIUtil.getResponse(e, Response.Status.NOT_FOUND);
} catch (ApplicationManagementException e) {
String msg = "Error occurred while creating the application";
log.error(msg, e);
return APIUtil.getResponse(e, Response.Status.BAD_REQUEST);
}
return Response.status(Response.Status.OK).entity(application).build();
}
@DELETE
@Path("/{appuuid}")
public Response deleteApplication(@PathParam("appuuid") String uuid) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager();
try {
applicationReleaseManager.deleteApplicationReleases(uuid);
applicationStorageManager.deleteApplicationArtifacts(uuid);
applicationManager.deleteApplication(uuid);
String responseMsg = "Successfully deleted the application: " + uuid;
return Response.status(Response.Status.OK).entity(responseMsg).build();
} catch (NotFoundException e) {
return APIUtil.getResponse(e, Response.Status.NOT_FOUND);
} catch (ApplicationManagementException e) {
String msg = "Error occurred while deleting the application: " + uuid;
log.error(msg, e);
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
} catch (ApplicationStorageManagementException e) {
log.error("Error occurred while deleteing the image artifacts of the application with the uuid " + uuid, e);
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
@Override
@POST
@ -592,51 +596,3 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
}
}
}
// @Override
// @POST
// @Path("/category")
// public Response createCategory(@Valid Category category) {
// if (category == null) {
// return Response.status(Response.Status.BAD_REQUEST).entity("Category is null. cannot create the "
// + "category").build();
// }
// try {
// Category createdCategory = APIUtil.getCategoryManager().createCategory(category);
// return Response.status(Response.Status.CREATED).entity(createdCategory).build();
// } catch (ApplicationManagementException e) {
// log.error("Application Management Exception while trying to create the application category", e);
// return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
// }
// }
//
// @Override
// @GET
// @Path("/category")
// public Response getCategories() {
// List<Category> categories;
// try {
// categories = APIUtil.getCategoryManager().getCategories();
// return Response.status(Response.Status.OK).entity(categories).build();
// } catch (ApplicationManagementException e) {
// log.error("Application Management Exception while trying to get application categories", e);
// return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
// }
// }
//
// @Override
// @DELETE
// @Path("/category/{name}")
// public Response deleteCategory(@PathParam("name") String name) {
// if (name == null || name.isEmpty()) {
// return Response.status(Response.Status.BAD_REQUEST).entity("Name cannot be null or empty.").build();
// }
// try {
// APIUtil.getCategoryManager().deleteCategory(name);
// return Response.status(Response.Status.OK).entity("Successfully deleted the category.").build();
// } catch (ApplicationManagementException e) {
// log.error("Application Management Exception while trying to delete category", e);
// return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
// }
// }
//}

@ -456,7 +456,7 @@ public interface DeviceManagementService {
String ifModifiedSince);
@PUT
@Path("/{type}/{id}")
@Path("/{type}/{id}/status")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",

Loading…
Cancel
Save