Class RequestHelper

java.lang.Object
com.janeirodigital.shapetrees.core.helpers.RequestHelper

public class RequestHelper extends Object
  • Method Details

    • buildContextFromRequest

      public static ShapeTreeContext buildContextFromRequest(ShapeTreeRequest shapeTreeRequest)
      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 request
      requestedName - 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 - Request
      baseUrl - BaseURL to use for graph
      targetResource -
      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