diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index 2fad649ab45..f1c13574f5d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -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 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 = "deviceIds", + value = "List of device identifiers", + required = true) List deviceIds, + @ApiParam( + name = "If-Modified-Since", + value = "Timestamp of the last modified date", + required = false) + @HeaderParam("If-Modified-Since") String timestamp); @GET diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index 4464f06e5c7..6122071b40f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -135,28 +135,28 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } return Response.status(Response.Status.OK).entity(deviceInfo).build(); } -// -// @POST -// @Override -// public Response getDevicesInfo( -// List deviceIds, -// @HeaderParam("If-Modified-Since") String timestamp) { -// DeviceInformationManager informationManager; -// List 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 + @Override + public Response getDevicesInfo( + List deviceIds, + @HeaderParam("If-Modified-Since") String timestamp) { + DeviceInformationManager informationManager; + List 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}")