コード例 #1
0
  @GET
  @Path("/{" + RodaConstants.API_PATH_PARAM_REPRESENTATION_UUID + "}")
  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, ExtraMediaType.APPLICATION_ZIP})
  @ApiOperation(
      value = "Get representation",
      notes = "Get representation",
      response = Representation.class)
  @ApiResponses(
      value = {
        @ApiResponse(code = 200, message = "OK", response = Representation.class),
        @ApiResponse(code = 404, message = "Not found", response = ApiResponseMessage.class)
      })
  public Response retrieveRepresentation(
      @ApiParam(value = "The ID of the existing representation", required = true)
          @PathParam(RodaConstants.API_PATH_PARAM_REPRESENTATION_UUID)
          String representationUUID,
      @ApiParam(
              value = "Choose format in which to get the representation",
              allowableValues = RodaConstants.API_GET_LIST_MEDIA_TYPES)
          @QueryParam(RodaConstants.API_QUERY_KEY_ACCEPT_FORMAT)
          String acceptFormat)
      throws RODAException {
    String mediaType = ApiUtils.getMediaType(acceptFormat, request);

    // get user
    User user = UserUtility.getApiUser(request);

    // delegate action to controller
    EntityResponse aipRepresentation =
        Browser.retrieveAIPRepresentation(user, representationUUID, acceptFormat);

    if (aipRepresentation instanceof ObjectResponse) {
      ObjectResponse<Representation> rep = (ObjectResponse<Representation>) aipRepresentation;
      return Response.ok(rep.getObject(), mediaType).build();
    } else {
      return ApiUtils.okResponse((StreamResponse) aipRepresentation);
    }
  }