Improving ceritificate management webapp impl

revert-70aa11f8
prabathabey 8 years ago
parent ddfd678b2a
commit 3e21c6d50d

@ -227,7 +227,8 @@ public interface CertificateManagementAdminService {
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "DELETE", httpMethod = "DELETE",
value = "Delete an SSL certificate", 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 = { @ApiResponses(value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,

@ -22,7 +22,7 @@ import javax.ws.rs.core.Response;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@Path("/certificates") @Path("/admin/certificates")
public class CertificateManagementAdminServiceImpl implements CertificateManagementAdminService { public class CertificateManagementAdminServiceImpl implements CertificateManagementAdminService {
private static Log log = LogFactory.getLog(CertificateManagementAdminServiceImpl.class); private static Log log = LogFactory.getLog(CertificateManagementAdminServiceImpl.class);

@ -27,73 +27,73 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.Date; import java.util.Date;
@Path("/admin/groups") //@Path("/admin/groups")
@Produces(MediaType.APPLICATION_JSON) //@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) //@Consumes(MediaType.APPLICATION_JSON)
@Api(value = "Group Management Administrative Service", description = "This an API intended to be used by " + //@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. " + // "'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 ") // "Further, this is strictly restricted to admin users only ")
public interface GroupManagementAdminService { public interface GroupManagementAdminService {
@GET // @GET
@ApiOperation( // @ApiOperation(
produces = MediaType.APPLICATION_JSON, // produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", // httpMethod = "GET",
value = "Get groups by the name.", // value = "Get groups by the name.",
notes = "Get devices the name of device and tenant.", // notes = "Get devices the name of device and tenant.",
response = DeviceGroupWrapper.class, // response = DeviceGroupWrapper.class,
responseContainer = "List", // responseContainer = "List",
tags = "Group Management Administrative Service") // tags = "Group Management Administrative Service")
@ApiResponses(value = { // @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of groups.", // @ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of groups.",
response = DeviceGroupWrapper.class, // response = DeviceGroupWrapper.class,
responseContainer = "List", // responseContainer = "List",
responseHeaders = { // responseHeaders = {
@ResponseHeader( // @ResponseHeader(
name = "Content-Type", // name = "Content-Type",
description = "The content type of the body"), // description = "The content type of the body"),
@ResponseHeader( // @ResponseHeader(
name = "ETag", // name = "ETag",
description = "Entity Tag of the response resource.\n" + // description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."), // "Used by caches, or in conditional requests."),
@ResponseHeader( // @ResponseHeader(
name = "Last-Modified", // name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" + // description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."), // "Used by caches, or in conditional requests."),
}), // }),
@ApiResponse( // @ApiResponse(
code = 304, // code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), // message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse( // @ApiResponse(
code = 406, // code = 406,
message = "Not Acceptable.\n The requested media type is not supported"), // message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse( // @ApiResponse(
code = 500, // code = 500,
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the group list.") // 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"}) // @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/user/groups/list"})
Response getGroupsOfUser( // Response getGroupsOfUser(
@ApiParam( // @ApiParam(
name = "username", // name = "username",
value = "Username of the user.", // value = "Username of the user.",
required = true) // required = true)
@QueryParam("username") String username, // @QueryParam("username") String username,
@ApiParam( // @ApiParam(
name = "If-Modified-Since", // name = "If-Modified-Since",
value = "Timestamp of the last modified date", // value = "Timestamp of the last modified date",
required = false) // required = false)
@HeaderParam("If-Modified-Since") String timestamp, // @HeaderParam("If-Modified-Since") String timestamp,
@ApiParam( // @ApiParam(
name = "offset", // name = "offset",
value = "Starting point within the complete list of items qualified.", // value = "Starting point within the complete list of items qualified.",
required = false) // required = false)
@QueryParam("offset") int offset, // @QueryParam("offset") int offset,
@ApiParam( // @ApiParam(
name = "limit", // name = "limit",
value = "Maximum size of resource array to return.", // value = "Maximum size of resource array to return.",
required = false) // required = false)
@QueryParam("limit") int limit); // @QueryParam("limit") int limit);
//
} }

@ -31,32 +31,32 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.Date; import java.util.Date;
@Path("/admin/groups") //@Path("/admin/groups")
@Produces(MediaType.APPLICATION_JSON) //@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) //@Consumes(MediaType.APPLICATION_JSON)
public class GroupManagementAdminServiceImpl implements GroupManagementAdminService { public class GroupManagementAdminServiceImpl implements GroupManagementAdminService {
//
private static final Log log = LogFactory.getLog(GroupManagementAdminServiceImpl.class); // private static final Log log = LogFactory.getLog(GroupManagementAdminServiceImpl.class);
//
@Override // @Override
public Response getGroupsOfUser( // public Response getGroupsOfUser(
@QueryParam("username") String username, // @QueryParam("username") String username,
@HeaderParam("If-Modified-Since") String timestamp, // @HeaderParam("If-Modified-Since") String timestamp,
@QueryParam("offset") int offset, // @QueryParam("offset") int offset,
@QueryParam("limit") int limit) { // @QueryParam("limit") int limit) {
try { // try {
PaginationResult result = // PaginationResult result =
DeviceMgtAPIUtils.getGroupManagementProviderService().getGroups(username, offset, limit); // DeviceMgtAPIUtils.getGroupManagementProviderService().getGroups(username, offset, limit);
if (result != null && result.getRecordsTotal() > 0) { // if (result != null && result.getRecordsTotal() > 0) {
return Response.status(Response.Status.OK).entity(result).build(); // return Response.status(Response.Status.OK).entity(result).build();
} else { // } else {
return Response.status(Response.Status.NOT_FOUND).build(); // return Response.status(Response.Status.NOT_FOUND).build();
} // }
} catch (GroupManagementException e) { // } catch (GroupManagementException e) {
String msg = "ErrorResponse occurred while retrieving the groups of user '" + username + "'"; // String msg = "ErrorResponse occurred while retrieving the groups of user '" + username + "'";
log.error(msg, e); // log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} // }
} // }
} }

Loading…
Cancel
Save