示例#1
0
  @POST
  @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  @ApiOperation(
      value = "Create representation",
      notes = "Create a new representation on an AIP",
      response = Representation.class)
  @ApiResponses(
      value = {
        @ApiResponse(code = 200, message = "OK", response = Representation.class),
        @ApiResponse(code = 409, message = "Already exists", response = ApiResponseMessage.class)
      })
  public Response createRepresentation(
      @ApiParam(value = "The AIP to add the representation", required = true)
          @PathParam(RodaConstants.API_PATH_PARAM_AIP_ID)
          String aipId,
      @ApiParam(value = "The desired representation ID", required = true)
          @PathParam(RodaConstants.API_PATH_PARAM_REPRESENTATION_ID)
          String representationId,
      @ApiParam(value = "The type of the new representation", required = true)
          @FormParam(RodaConstants.API_QUERY_PARAM_TYPE)
          String type,
      @ApiParam(value = "Reason to create representation", required = true)
          @FormParam(RodaConstants.API_QUERY_PARAM_DETAILS)
          String details,
      @ApiParam(
              value = "Choose format in which to get the representation",
              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
    Representation rep = Browser.createRepresentation(user, aipId, representationId, type, details);
    return Response.ok(rep, mediaType).build();
  }