コード例 #1
0
ファイル: ImagesResource.java プロジェクト: solopaulo/yosane
 /* (non-Javadoc)
  * @see au.com.twobit.yosane.service.resource.impl.ImagesResource#getImageDetails(java.lang.String)
  */
 @GET
 @Path("/{imageId}")
 @Relation(relation = "image", method = METHOD_GET_IMAGE_DETAILS)
 public Response getImageDetails(@PathParam("imageId") String imageIdentifier) throws Exception {
   ImageStatus status = storage.getImageStatus(imageIdentifier);
   Image image =
       new Image(
           imageIdentifier,
           ImageFormat.png.name(),
           status,
           storage.getImageLastModifiedDate(imageIdentifier));
   String pathbase =
       String.format("%s/%s", getClass().getAnnotation(Path.class).value(), imageIdentifier);
   Link home = createLink(HomeResource.class);
   Link scanners = createLink(ScannersResource.class);
   Representation response =
       hal.newRepresentation(pathbase)
           .withLink(home.getRel(), home.getHref())
           .withLink(scanners.getRel(), scanners.getHref());
   if (status == ImageStatus.MISSING) {
     return ResourceHelper.generateErrorResponse(
         response, ERROR_IMAGE_MISSING, "Image is no longer available");
   }
   response
       .withLink("imageRotate", String.format("%s/rotate", pathbase))
       .withLink("imageDownload", String.format("%s/file", pathbase))
       .withLink("imageDownloadThumb", String.format("%s/file/thumb", pathbase))
       .withBean(image);
   return Response.ok(response.toString(RepresentationFactory.HAL_JSON)).build();
 }