@GET @Path("{objectid}") public Response getImage( @PathParam("objectid") String objectId, @HeaderParam("If-Modified-Since") String modified) { GridFSDBFile mongoFile = imageRepository.getImage(objectId); if (mongoFile != null) { if (modified != null) { if (new Date(modified).before(mongoFile.getUploadDate())) { return Response.status(Status.NOT_MODIFIED).build(); } } return Response.ok(mongoFile.getInputStream(), mongoFile.getContentType()) .lastModified(mongoFile.getUploadDate()) .build(); } return Response.status(Status.NOT_FOUND).build(); }
@DELETE @Path("{objectid}") public Response removeImages(@PathParam("objectid") String objectId) { imageRepository.removeImageAndItsChildren(objectId); return Response.ok().build(); }
@GET @Produces(MediaType.APPLICATION_JSON) public Response getAllImages() { return Response.ok(imageRepository.getAllImages()).build(); }