Ejemplo n.º 1
0
  @PUT
  @Path(
      "/{"
          + RodaConstants.API_PATH_PARAM_REPRESENTATION_UUID
          + "}/"
          + RodaConstants.API_DESCRIPTIVE_METADATA
          + "/{"
          + RodaConstants.API_PATH_PARAM_METADATA_ID
          + "}")
  @ApiOperation(
      value = "Update descriptive metadata",
      notes = "Upload a descriptive metadata file to update an existing one",
      response = DescriptiveMetadata.class)
  @ApiResponses(
      value = {
        @ApiResponse(code = 200, message = "OK", response = DescriptiveMetadata.class),
        @ApiResponse(code = 404, message = "Not found", response = ApiResponseMessage.class)
      })
  public Response updateDescriptiveMetadataOnRepresentation(
      @ApiParam(value = "The ID of the existing Representation", required = true)
          @PathParam(RodaConstants.API_PATH_PARAM_REPRESENTATION_UUID)
          String representationId,
      @ApiParam(value = "The ID of the existing metadata file to update", required = true)
          @PathParam(RodaConstants.API_PATH_PARAM_METADATA_ID)
          String metadataId,
      @FormDataParam(RodaConstants.API_PARAM_FILE) InputStream inputStream,
      @FormDataParam(RodaConstants.API_PARAM_FILE) FormDataContentDisposition fileDetail,
      @ApiParam(value = "The type of the metadata file (e.g. eadc2014, dc)", required = true)
          @QueryParam(RodaConstants.API_QUERY_PARAM_METADATA_TYPE)
          String metadataType,
      @ApiParam(value = "The version of the metadata type used", required = false)
          @QueryParam(RodaConstants.API_QUERY_PARAM_METADATA_VERSION)
          String metadataVersion,
      @ApiParam(
              value = "Choose format in which to get the response",
              allowableValues = RodaConstants.API_POST_PUT_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
    DescriptiveMetadata dm =
        Browser.updateRepresentationDescriptiveMetadataFile(
            user, representationId, metadataId, metadataType, metadataVersion, inputStream);

    return Response.ok(dm, mediaType).build();
  }