From d60b88504528e3187d074146a8cf05434275ad6b Mon Sep 17 00:00:00 2001 From: lashanfaliq95 Date: Wed, 14 Mar 2018 14:13:56 +0530 Subject: [PATCH] changed the parameters "type" and "deviceId" as required for the last-know api. --- .../jaxrs/service/api/DeviceEventManagementService.java | 4 ++-- .../service/impl/DeviceEventManagementServiceImpl.java | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java index 2a29f962af..59e7e2e11b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java @@ -290,9 +290,9 @@ public interface DeviceEventManagementService { response = ErrorResponse.class) } ) - Response getLastKnownData(@ApiParam(name = "deviceId", value = "id of the device ", required = false) + Response getLastKnownData(@ApiParam(name = "deviceId", value = "id of the device ", required = true) @PathParam("deviceId") String deviceId, - @ApiParam(name = "type", value = "name of the device type", required = false) + @ApiParam(name = "type", value = "name of the device type", required = true) @PathParam("type") String deviceType, @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", 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/DeviceEventManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java index 1d1482899c..cba8879dcb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java @@ -382,7 +382,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe /** * Returns last known data points up to the limit if limit is specified. Otherwise returns last known data point. - * Limit need to be zero or positive. + * Limit parameter needs to be zero or positive. */ @GET @Path("/last-known/{type}/{deviceId}") @@ -408,11 +408,10 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe if (limit == 0) { EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1); return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); - } else if(limit>0){ + } else if (limit > 0) { EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit); return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); - } - else{ + } else { String errorMessage = "Invalid limit value"; return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); }