Package org.aktin.broker.rest
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 Summary
Constructors Constructor Description RequestAdminEndpoint() -
Method Summary
Modifier and Type Method Description voidaddRequestDefinition(String requestId, Reader content, javax.ws.rs.core.HttpHeaders headers)Add (additional) request definitions to an existing request.voidclearRequestTargetNodes(Integer requestId)Delete a restriction to certain target nodes.voidcloseRequest(Integer requestId)Mark a request as closed.javax.ws.rs.core.ResponsecreateRequest(Reader content, javax.ws.rs.core.HttpHeaders headers, javax.ws.rs.core.UriInfo info)Create a new request at the broker and return the request location in the HTTP-response headerLocation.voiddeleteRequest(String id)Delete a single existing requestprotected BrokerBackendgetBroker()javax.ws.rs.core.ResponsegetRequest(Integer requestId, javax.ws.rs.core.HttpHeaders headers)Get a single content representation for the given request which matches the provided Accept header.javax.ws.rs.core.ResponsegetRequestInfo(int requestId)Retrieve available HTTP methods for the given request IDRequestStatusListgetRequestInfo(Integer requestId)List status information for the specified request for each nodejavax.ws.rs.core.ResponsegetRequestNodeStatusMessage(Integer requestId, Integer nodeId)Retrieve request node status message (e.g. error messages) assigned to a request by a nodeRequestTargetNodesgetRequestTargetNodes(Integer requestId)Get the targeted nodes for this request.protected RequestTypeManagergetTypeManager()RequestListlistAllRequests()List all request available at this brokervoidpublishRequest(Integer requestId)Publish the given request.voidsetRequestTargetNodes(Integer requestId, RequestTargetNodes nodes)Apply a publication restriction to the request, making it available only to the given nodes.Methods inherited from class org.aktin.broker.rest.AbstractRequestEndpoint
getRequest, removeCharsetInfo
-
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 URISyntaxExceptionCreate a new request at the broker and return the request location in the HTTP-response headerLocation. This method can be used either to create an empty request if noContent-typeheader 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 theContent-typeheader must be present and the HTTP payload is used for the representation.- Parameters:
content- HTTP payload to use as first content representationheaders- HTTP request headers containing Content-typeinfo- 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 URISyntaxExceptionAdd (additional) request definitions to an existing request. This method is similar tocreateRequest(Reader, HttpHeaders, UriInfo)but expects the request to be already existing.- Parameters:
requestId- request idcontent- request definitionheaders- Content-type header- Throws:
URISyntaxException- URI syntax error
-
listAllRequests
List all request available at this broker- Returns:
- HTTP 200 with XML representation of all requests
-
deleteRequest
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.NotAcceptableExceptionGet a single content representation for the given request which matches the provided Accept header.- Parameters:
requestId- request id request idheaders- headers headers containing acceptable media types- Returns:
- request definition matching the Accept header
- Throws:
SQLException- SQL errorIOException- IO errorjavax.ws.rs.NotFoundException- request id does not existjavax.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, IOExceptionRetrieve 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 errorIOException- IO error
-
getRequestInfo
@GET @Path("{id}/status") @Produces("application/xml") public RequestStatusList getRequestInfo(@PathParam("id") Integer requestId) throws SQLException, IOExceptionList status information for the specified request for each node- Parameters:
requestId- request- Returns:
- status information list
- Throws:
SQLException- SQL errorIOException- IO error
-
getRequestTargetNodes
@GET @Path("{id}/nodes") @Produces("application/xml") public RequestTargetNodes getRequestTargetNodes(@PathParam("id") Integer requestId) throws SQLException, IOException, javax.ws.rs.NotFoundExceptionGet 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 errorIOException- IO errorjavax.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.NotFoundExceptionDelete 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 errorIOException- IO errorjavax.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.NotFoundExceptionApply 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 idnodes- selected list of nodes to which the request should be available- Throws:
SQLException- SQL errorIOException- IO errorjavax.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, IOExceptionRetrieve request node status message (e.g. error messages) assigned to a request by a node- Parameters:
requestId- request idnodeId- node id- Returns:
- error payload
- Throws:
SQLException- SQL errorIOException- IO error
-
publishRequest
@POST @Path("{id}/publish") public void publishRequest(@PathParam("id") Integer requestId) throws SQLExceptionPublish 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 SQLExceptionMark a request as closed. The client nodes will stop processing requests in closed state.- Parameters:
requestId- request id- Throws:
SQLException- SQL error
-
getTypeManager
- Specified by:
getTypeManagerin classAbstractRequestEndpoint
-
getBroker
- Specified by:
getBrokerin classAbstractRequestEndpoint
-