Class ProtocolUtil


  • public class ProtocolUtil
    extends Object
    Utilities to help with the transition between HTTP requests/responses and values expected by the protocol.
    Author:
    Herko ter Horst, Arjohn Kampman
    • Constructor Summary

      Constructors 
      Constructor Description
      ProtocolUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <FF extends org.eclipse.rdf4j.common.lang.FileFormat,​S>
      S
      getAcceptableService​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.eclipse.rdf4j.common.lang.service.FileFormatServiceRegistry<FF,​S> serviceRegistry)  
      static void logAcceptableFormats​(javax.servlet.http.HttpServletRequest request)  
      static void logRequestParameters​(javax.servlet.http.HttpServletRequest request)
      Logs all request parameters of the supplied request.
      static boolean parseBooleanParam​(javax.servlet.http.HttpServletRequest request, String paramName, boolean defaultValue)  
      static org.eclipse.rdf4j.model.Resource[] parseContextParam​(javax.servlet.http.HttpServletRequest request, String paramName, org.eclipse.rdf4j.model.ValueFactory vf)  
      static org.eclipse.rdf4j.model.IRI parseGraphParam​(javax.servlet.http.HttpServletRequest request, org.eclipse.rdf4j.model.ValueFactory vf)  
      static long parseLongParam​(javax.servlet.http.HttpServletRequest request, String paramName, long defaultValue)  
      static org.eclipse.rdf4j.model.Resource parseResourceParam​(javax.servlet.http.HttpServletRequest request, String paramName, org.eclipse.rdf4j.model.ValueFactory vf)  
      static int parseTimeoutParam​(javax.servlet.http.HttpServletRequest request)
      Reads the Protocol.TIMEOUT_PARAM_NAME parameter from the request and (if present) parses it into an integer value.
      static org.eclipse.rdf4j.model.IRI parseURIParam​(javax.servlet.http.HttpServletRequest request, String paramName, org.eclipse.rdf4j.model.ValueFactory vf)  
      static org.eclipse.rdf4j.model.Value parseValueParam​(javax.servlet.http.HttpServletRequest request, String paramName, org.eclipse.rdf4j.model.ValueFactory vf)  
    • Constructor Detail

      • ProtocolUtil

        public ProtocolUtil()
    • Method Detail

      • parseValueParam

        public static org.eclipse.rdf4j.model.Value parseValueParam​(javax.servlet.http.HttpServletRequest request,
                                                                    String paramName,
                                                                    org.eclipse.rdf4j.model.ValueFactory vf)
                                                             throws ClientHTTPException
        Throws:
        ClientHTTPException
      • parseResourceParam

        public static org.eclipse.rdf4j.model.Resource parseResourceParam​(javax.servlet.http.HttpServletRequest request,
                                                                          String paramName,
                                                                          org.eclipse.rdf4j.model.ValueFactory vf)
                                                                   throws ClientHTTPException
        Throws:
        ClientHTTPException
      • parseURIParam

        public static org.eclipse.rdf4j.model.IRI parseURIParam​(javax.servlet.http.HttpServletRequest request,
                                                                String paramName,
                                                                org.eclipse.rdf4j.model.ValueFactory vf)
                                                         throws ClientHTTPException
        Throws:
        ClientHTTPException
      • parseGraphParam

        public static org.eclipse.rdf4j.model.IRI parseGraphParam​(javax.servlet.http.HttpServletRequest request,
                                                                  org.eclipse.rdf4j.model.ValueFactory vf)
                                                           throws ClientHTTPException
        Throws:
        ClientHTTPException
      • parseContextParam

        public static org.eclipse.rdf4j.model.Resource[] parseContextParam​(javax.servlet.http.HttpServletRequest request,
                                                                           String paramName,
                                                                           org.eclipse.rdf4j.model.ValueFactory vf)
                                                                    throws ClientHTTPException
        Throws:
        ClientHTTPException
      • parseBooleanParam

        public static boolean parseBooleanParam​(javax.servlet.http.HttpServletRequest request,
                                                String paramName,
                                                boolean defaultValue)
      • logRequestParameters

        public static void logRequestParameters​(javax.servlet.http.HttpServletRequest request)
        Logs all request parameters of the supplied request.
      • getAcceptableService

        public static <FF extends org.eclipse.rdf4j.common.lang.FileFormat,​S> S getAcceptableService​(javax.servlet.http.HttpServletRequest request,
                                                                                                           javax.servlet.http.HttpServletResponse response,
                                                                                                           org.eclipse.rdf4j.common.lang.service.FileFormatServiceRegistry<FF,​S> serviceRegistry)
                                                                                                    throws ClientHTTPException
        Throws:
        ClientHTTPException
      • parseTimeoutParam

        public static int parseTimeoutParam​(javax.servlet.http.HttpServletRequest request)
                                     throws ClientHTTPException
        Reads the Protocol.TIMEOUT_PARAM_NAME parameter from the request and (if present) parses it into an integer value.
        Parameters:
        request - the HttpServletRequest to read the parameter from
        Returns:
        the value of the timeout parameter as an integer (representing the timeout time in seconds), or 0 if no timeout parameter is specified in the request.
        Throws:
        ClientHTTPException - if the value of the timeout parameter is not a valid integer.
      • logAcceptableFormats

        public static void logAcceptableFormats​(javax.servlet.http.HttpServletRequest request)