Class WebServiceRequestParser

  • Direct Known Subclasses:
    QueryRequestParser, TemplateResultRequestParser

    public class WebServiceRequestParser
    extends java.lang.Object
    Base request parser that is used by advanced web service parsers.
    Author:
    Jakub Kulaviak, Alex Kalderimis
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ADD_HEADER_PARAMETER
      The parameter for requesting column headers
      static java.lang.String CALLBACK_PARAMETER
      The callback to be supplied for jsonp calls
      static java.lang.Integer DEFAULT_LIMIT
      10 000 000 default size actually means that web service will return all results
      static java.lang.String FILENAME_PARAMETER
      The parameter for setting the filename
      static java.lang.String FORMAT_PARAMETER_ANY
      The parameter for accepting any format
      static java.lang.String FORMAT_PARAMETER_COUNT
      Value of parameter when user wants comma separated output to be returned.
      static java.lang.String FORMAT_PARAMETER_CSV
      Value of parameter when user wants comma separated output to be returned.
      static java.lang.String FORMAT_PARAMETER_HTML
      Value of parameter when user wants html output to be returned.
      static java.lang.String FORMAT_PARAMETER_JSON
      Value of parameter when user wants json data
      static java.lang.String FORMAT_PARAMETER_JSON_COUNT
      Value of parameter when user wants json data suitable for using to construct tables with - this returns the rows of the table
      static java.lang.String FORMAT_PARAMETER_JSON_DATA_TABLE
      Value of parameter when user wants json data in a data table
      static java.lang.String FORMAT_PARAMETER_JSON_OBJ
      Value of parameter when user wants json data as nested objects representing records
      static java.lang.String FORMAT_PARAMETER_JSON_ROW
      Value of parameter when user wants json data suitable for using to construct tables with - this returns the rows of the table
      static java.lang.String FORMAT_PARAMETER_JSON_TABLE
      Value of parameter when user wants json data suitable for using to construct tables with
      static java.lang.String FORMAT_PARAMETER_JSONP
      Value of parameter when user wants jsonp data
      static java.lang.String FORMAT_PARAMETER_JSONP_COUNT
      Value of parameter when user wants json data as above but in a format suitable for cross site ajax calls
      static java.lang.String FORMAT_PARAMETER_JSONP_DATA_TABLE
      Value of parameter when user wants jsonp data in a data table
      static java.lang.String FORMAT_PARAMETER_JSONP_OBJ
      Value of parameter when user wants json data as above, but in a format suitable for cross site ajax calls
      static java.lang.String FORMAT_PARAMETER_JSONP_ROW
      Value of parameter when user wants json data as above but in a format suitable for cross site ajax calls
      static java.lang.String FORMAT_PARAMETER_JSONP_TABLE
      Value of parameter when user wants json data as above but in a format suitable for cross site ajax calls
      static java.lang.String FORMAT_PARAMETER_TAB
      Value of parameter when user wants tab separated output to be returned.
      static java.lang.String FORMAT_PARAMETER_TEXT
      Value of parameter when user wants plain text to be returned.
      static java.lang.String FORMAT_PARAMETER_TSV
      Value of parameter when user wants tab separated output to be returned.
      static java.lang.String FORMAT_PARAMETER_XML
      Value of parameter when user wants xml output to be returned.
      static java.lang.String LIMIT_PARAMETER
      Name of size parameter that determines number of returned results.
      static int MIN_LIMIT
      The smallest legal result size you can request
      static java.lang.String OUTPUT_PARAMETER
      Name of format parameter that specifies format of returned results.
      static java.lang.String START_PARAMETER
      Name of start parameter that determines index of first returned result.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<Format> getAcceptableFormats​(javax.servlet.http.HttpServletRequest request)
      Get the list of formats that this request finds acceptable.
      protected static Format interpretFormat​(java.lang.String format)
      Figure out which format the user wants.
      static boolean isCountRequest​(javax.servlet.http.HttpServletRequest request)  
      static boolean isJsonP​(javax.servlet.http.HttpServletRequest request)
      Work out if this a JSON-P request.
      protected static Format parseFormatFromPathInfo​(javax.servlet.http.HttpServletRequest request)
      Parse a format from the path-info of the request.
      void parseRequest​(javax.servlet.http.HttpServletRequest request, WebServiceInput input)
      Parses common parameters for all web services.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MIN_LIMIT

        public static final int MIN_LIMIT
        The smallest legal result size you can request
        See Also:
        Constant Field Values
      • START_PARAMETER

        public static final java.lang.String START_PARAMETER
        Name of start parameter that determines index of first returned result.
        See Also:
        Constant Field Values
      • LIMIT_PARAMETER

        public static final java.lang.String LIMIT_PARAMETER
        Name of size parameter that determines number of returned results.
        See Also:
        Constant Field Values
      • DEFAULT_LIMIT

        public static final java.lang.Integer DEFAULT_LIMIT
        10 000 000 default size actually means that web service will return all results
      • FORMAT_PARAMETER_XML

        public static final java.lang.String FORMAT_PARAMETER_XML
        Value of parameter when user wants xml output to be returned.
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_TAB

        public static final java.lang.String FORMAT_PARAMETER_TAB
        Value of parameter when user wants tab separated output to be returned.
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_TSV

        public static final java.lang.String FORMAT_PARAMETER_TSV
        Value of parameter when user wants tab separated output to be returned. (alternate)
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_TEXT

        public static final java.lang.String FORMAT_PARAMETER_TEXT
        Value of parameter when user wants plain text to be returned.
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_HTML

        public static final java.lang.String FORMAT_PARAMETER_HTML
        Value of parameter when user wants html output to be returned.
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_CSV

        public static final java.lang.String FORMAT_PARAMETER_CSV
        Value of parameter when user wants comma separated output to be returned.
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_COUNT

        public static final java.lang.String FORMAT_PARAMETER_COUNT
        Value of parameter when user wants comma separated output to be returned.
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSON

        public static final java.lang.String FORMAT_PARAMETER_JSON
        Value of parameter when user wants json data
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSONP

        public static final java.lang.String FORMAT_PARAMETER_JSONP
        Value of parameter when user wants jsonp data
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSON_DATA_TABLE

        public static final java.lang.String FORMAT_PARAMETER_JSON_DATA_TABLE
        Value of parameter when user wants json data in a data table
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSONP_DATA_TABLE

        public static final java.lang.String FORMAT_PARAMETER_JSONP_DATA_TABLE
        Value of parameter when user wants jsonp data in a data table
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSON_OBJ

        public static final java.lang.String FORMAT_PARAMETER_JSON_OBJ
        Value of parameter when user wants json data as nested objects representing records
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSONP_OBJ

        public static final java.lang.String FORMAT_PARAMETER_JSONP_OBJ
        Value of parameter when user wants json data as above, but in a format suitable for cross site ajax calls
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSON_TABLE

        public static final java.lang.String FORMAT_PARAMETER_JSON_TABLE
        Value of parameter when user wants json data suitable for using to construct tables with
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSONP_TABLE

        public static final java.lang.String FORMAT_PARAMETER_JSONP_TABLE
        Value of parameter when user wants json data as above but in a format suitable for cross site ajax calls
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSON_ROW

        public static final java.lang.String FORMAT_PARAMETER_JSON_ROW
        Value of parameter when user wants json data suitable for using to construct tables with - this returns the rows of the table
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSONP_ROW

        public static final java.lang.String FORMAT_PARAMETER_JSONP_ROW
        Value of parameter when user wants json data as above but in a format suitable for cross site ajax calls
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSON_COUNT

        public static final java.lang.String FORMAT_PARAMETER_JSON_COUNT
        Value of parameter when user wants json data suitable for using to construct tables with - this returns the rows of the table
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_JSONP_COUNT

        public static final java.lang.String FORMAT_PARAMETER_JSONP_COUNT
        Value of parameter when user wants json data as above but in a format suitable for cross site ajax calls
        See Also:
        Constant Field Values
      • OUTPUT_PARAMETER

        public static final java.lang.String OUTPUT_PARAMETER
        Name of format parameter that specifies format of returned results.
        See Also:
        Constant Field Values
      • CALLBACK_PARAMETER

        public static final java.lang.String CALLBACK_PARAMETER
        The callback to be supplied for jsonp calls
        See Also:
        Constant Field Values
      • ADD_HEADER_PARAMETER

        public static final java.lang.String ADD_HEADER_PARAMETER
        The parameter for requesting column headers
        See Also:
        Constant Field Values
      • FORMAT_PARAMETER_ANY

        public static final java.lang.String FORMAT_PARAMETER_ANY
        The parameter for accepting any format
        See Also:
        Constant Field Values
      • FILENAME_PARAMETER

        public static final java.lang.String FILENAME_PARAMETER
        The parameter for setting the filename
        See Also:
        Constant Field Values
    • Constructor Detail

      • WebServiceRequestParser

        public WebServiceRequestParser()
    • Method Detail

      • parseRequest

        public void parseRequest​(javax.servlet.http.HttpServletRequest request,
                                 WebServiceInput input)
        Parses common parameters for all web services. Must be called from parseRequest method in subclass else the parameters won't be set.
        Parameters:
        request - request
        input - web service input in which the parameters are set
      • interpretFormat

        protected static Format interpretFormat​(java.lang.String format)
        Figure out which format the user wants.
        Parameters:
        format - The format as provided by the user.
        Returns:
        A real Format.
      • isJsonP

        public static boolean isJsonP​(javax.servlet.http.HttpServletRequest request)
        Work out if this a JSON-P request.
        Parameters:
        request - The incoming request.
        Returns:
        Whether or not it is a JSON-P request.
      • parseFormatFromPathInfo

        protected static Format parseFormatFromPathInfo​(javax.servlet.http.HttpServletRequest request)
        Parse a format from the path-info of the request. By default, if the path-info is one of "xml", "json", "jsonp", "tsv" or "csv", then an appropriate format will be returned. All other values will cause null to be returned.
        Parameters:
        request - the incoming request.
        Returns:
        A format string.
      • getAcceptableFormats

        public static java.util.List<Format> getAcceptableFormats​(javax.servlet.http.HttpServletRequest request)
        Get the list of formats that this request finds acceptable.
        Parameters:
        request - The incoming client request.
        Returns:
        A list of formats this request can accept.
      • isCountRequest

        public static boolean isCountRequest​(javax.servlet.http.HttpServletRequest request)
        Parameters:
        request - The incoming request.
        Returns:
        true iff this request is looking for a count.