Class DocumentResponseHelper

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

public class DocumentResponseHelper extends Object
  • Method Details

    • getHeader

      public static Optional<String> getHeader(DocumentResponse response, HttpHeader header)
      Gets the string value of the http header header stored in the ResourceAttributes of the provided response.
      Parameters:
      response - DocumentResponse to extract value from
      header - HTTP Header to get the value for
      Returns:
      Optional string value of the header
    • getHeader

      public static Optional<String> getHeader(ResourceAttributes attributes, HttpHeader header)
      Gets the string value of the http header header stored in the provided attributes.
      Parameters:
      attributes - ResourceAttributes to extract value from
      header - HTTP header to get the value for
      Returns:
      Optional string value of the header
    • getLinkHeaders

      public static List<String> getLinkHeaders(DocumentResponse response)
      Gets a list of string values for HTTP Link headers stored in the provided response
      Parameters:
      response - DocumentResponse to extract values from
      Returns:
      List of string values from HTTP Link headers
    • getLinkRelations

      public static RelationAttributes getLinkRelations(DocumentResponse response)
      Extracts HTTP Link Relations from the HTTP Headers of the provided response. Note that the ResourceAttributes class is used to represent the resultant map of relations.
      Parameters:
      response - DocumentResponse to extract values from
      Returns:
      Map of link relations for HTTP Link headers
    • getLinkRelation

      public static Optional<String> getLinkRelation(ResourceAttributes linkRelations, LinkRelation relation)
      Gets a single link relation value from the provided linkRelations map of HTTP Link Relations
      Parameters:
      linkRelations - Map of HTTP Link Relations as ResourceAttributes
      relation - Link relation type to get
      Returns:
      Optional string value of the provided LinkRelation
    • getResourceType

      public static ShapeTreeResourceType getResourceType(DocumentResponse response)
      Determine a resource type by parsing Link rel=type headers
      Parameters:
      response - DocumentResponse to parse
      Returns:
      Type of resource
    • checkStringAsUrl

      public static void checkStringAsUrl(String urlString) throws ShapeTreeException
      Check the validity of a URL string value
      Parameters:
      urlString - URL string value to check
      Throws:
      ShapeTreeException - thrown when the URL value is malformed
    • stringToUrl

      public static URL stringToUrl(String urlString) throws ShapeTreeException
      Convert the provided URL string value to URL
      Parameters:
      urlString - URL string value to convert
      Returns:
      Converted URL
      Throws:
      ShapeTreeException - on Malformed URL string value
    • stringToUrl

      public static URL stringToUrl(URL context, String urlString) throws ShapeTreeException
      Convert the provided URL string value to a URL, using the provided URL context
      Parameters:
      context - URL context URL to create from
      urlString - URL string value to convert
      Returns:
      Converted URL
      Throws:
      ShapeTreeException - on Malformed URL string value