Re-enabling retrieval of device info

merge-requests/7/head
prabathabey 9 years ago
parent dada719486
commit e002ffb54a

@ -201,69 +201,68 @@ public interface DeviceManagementService {
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince);
// @POST
// @ApiOperation(
// consumes = MediaType.APPLICATION_JSON,
// produces = MediaType.APPLICATION_JSON,
// httpMethod = "POST",
// value = "Retrieve devices information from the supplied device identifies.",
// notes = "This will return device information such as CPU usage, memory usage etc for supplied device " +
// "identifiers.",
// response = DeviceInfo.class,
// responseContainer = "List",
// tags = "Device Management")
// @ApiResponses(
// value = {
// @ApiResponse(
// code = 200,
// message = "OK. \n Information of the submitted list of devices is returned",
// response = DeviceInfo.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 = 303,
// message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
// responseHeaders = {
// @ResponseHeader(
// name = "Content-Location",
// description = "The Source URL of the document.")}),
// @ApiResponse(
// code = 304,
// message = "Not Modified. \n " +
// "Empty body because the client already has the latest version of the requested resource."),
// @ApiResponse(
// code = 400,
// message = "Bad Request. \n Invalid request or validation error."),
// @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 retrieving information of the list of the devices submitted.")
// })
// @Permission(scope = "device-info", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
// Response getDevicesInfo(
// @ApiParam(
// name = "deviceIds",
// value = "List of device identifiers",
// required = true) List<DeviceIdentifier> deviceIds,
// @ApiParam(
// name = "If-Modified-Since",
// value = "Timestamp of the last modified date",
// required = false)
// @HeaderParam("If-Modified-Since") String timestamp);
@POST
@Path("/get-info")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Retrieve devices information from the supplied device identifies.",
notes = "This will return device information such as CPU usage, memory usage etc for supplied device " +
"identifiers.",
tags = "Device Management")
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Information of the submitted list of devices is returned",
response = DeviceInfo.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 = 303,
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The Source URL of the document.")}),
@ApiResponse(
code = 304,
message = "Not Modified. \n " +
"Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@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 retrieving information of the list of the devices submitted.")
})
@Permission(scope = "device-info", permissions = {"/permission/admin/device-mgt/admin/devices/list"})
Response getDevicesInfo(
@ApiParam(
name = "If-Modified-Since",
value = "Timestamp of the last modified date",
required = false)
@HeaderParam("If-Modified-Since") String timestamp,
@ApiParam(
name = "deviceIds",
value = "List of device identifiers",
required = true) List<DeviceIdentifier> deviceIds);
@GET

@ -131,28 +131,29 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
}
return Response.status(Response.Status.OK).entity(deviceInfo).build();
}
//
// @POST
// @Override
// public Response getDevicesInfo(
// List<DeviceIdentifier> deviceIds,
// @HeaderParam("If-Modified-Since") String timestamp) {
// DeviceInformationManager informationManager;
// List<DeviceInfo> deviceInfo;
// try {
// informationManager = DeviceMgtAPIUtils.getDeviceInformationManagerService();
// deviceInfo = informationManager.getDevicesInfo(deviceIds);
// if (deviceInfo == null) {
// return Response.status(Response.Status.NOT_FOUND).entity("No device information is available for the " +
// "device list submitted").build();
// }
// } catch (DeviceDetailsMgtException e) {
// String msg = "Error occurred while getting the device information.";
// log.error(msg, e);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
// }
// return Response.status(Response.Status.OK).entity(deviceInfo).build();
// }
@POST
@Path("/get-info")
@Override
public Response getDevicesInfo(
@HeaderParam("If-Modified-Since") String timestamp,
List<DeviceIdentifier> deviceIds) {
DeviceInformationManager informationManager;
List<DeviceInfo> deviceInfo;
try {
informationManager = DeviceMgtAPIUtils.getDeviceInformationManagerService();
deviceInfo = informationManager.getDevicesInfo(deviceIds);
if (deviceInfo == null) {
return Response.status(Response.Status.NOT_FOUND).entity("No device information is available for the " +
"device list submitted").build();
}
} catch (DeviceDetailsMgtException e) {
String msg = "Error occurred while getting the device information.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
return Response.status(Response.Status.OK).entity(deviceInfo).build();
}
@GET
@Path("/{type}/{id}")

Loading…
Cancel
Save