mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
last-known api
updated the comment of the api and handled the error when a negative value is passed as the limit.
This commit is contained in:
parent
ac2a13273b
commit
b4f78337fa
@ -381,7 +381,8 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last know data point of the device type or last known data points upto the limit.
|
* 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.
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/last-known/{type}/{deviceId}")
|
@Path("/last-known/{type}/{deviceId}")
|
||||||
@ -407,10 +408,14 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
|
|||||||
if (limit == 0) {
|
if (limit == 0) {
|
||||||
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1);
|
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1);
|
||||||
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
||||||
} else {
|
} else if(limit>0){
|
||||||
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit);
|
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit);
|
||||||
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
String errorMessage = "Invalid limit value";
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||||
|
}
|
||||||
} catch (AnalyticsException e) {
|
} catch (AnalyticsException e) {
|
||||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||||
log.error(errorMsg);
|
log.error(errorMsg);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user