From 3e21c6d50dd8b1ec74b059e131485cfec81c28cf Mon Sep 17 00:00:00 2001 From: prabathabey Date: Tue, 31 May 2016 17:49:26 +0530 Subject: [PATCH] Improving ceritificate management webapp impl --- .../CertificateManagementAdminService.java | 3 +- ...CertificateManagementAdminServiceImpl.java | 2 +- .../admin/GroupManagementAdminService.java | 130 +++++++++--------- .../GroupManagementAdminServiceImpl.java | 52 +++---- 4 files changed, 94 insertions(+), 93 deletions(-) diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/CertificateManagementAdminService.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/CertificateManagementAdminService.java index c7cbc13b52..6988f31712 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/CertificateManagementAdminService.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/CertificateManagementAdminService.java @@ -227,7 +227,8 @@ public interface CertificateManagementAdminService { produces = MediaType.APPLICATION_JSON, httpMethod = "DELETE", value = "Delete an SSL certificate", - notes = "Delete an SSL certificate that's on the client end") + notes = "Delete an SSL certificate that's on the client end", + tags = "Certificate Management") @ApiResponses(value = { @ApiResponse( code = 200, diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java index ad3b1e8108..ebe9953f8b 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java @@ -22,7 +22,7 @@ import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.List; -@Path("/certificates") +@Path("/admin/certificates") public class CertificateManagementAdminServiceImpl implements CertificateManagementAdminService { private static Log log = LogFactory.getLog(CertificateManagementAdminServiceImpl.class); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java index 1143447c39..4d5915684b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java @@ -27,73 +27,73 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.Date; -@Path("/admin/groups") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Api(value = "Group Management Administrative Service", description = "This an API intended to be used by " + - "'internal' components to log in as an admin user and do a selected number of operations. " + - "Further, this is strictly restricted to admin users only ") +//@Path("/admin/groups") +//@Produces(MediaType.APPLICATION_JSON) +//@Consumes(MediaType.APPLICATION_JSON) +//@Api(value = "Group Management Administrative Service", description = "This an API intended to be used by " + +// "'internal' components to log in as an admin user and do a selected number of operations. " + +// "Further, this is strictly restricted to admin users only ") public interface GroupManagementAdminService { - @GET - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Get groups by the name.", - notes = "Get devices the name of device and tenant.", - response = DeviceGroupWrapper.class, - responseContainer = "List", - tags = "Group Management Administrative Service") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of groups.", - response = DeviceGroupWrapper.class, - responseContainer = "List", - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource has been modified the last time.\n" + - "Used by caches, or in conditional requests."), - }), - @ApiResponse( - code = 304, - message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported"), - @ApiResponse( - code = 500, - message = "Internal Server ErrorResponse. \n Server error occurred while fetching the group list.") - }) - @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/user/groups/list"}) - Response getGroupsOfUser( - @ApiParam( - name = "username", - value = "Username of the user.", - required = true) - @QueryParam("username") String username, - @ApiParam( - name = "If-Modified-Since", - value = "Timestamp of the last modified date", - required = false) - @HeaderParam("If-Modified-Since") String timestamp, - @ApiParam( - name = "offset", - value = "Starting point within the complete list of items qualified.", - required = false) - @QueryParam("offset") int offset, - @ApiParam( - name = "limit", - value = "Maximum size of resource array to return.", - required = false) - @QueryParam("limit") int limit); - +// @GET +// @ApiOperation( +// produces = MediaType.APPLICATION_JSON, +// httpMethod = "GET", +// value = "Get groups by the name.", +// notes = "Get devices the name of device and tenant.", +// response = DeviceGroupWrapper.class, +// responseContainer = "List", +// tags = "Group Management Administrative Service") +// @ApiResponses(value = { +// @ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of groups.", +// response = DeviceGroupWrapper.class, +// responseContainer = "List", +// responseHeaders = { +// @ResponseHeader( +// name = "Content-Type", +// description = "The content type of the body"), +// @ResponseHeader( +// name = "ETag", +// description = "Entity Tag of the response resource.\n" + +// "Used by caches, or in conditional requests."), +// @ResponseHeader( +// name = "Last-Modified", +// description = "Date and time the resource has been modified the last time.\n" + +// "Used by caches, or in conditional requests."), +// }), +// @ApiResponse( +// code = 304, +// message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), +// @ApiResponse( +// code = 406, +// message = "Not Acceptable.\n The requested media type is not supported"), +// @ApiResponse( +// code = 500, +// message = "Internal Server ErrorResponse. \n Server error occurred while fetching the group list.") +// }) +// @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/user/groups/list"}) +// Response getGroupsOfUser( +// @ApiParam( +// name = "username", +// value = "Username of the user.", +// required = true) +// @QueryParam("username") String username, +// @ApiParam( +// name = "If-Modified-Since", +// value = "Timestamp of the last modified date", +// required = false) +// @HeaderParam("If-Modified-Since") String timestamp, +// @ApiParam( +// name = "offset", +// value = "Starting point within the complete list of items qualified.", +// required = false) +// @QueryParam("offset") int offset, +// @ApiParam( +// name = "limit", +// value = "Maximum size of resource array to return.", +// required = false) +// @QueryParam("limit") int limit); +// } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 7fe91394f4..7573df0f5e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -31,32 +31,32 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.Date; -@Path("/admin/groups") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +//@Path("/admin/groups") +//@Produces(MediaType.APPLICATION_JSON) +//@Consumes(MediaType.APPLICATION_JSON) public class GroupManagementAdminServiceImpl implements GroupManagementAdminService { - - private static final Log log = LogFactory.getLog(GroupManagementAdminServiceImpl.class); - - @Override - public Response getGroupsOfUser( - @QueryParam("username") String username, - @HeaderParam("If-Modified-Since") String timestamp, - @QueryParam("offset") int offset, - @QueryParam("limit") int limit) { - try { - PaginationResult result = - DeviceMgtAPIUtils.getGroupManagementProviderService().getGroups(username, offset, limit); - if (result != null && result.getRecordsTotal() > 0) { - return Response.status(Response.Status.OK).entity(result).build(); - } else { - return Response.status(Response.Status.NOT_FOUND).build(); - } - } catch (GroupManagementException e) { - String msg = "ErrorResponse occurred while retrieving the groups of user '" + username + "'"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } +// +// private static final Log log = LogFactory.getLog(GroupManagementAdminServiceImpl.class); +// +// @Override +// public Response getGroupsOfUser( +// @QueryParam("username") String username, +// @HeaderParam("If-Modified-Since") String timestamp, +// @QueryParam("offset") int offset, +// @QueryParam("limit") int limit) { +// try { +// PaginationResult result = +// DeviceMgtAPIUtils.getGroupManagementProviderService().getGroups(username, offset, limit); +// if (result != null && result.getRecordsTotal() > 0) { +// return Response.status(Response.Status.OK).entity(result).build(); +// } else { +// return Response.status(Response.Status.NOT_FOUND).build(); +// } +// } catch (GroupManagementException e) { +// String msg = "ErrorResponse occurred while retrieving the groups of user '" + username + "'"; +// log.error(msg, e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); +// } +// } }