Class ActionLib


  • public class ActionLib
    extends java.lang.Object
    Operations related to servlets
    • Constructor Detail

      • ActionLib

        public ActionLib()
    • Method Detail

      • mapRequestToDataset

        public static java.lang.String mapRequestToDataset​(HttpAction action)
        Get the datasets from an HttpAction that assumes the form /dataset/service.
        Parameters:
        action - the request
        Returns:
        the dataset
      • mapRequestToDataset

        public static java.lang.String mapRequestToDataset​(java.lang.String uri)
        Map request to uri in the registry. A possible implementation for mapRequestToDataset(String) that assumes the form /dataset/service Returning null means no mapping found. The URI must be the action URI (no contact path)
      • mapRequestToEndpointName

        public static java.lang.String mapRequestToEndpointName​(HttpAction action,
                                                                DataAccessPoint dsRef)
        Calculate the operation, given action and data access point
      • mapRequestToDatasetLongest$

        public static java.lang.String mapRequestToDatasetLongest$​(java.lang.String uri,
                                                                   DataAccessPointRegistry registry)
        Implementation of mapRequestToDataset(String) that looks for the longest match in the registry. This includes use in direct naming GSP.
      • wholeRequestURL

        public static java.lang.String wholeRequestURL​(javax.servlet.http.HttpServletRequest request)
        Calculate the fill URL including query string for the HTTP request. This may be quite long.
        Parameters:
        request - HttpServletRequest
        Returns:
        String The full URL, including query string.
      • removeContextPath

        public static java.lang.String removeContextPath​(HttpAction action)
      • actionURI

        public static java.lang.String actionURI​(javax.servlet.http.HttpServletRequest request)
        Returns:
        the URI without context path of the webapp and without query string.
      • contentNegotation

        public static MediaType contentNegotation​(HttpAction action,
                                                  AcceptList myPrefs,
                                                  MediaType defaultMediaType)
        Negotiate the content-type and set the response headers
      • contentNegotationRDF

        public static MediaType contentNegotationRDF​(HttpAction action)
        Negotiate the content-type for an RDF triples syntax and set the response headers
      • contentNegotationQuads

        public static MediaType contentNegotationQuads​(HttpAction action)
        Negotiate the content-type for an RDF quads syntax and set the response headers
      • parseOrError

        public static void parseOrError​(HttpAction action,
                                        StreamRDF dest,
                                        Lang lang,
                                        java.lang.String base)
        Parse RDF content from the body of the request of the action, ends the request, and sends a 400 if there is a parse error.
        Throws:
        ActionErrorException
      • parse

        public static void parse​(HttpAction action,
                                 StreamRDF dest,
                                 Lang lang,
                                 java.lang.String base)
        Parse RDF content. This wraps up the parse step reading from an action.
        Throws:
        RiotParseException
      • parse

        public static void parse​(HttpAction action,
                                 StreamRDF dest,
                                 java.io.InputStream input,
                                 Lang lang,
                                 java.lang.String base)
        Parse RDF content. This wraps up the parse step reading from an input stream.
        Throws:
        RiotParseException
      • consumeBody

        public static void consumeBody​(HttpAction action)
        Reset the request input stream for an HttpAction if necessary. If there is a Content-Length header, throw away input to exhaust this request. If there is a no Content-Length header, no need to do anything - the connection is not reusable.
      • readFromRequest

        public static Graph readFromRequest​(HttpAction action,
                                            Lang defaultLang)
      • datasetResponse

        public static void datasetResponse​(HttpAction action,
                                           DatasetGraph dsg,
                                           Lang lang)
        Output a dataset to the HTTP response.
      • datasetResponse

        public static void datasetResponse​(HttpAction action,
                                           DatasetGraph dsg,
                                           RDFFormat format,
                                           java.lang.String contentType)
        Output a dataset to the HTTP response.
      • graphResponse

        public static void graphResponse​(HttpAction action,
                                         Graph graph,
                                         Lang lang)
        Output a graph to the HTTP response. Bad, unwritable RDF/XML causes a "406 Not Acceptable".
      • graphResponse

        public static void graphResponse​(HttpAction action,
                                         Graph graph,
                                         RDFFormat format,
                                         java.lang.String contentType)
        Output a graph to the HTTP response. Bad, unwritable RDF/XML causes a "406 Not Acceptable".
      • getNetworkFormatForLang

        public static RDFFormat getNetworkFormatForLang​(Lang lang)
        Return the preferred RDFFormat for a given Lang.
      • getOneHeader

        public static java.lang.String getOneHeader​(javax.servlet.http.HttpServletRequest request,
                                                    java.lang.String name)
        Get one or zero strings from an HTTP header
      • getContentType

        public static ContentType getContentType​(HttpAction action)
        Get the content type of an action or return the default.
        Parameters:
        action -
        Returns:
        ContentType
      • setCommonHeadersForOptions

        public static void setCommonHeadersForOptions​(javax.servlet.http.HttpServletResponse httpResponse)
      • setCommonHeaders

        public static void setCommonHeaders​(javax.servlet.http.HttpServletResponse httpResponse)
      • doOptionsGet

        public static void doOptionsGet​(HttpAction action)
      • doOptionsGetHead

        public static void doOptionsGetHead​(HttpAction action)
      • doOptionsGetPost

        public static void doOptionsGetPost​(HttpAction action)
      • doOptionsGetPostHead

        public static void doOptionsGetPostHead​(HttpAction action)
      • doOptionsGetPostDelete

        public static void doOptionsGetPostDelete​(HttpAction action)
      • doOptionsGetPostDeleteHead

        public static void doOptionsGetPostDeleteHead​(HttpAction action)
      • doOptionsPost

        public static void doOptionsPost​(HttpAction action)