Class RequestAdminEndpoint

java.lang.Object
org.aktin.broker.rest.AbstractRequestEndpoint
org.aktin.broker.rest.RequestAdminEndpoint

@Path("/broker/request")
public class RequestAdminEndpoint
extends AbstractRequestEndpoint
RESTful HTTP endpoint to manage broker requests. Request management is not done by client nodes. For client node usage, see MyBrokerEndpoint.
Author:
R.W.Majeed
  • Constructor Details

    • RequestAdminEndpoint

      public RequestAdminEndpoint()
  • Method Details

    • createRequest

      @POST public javax.ws.rs.core.Response createRequest​(Reader content, @Context javax.ws.rs.core.HttpHeaders headers, @Context javax.ws.rs.core.UriInfo info) throws URISyntaxException
      Create a new request at the broker and return the request location in the HTTP-response header Location. This method can be used either to create an empty request if no Content-type header is given (e.g. to add multiple content representations later) or it can be used to create a request already containing a request definition. In the latter case the Content-type header must be present and the HTTP payload is used for the representation.
      Parameters:
      content - HTTP payload to use as first content representation
      headers - HTTP request headers containing Content-type
      info - URI info for the response location
      Returns:
      request object with status 201 and location header.
      Throws:
      URISyntaxException - URI syntax processing error
    • addRequestDefinition

      @PUT @Path("{id}") public void addRequestDefinition​(@PathParam("id") String requestId, Reader content, @Context javax.ws.rs.core.HttpHeaders headers) throws URISyntaxException
      Add (additional) request definitions to an existing request. This method is similar to createRequest(Reader, HttpHeaders, UriInfo) but expects the request to be already existing.
      Parameters:
      requestId - request id
      content - request definition
      headers - Content-type header
      Throws:
      URISyntaxException - URI syntax error
    • listAllRequests

      @GET @Produces("application/xml") public RequestList listAllRequests()
      List all request available at this broker
      Returns:
      HTTP 200 with XML representation of all requests
    • deleteRequest

      @DELETE @Path("{id}") public void deleteRequest​(@PathParam("id") String id)
      Delete a single existing request
      Parameters:
      id - request id to delete
    • getRequest

      @GET @Path("{id}") public javax.ws.rs.core.Response getRequest​(@PathParam("id") Integer requestId, @Context javax.ws.rs.core.HttpHeaders headers) throws SQLException, IOException, javax.ws.rs.NotFoundException, javax.ws.rs.NotAcceptableException
      Get a single content representation for the given request which matches the provided Accept header.
      Parameters:
      requestId - request id request id
      headers - headers headers containing acceptable media types
      Returns:
      request definition matching the Accept header
      Throws:
      SQLException - SQL error
      IOException - IO error
      javax.ws.rs.NotFoundException - request id does not exist
      javax.ws.rs.NotAcceptableException - requested media type not available
    • getRequestInfo

      @OPTIONS @Path("{id}") public javax.ws.rs.core.Response getRequestInfo​(@PathParam("id") int requestId) throws SQLException, IOException
      Retrieve available HTTP methods for the given request ID
      Parameters:
      requestId - request id
      Returns:
      response with [@code Allow} header or 404 if request was not found
      Throws:
      SQLException - SQL error
      IOException - IO error
    • getRequestInfo

      @GET @Path("{id}/status") @Produces("application/xml") public RequestStatusList getRequestInfo​(@PathParam("id") Integer requestId) throws SQLException, IOException
      List status information for the specified request for each node
      Parameters:
      requestId - request
      Returns:
      status information list
      Throws:
      SQLException - SQL error
      IOException - IO error
    • getRequestTargetNodes

      @GET @Path("{id}/nodes") @Produces("application/xml") public RequestTargetNodes getRequestTargetNodes​(@PathParam("id") Integer requestId) throws SQLException, IOException, javax.ws.rs.NotFoundException
      Get the targeted nodes for this request. A resource is only returned, if the request is limited to / targeted at specifig nodes.
      Parameters:
      requestId - request
      Returns:
      target node list
      Throws:
      SQLException - SQL error
      IOException - IO error
      javax.ws.rs.NotFoundException - if the request is not targeted at specific nodes
    • clearRequestTargetNodes

      @DELETE @Path("{id}/nodes") public void clearRequestTargetNodes​(@PathParam("id") Integer requestId) throws SQLException, IOException, javax.ws.rs.NotFoundException
      Delete a restriction to certain target nodes. When the delete is successful, the request can be retrieved by all nodes.
      Parameters:
      requestId - request id
      Throws:
      SQLException - SQL error
      IOException - IO error
      javax.ws.rs.NotFoundException - request not found or request not targeted at specific nodes
    • setRequestTargetNodes

      @PUT @Path("{id}/nodes") @Consumes("application/xml") public void setRequestTargetNodes​(@PathParam("id") Integer requestId, RequestTargetNodes nodes) throws SQLException, IOException, javax.ws.rs.NotFoundException
      Apply a publication restriction to the request, making it available only to the given nodes. Only the specified nodes will be able to retrieve the request. To clear the restriction, submit an empty restriction list. Without the restriction, any node can download the request - also including nodes added in the future.
      Parameters:
      requestId - request id
      nodes - selected list of nodes to which the request should be available
      Throws:
      SQLException - SQL error
      IOException - IO error
      javax.ws.rs.NotFoundException - request not found
    • getRequestNodeStatusMessage

      @GET @Path("{id}/status/{nodeId}") public javax.ws.rs.core.Response getRequestNodeStatusMessage​(@PathParam("id") Integer requestId, @PathParam("nodeId") Integer nodeId) throws SQLException, IOException
      Retrieve request node status message (e.g. error messages) assigned to a request by a node
      Parameters:
      requestId - request id
      nodeId - node id
      Returns:
      error payload
      Throws:
      SQLException - SQL error
      IOException - IO error
    • publishRequest

      @POST @Path("{id}/publish") public void publishRequest​(@PathParam("id") Integer requestId) throws SQLException
      Publish the given request. After being published, the request can be retrieved by client nodes.
      Parameters:
      requestId - request id
      Throws:
      SQLException - SQL error
    • closeRequest

      @POST @Path("{id}/close") public void closeRequest​(@PathParam("id") Integer requestId) throws SQLException
      Mark a request as closed. The client nodes will stop processing requests in closed state.
      Parameters:
      requestId - request id
      Throws:
      SQLException - SQL error
    • getTypeManager

      protected RequestTypeManager getTypeManager()
      Specified by:
      getTypeManager in class AbstractRequestEndpoint
    • getBroker

      protected BrokerBackend getBroker()
      Specified by:
      getBroker in class AbstractRequestEndpoint