Esempio n. 1
0
 @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();
 }
Esempio n. 2
0
 @DELETE
 @Path("{objectid}")
 public Response removeImages(@PathParam("objectid") String objectId) {
   imageRepository.removeImageAndItsChildren(objectId);
   return Response.ok().build();
 }
Esempio n. 3
0
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 public Response getAllImages() {
   return Response.ok(imageRepository.getAllImages()).build();
 }