Ejemplo n.º 1
0
  @DELETE
  @Path(
      "/{"
          + RodaConstants.API_PATH_PARAM_REPRESENTATION_UUID
          + "}/"
          + RodaConstants.API_PRESERVATION_METADATA
          + "/{"
          + RodaConstants.API_PATH_PARAM_FILE_ID
          + "}")
  @ApiOperation(
      value = "Delete representation preservation file",
      notes = "Delete a preservation file for a representation.",
      response = PreservationMetadata.class)
  @ApiResponses(
      value = {
        @ApiResponse(code = 200, message = "OK", response = PreservationMetadata.class),
        @ApiResponse(code = 404, message = "Not found", response = ApiResponseMessage.class)
      })
  public Response deletePreservationMetadataFromFile(
      @ApiParam(value = "The ID of the existing representation")
          @PathParam(RodaConstants.API_PATH_PARAM_REPRESENTATION_UUID)
          String representationId,
      @ApiParam(value = "The ID of the existing file", required = true)
          @PathParam(RodaConstants.API_PATH_PARAM_FILE_ID)
          String fileId,
      @ApiParam(
              value = "Choose preservation metadata type",
              allowableValues =
                  "REPRESENTATION, FILE, INTELLECTUAL_ENTITY, AGENT, EVENT, RIGHTS_STATEMENT, ENVIRONMENT, OTHER",
              defaultValue = "FILE",
              required = true)
          @QueryParam(RodaConstants.API_QUERY_PARAM_TYPE)
          String type,
      @ApiParam(
              value = "Choose format in which to get the response",
              allowableValues = RodaConstants.API_DELETE_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);

    Browser.deletePreservationMetadataWithRepresentation(user, representationId, fileId, type);
    return Response.ok(
            new ApiResponseMessage(ApiResponseMessage.OK, "Preservation file deleted"), mediaType)
        .build();
  }