Merge pull request #288 from madhawap/rest-api-improvements

Fixes to if-modified-since in activity provider
merge-requests/7/head
Milan Perera 9 years ago
commit 17e89024c9

@ -79,7 +79,6 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
@QueryParam("limit") int limit, @QueryParam("limit") int limit,
@HeaderParam("If-Modified-Since") String ifModifiedSince) { @HeaderParam("If-Modified-Since") String ifModifiedSince) {
long sinceTimestamp = 0; long sinceTimestamp = 0;
boolean isSinceModifiedIsSet = false; boolean isSinceModifiedIsSet = false;
if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) {
@ -103,7 +102,8 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
activities = dmService.getActivitiesUpdatedAfter(timestamp); activities = dmService.getActivitiesUpdatedAfter(timestamp);
if (activities == null || activities.size() == 0) { if (activities == null || activities.size() == 0) {
if (isSinceModifiedIsSet) { if (isSinceModifiedIsSet) {
return Response.status(Response.Status.NOT_MODIFIED).entity(activities).build(); return Response.status(Response.Status.NOT_MODIFIED).entity("No activities " +
"after the timestamp provided in 'If-Modified-Since' header").build();
} }
throw new NotFoundException( throw new NotFoundException(
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No activities " + new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No activities " +

Loading…
Cancel
Save