Class RequestHelper
java.lang.Object
com.janeirodigital.shapetrees.core.helpers.RequestHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic ShapeTreeContextbuildContextFromRequest(ShapeTreeRequest shapeTreeRequest) Builds a ShapeTreeContext from the incoming request.static org.apache.jena.graph.GraphgetIncomingBodyGraph(ShapeTreeRequest shapeTreeRequest, URL baseUrl, InstanceResource targetResource) Loads body of request into graphgetIncomingFocusNodes(ShapeTreeRequest shapeTreeRequest, URL baseUrl) static URLgetIncomingParentContainerUrl(ShapeTreeRequest shapeTreeRequest) Get the URL of the incoming resource target's parent containerstatic ShapeTreeResourceTypegetIncomingResourceType(ShapeTreeRequest shapeTreeRequest) Determines the type of resource represented by an incoming ShapeTreeRequest.static ShapeTreeManagergetIncomingShapeTreeManager(ShapeTreeRequest shapeTreeRequest, ManagerResource managerResource) getIncomingTargetShapeTrees(ShapeTreeRequest shapeTreeRequest, URL baseUrl) Gets target shape tree / hint from request headerstatic URLnormalizeSolidResourceUrl(URL url, String requestedName, ShapeTreeResourceType resourceType) Normalizes the BaseURL to use for a request based on the incoming request.
-
Method Details
-
buildContextFromRequest
Builds a ShapeTreeContext from the incoming request. Specifically it retrieves the incoming Authorization header and stashes that value for use on any additional requests made during validation.- Parameters:
shapeTreeRequest- Incoming request- Returns:
- ShapeTreeContext object populated with authentication details, if present
-
getIncomingResourceType
public static ShapeTreeResourceType getIncomingResourceType(ShapeTreeRequest shapeTreeRequest) throws ShapeTreeException Determines the type of resource represented by an incoming ShapeTreeRequest. Initial test is based on the incoming request headers, specifically the Content-Type header. If the content type is not one of the accepted RDF types, it will be treated as a NON-RDF source. Then the determination becomes whether or not the resource is a container.- Parameters:
shapeTreeRequest- The current incoming request- Returns:
- ShapeTreeResourceType aligning to current request
- Throws:
ShapeTreeException- ShapeTreeException throw, specifically if Content-Type is not included on request
-
getIncomingFocusNodes
public static List<URL> getIncomingFocusNodes(ShapeTreeRequest shapeTreeRequest, URL baseUrl) throws ShapeTreeException - Throws:
ShapeTreeException
-
getIncomingTargetShapeTrees
public static List<URL> getIncomingTargetShapeTrees(ShapeTreeRequest shapeTreeRequest, URL baseUrl) throws ShapeTreeException Gets target shape tree / hint from request header- Parameters:
shapeTreeRequest- Request- Returns:
- URL value of target shape tree
- Throws:
ShapeTreeException- ShapeTreeException
-
getIncomingShapeTreeManager
public static ShapeTreeManager getIncomingShapeTreeManager(ShapeTreeRequest shapeTreeRequest, ManagerResource managerResource) throws ShapeTreeException - Throws:
ShapeTreeException
-
normalizeSolidResourceUrl
public static URL normalizeSolidResourceUrl(URL url, String requestedName, ShapeTreeResourceType resourceType) throws ShapeTreeException Normalizes the BaseURL to use for a request based on the incoming request.- Parameters:
url- URL of requestrequestedName- Requested name of resource (provided on created resources via POST)resourceType- Description of resource (Container, NonRDF, Resource)- Returns:
- BaseURL to use for RDF Graphs
- Throws:
ShapeTreeException- ShapeTreeException
-
getIncomingBodyGraph
public static org.apache.jena.graph.Graph getIncomingBodyGraph(ShapeTreeRequest shapeTreeRequest, URL baseUrl, InstanceResource targetResource) throws ShapeTreeException Loads body of request into graph- Parameters:
shapeTreeRequest- RequestbaseUrl- BaseURL to use for graphtargetResource-- Returns:
- Graph representation of request body
- Throws:
ShapeTreeException- ShapeTreeException
-
getIncomingParentContainerUrl
public static URL getIncomingParentContainerUrl(ShapeTreeRequest shapeTreeRequest) throws ShapeTreeException Get the URL of the incoming resource target's parent container- Returns:
- URL of the parent container
- Throws:
ShapeTreeException
-