add changes to 'since' QueryParam and 'if-modified-since' HeaderParam

revert-70aa11f8
madhawap 9 years ago
parent 3d416da6fe
commit 59119f9167

@ -83,15 +83,15 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
long sinceTimestamp =0; long sinceTimestamp =0;
boolean isIfModifiedSinceSet = false; boolean isIfModifiedSinceSet = false;
if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) {
Date sinceDate; Date ifSinceDate;
SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
try { try {
sinceDate = format.parse(ifModifiedSince); ifSinceDate = format.parse(ifModifiedSince);
} catch (ParseException e) { } catch (ParseException e) {
throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder().setCode(400l) throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder().setCode(400l)
.setMessage("Invalid date string is provided in 'If-Modified-Since' header").build()); .setMessage("Invalid date string is provided in 'If-Modified-Since' header").build());
} }
ifModifiedSinceTimestamp = sinceDate.getTime(); ifModifiedSinceTimestamp = ifSinceDate.getTime();
} }
if (since != null && !since.isEmpty()){ if (since != null && !since.isEmpty()){
Date sinceDate; Date sinceDate;
@ -112,7 +112,7 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
DeviceManagementProviderService dmService; DeviceManagementProviderService dmService;
try { try {
dmService = DeviceMgtAPIUtils.getDeviceManagementService(); dmService = DeviceMgtAPIUtils.getDeviceManagementService();
activities = dmService.getActivitiesUpdatedAfter(sinceTimestamp); activities = dmService.getActivitiesUpdatedAfter(sinceTimestamp/1000);
if (activities == null || activities.size() == 0) { if (activities == null || activities.size() == 0) {
if (isIfModifiedSinceSet) { if (isIfModifiedSinceSet) {
return Response.status(Response.Status.NOT_MODIFIED).entity("No activities " + return Response.status(Response.Status.NOT_MODIFIED).entity("No activities " +

Loading…
Cancel
Save