Interface RestCollectionCreateView<P extends RestResource,C extends RestResource,I>

Type Parameters:
P - type of the parent resource
C - type of the child resource that is created
I - type of input the JSON parser will parse the input into.
All Superinterfaces:
RestCollectionView<P,C,I>, RestView<C>
All Known Implementing Classes:
AddMembers.CreateMember, AddSubgroups.CreateSubgroup, ChangeEdits.Create, CreateAccount, CreateBranch, CreateDashboard, CreateEmail, CreateGroup, CreateLabel, CreateProject, CreateSubmitRequirement, CreateTag, StarredChanges.Create

public interface RestCollectionCreateView<P extends RestResource,C extends RestResource,I> extends RestCollectionView<P,C,I>
RestView that supports accepting input and creating a resource.

The input must be supplied as JSON as the body of the HTTP request. Create views can be invoked by the HTTP methods PUT and POST.

The RestCreateView is only invoked when the parse method of the RestCollection throws ResourceNotFoundException, and hence the resource doesn't exist yet.

  • Method Summary

    Modifier and Type
    Method
    Description
    apply(P parentResource, IdString id, I input)
    Process the view operation by creating the resource.
  • Method Details

    • apply

      Response<?> apply(P parentResource, IdString id, I input) throws Exception
      Process the view operation by creating the resource.

      The returned response defines the status code that is returned to the client. For RestCollectionCreateViews this is usually 201 Created because a resource is created, but other 2XX or 3XX status codes are also possible (e.g. Response.Redirect can be returned for 302 Found).

      The value of the returned response is automatically converted to JSON unless it is a BinaryResult.

      Throwing a subclass of RestApiException results in a 4XX response to the client. For any other exception the client will get a 500 Internal Server Error response.

      Parameters:
      parentResource - parent resource of the resource that should be created
      id - the ID of the child resource that should be created
      input - input after parsing from request.
      Returns:
      response to return to the client
      Throws:
      RestApiException - if the resource creation is rejected
      Exception - the implementation of the view failed. The exception will be logged and HTTP 500 Internal Server Error will be returned to the client.