Class ServletTool


  • public final class ServletTool
    extends HTTPTool

    HTTP Servlet toolbox

    • Constructor Summary

      Constructors 
      Constructor Description
      ServletTool()
      Constructor
      Don't instantiate this class, it only provides static variables and methods
    • Method Summary

      Modifier and Type Method Description
      static void addHeaders​(javax.servlet.http.HttpServletResponse response, java.util.Map<java.lang.String,​java.lang.String> headers)
      Add HTTP headers to reponse
      static void badRequest​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object data)
      Bad request response (HTTP code 400)
      static java.lang.String cleanURI​(javax.servlet.http.HttpServletRequest request)
      Get clean URI
      static java.lang.String debugHTTPRequest​(javax.servlet.http.HttpServletRequest request)
      Displays HTTP request information (request items, parameters and cookies) for debug purposes
      static java.lang.String debugHTTPRequest​(javax.servlet.http.HttpServletRequest request, boolean parameters)
      Displays HTTP request information (request items, parameters and cookies) for debug purposes
      static java.lang.String debugHTTPRequest​(javax.servlet.http.HttpServletRequest request, boolean parameters, boolean attributes)
      Displays HTTP request information (request items, parameters and cookies) for debug purposes
      static void forbidden​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object data)
      Forbidden response (HTTP code 403)
      static java.lang.String getAPIAuthToken​(javax.servlet.http.HttpServletRequest request)
      Get auth token in the API endpoint context
      static Grant getAPIGrant​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Gets an API grant from request (creates it if not found in session and loads it if not loaded).
      static java.lang.String getBaseRequestURL​(javax.servlet.http.HttpServletRequest request)
      Return base request URL
      static java.util.Map<java.lang.String,​java.lang.Object> getBasicAuthLoginPassword​(javax.servlet.http.HttpServletRequest request, java.lang.String header)
      Return user and password from a HTTP basic authentication header (base64 encoded).
      static boolean getBooleanParamValue​(javax.servlet.http.HttpServletRequest request, java.lang.String name)
      Gets single boolean value from HTTP parameter
      static int getCacheMaxAge​(Grant g)
      Returns configured maximum cache age
      static java.lang.String getCharset​(javax.servlet.http.HttpServletRequest request)
      Get content charset
      static java.lang.String getClientId​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Set and get unique client ID and store it as a cookie
      static java.lang.String getContentType​(javax.servlet.http.HttpServletRequest request)
      Get content type (without charset)
      static java.lang.String getContextPath​(javax.servlet.http.HttpServletRequest request)
      Deprecated. 
      static java.lang.String getContextURL​(javax.servlet.http.HttpServletRequest request)
      Get context URL for HTTP request
      static java.lang.String getCookie​(javax.servlet.http.HttpServletRequest request, java.lang.String name)
      Gets cookie value (or null if cookie is not defined)
      static java.lang.String getCookieValue​(javax.servlet.http.HttpServletRequest request, java.lang.String name)
      Get a cookie value from request
      static java.lang.String getDeepLinkFromRequest​(javax.servlet.http.HttpServletRequest request)
      Get deep link parameter from request
      static double getDoubleParamValue​(javax.servlet.http.HttpServletRequest request, java.lang.String name)
      Gets single double value from HTTP parameter
      static float getFloatParamValue​(javax.servlet.http.HttpServletRequest request, java.lang.String name)
      Gets single float value from HTTP parameter
      static java.lang.String getFullRequestURL​(javax.servlet.http.HttpServletRequest request)
      Return full request URL including GET parameters
      static Grant getGrant​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Gets the UI grant from request (creates it if not found and loads it if not loaded)
      static Grant getGrant​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean create)
      Gets the UI grant from request (creates it if not found and loads it if not loaded)
      static Grant getGrant​(javax.servlet.http.HttpSession session)
      Gets the UI grant from request (it is supposed to be existing in this case, otherwise getGrant(request) must be used instead))
      static int getIEVersion​(javax.servlet.http.HttpServletRequest request)
      Get Internet Explorer major version number (returns -1 if other browser)
      static int getIntParamValue​(javax.servlet.http.HttpServletRequest request, java.lang.String name)
      Gets single integer value from HTTP parameter
      static Grant getIOGrant​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Gets an IO grant from request (creates it if not found in session and loads it if not loaded).
      static java.lang.String getLoginFromRequest​(javax.servlet.http.HttpServletRequest request, boolean force)
      Retrieve current user login from HTTP request (defaults to public user login)
      static long getLongParamValue​(javax.servlet.http.HttpServletRequest request, java.lang.String name)
      Gets single long value from HTTP parameter
      static java.lang.String getMethod​(javax.servlet.http.HttpServletRequest request)
      Request method (taking into account HTTP method override header if present
      static java.lang.String getMobileFromRequest​(javax.servlet.http.HttpServletRequest request)
      Get mobile parameter from request
      static HTMLPage getPage​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Gets the UI page from request (creates and initializes it if not found)
      static HTMLPage getPage​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean load, boolean full)
      Gets the UI page from request (creates and initializes it if not found)
      static HTMLPage getPage​(javax.servlet.http.HttpSession session)
      Gets the UI page from session (it is supposed to be existing in this case, otherwise getPage(request) must be used instead))
      static java.lang.String getParamValue​(javax.servlet.http.HttpServletRequest request, java.lang.String name)
      Gets single string value from HTTP parameter
      static java.lang.String getParamValue​(javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.String def)
      Gets single string value from HTTP parameter
      static java.lang.String[] getParamValues​(javax.servlet.http.HttpServletRequest request, java.lang.String name)
      Gets multiple string values HTTP parameter
      static Grant getPublicGrant​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Gets the UI public grant from request (creates it if not found and loads it if not loaded)
      static Grant getPublicGrant​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean create)
      Gets the UI public grant from request (creates it if not found and loads it if not loaded)
      static Grant getPublicGrant​(javax.servlet.http.HttpSession session)
      Gets the UI public grant from request (it is supposed to be existing in this case, otherwise getGrant(request) must be used instead))
      static HTMLPage getPublicPage​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Gets the UI public page from request (creates and initializes it if not found)
      static HTMLPage getPublicPage​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean load)
      Gets the UI public page from request (creates and initializes it if not found)
      static HTMLPage getPublicPage​(javax.servlet.http.HttpSession session)
      Gets the UI public page from session (it is supposed to be existing in this case, otherwise gePublictPage(request) must be used instead))
      static java.lang.String getRemoteAddr​(javax.servlet.http.HttpServletRequest request)
      Get remote address (either from the X-Real-IP header or directly using request.getRemoteAddr())
      static java.lang.String getRequestBody​(javax.servlet.http.HttpServletRequest request)
      Reads request body from HTTP request
      static byte[] getRequestBodyAsByteArray​(javax.servlet.http.HttpServletRequest request)
      Reads request body as byte array from HTTP request
      static java.lang.String getRowIdFromParameters​(ObjectDB obj, Parameters params)
      Get object row ID field values from parameters (using actual object row ID name or, if not found, default row ID name)
      static java.lang.String getRowIdFromRequest​(ObjectDB obj, javax.servlet.http.HttpServletRequest request)
      Get object row ID field values from HTTP request (using actual object row ID name or, if not found, default row ID name)
      static java.lang.String getScopeFromRequest​(javax.servlet.http.HttpServletRequest request)
      Get scope parameter from request
      static java.lang.String getServerURL​(javax.servlet.http.HttpServletRequest request)
      Get server URL for HTTP request
      static org.json.JSONObject getTokenData​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Get token data from request ad response
      static com.simplicite.webapp.ObjectTreeview getTreeview​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Gets the UI tree view manager
      static java.lang.String getUserAgent​(javax.servlet.http.HttpServletRequest request)
      Get UserAgent
      static WebServicesFactory getWebServicesFactory​(Grant g, javax.servlet.http.HttpServletRequest request, int endpoint)
      Gets a web services factory from request (creates it if not found)
      static boolean hasPage​(javax.servlet.http.HttpServletRequest request)
      Check if the UI page is present and initialized
      static boolean hasPublicPage​(javax.servlet.http.HttpServletRequest request)
      Check if the UI public page is present and initialized
      static void internalServerError​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object data)
      Internal server error response (HTTP code 500)
      static boolean isAjax​(javax.servlet.http.HttpServletRequest request)
      Checks if request is from an Ajax call (checking the non normative X-Requested-With header).
      static boolean isAPIRequest​(javax.servlet.http.HttpServletRequest request)
      Checks whether request is done on the API endpoint
      static boolean isBrowser​(javax.servlet.http.HttpServletRequest request, java.lang.String browser)
      Checks if user agent is specified browser.
      static boolean isChrome​(javax.servlet.http.HttpServletRequest request)
      Checks if user agent is Chrome.
      static boolean isFirefox​(javax.servlet.http.HttpServletRequest request)
      Checks if user agent is Firefox.
      static boolean isGitRequest​(javax.servlet.http.HttpServletRequest request)
      Checks whether request is done on the Git endpoint
      static boolean isIE​(javax.servlet.http.HttpServletRequest request)
      Checks if user agent is Internet Explorer.
      static boolean isIEMaxVersion​(javax.servlet.http.HttpServletRequest request, int maxVersion)
      Check if browser is Internet Explorer with specified major version number or less
      static boolean isIORequest​(javax.servlet.http.HttpServletRequest request)
      Checks whether request is done on the I/O endpoint
      static boolean isMobileBrowser​(javax.servlet.http.HttpServletRequest request)
      Checks if user agent is a mobile browser.
      static boolean isMobileWebkit​(javax.servlet.http.HttpServletRequest request)
      Checks if user agent is a iPhone/iPad/iPod/Android Safari browser.
      static boolean isOpera​(javax.servlet.http.HttpServletRequest request)
      Checks if user agent is Opera.
      static boolean isSafari​(javax.servlet.http.HttpServletRequest request)
      Checks if user agent is Safari.
      static boolean isSOAP​(javax.servlet.http.HttpServletRequest request)
      Checks if request is from a SOAP call (checking the presence of the SOAPAction header).
      static boolean isUIRequest​(javax.servlet.http.HttpServletRequest request)
      Checks whether request is done on the UI endpoint
      static void javascript​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String script, java.lang.String title, java.lang.String icon, java.lang.String help, java.lang.String html, java.lang.String[] css, java.lang.String[] js, org.json.JSONObject metadata)
      Send a JavaScript statement with optional elements (for use in the responsive UI)
      static java.lang.String jspInclude​(java.lang.String url)
      JSP include statement in dynamic content (to be processed from including JSP by the processContent() method)
      static void notFound​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object data)
      Not found response (HTTP code 404)
      static void processContent​(java.lang.String content, java.io.Writer out, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Process dynamic content with JSP includes substitution if any (added using the jspInclude() method)
      static void redirect​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String url)
      Send an HTTP redirect
      static void redirect​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String url, int type)
      Send a redirect
      static void removeCookie​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String name)
      Remove a cookie
      static void removeCookie​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String domain, java.lang.String path, java.lang.String name)
      Remove a cookie
      static void reset​(javax.servlet.http.HttpServletResponse response, boolean all)
      Reset the response buffer
      static void selectObjectContext​(ObjectDB obj, java.lang.String rowId, int context, Parameters.ParamContext params)
      Select the record and apply the context on different rowId
      static void send​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String mime, java.lang.Object data)
      Send response
      static void send​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String mime, java.lang.Object data, int status)
      Send response
      static void send​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String mime, java.lang.Object data, int status, java.util.Map<java.lang.String,​java.lang.String> headers)
      Send response
      static void setContentLength​(javax.servlet.http.HttpServletResponse response, byte[] content)
      Generates Content-Length HTTP header for a string using platform encoding
      static void setContentLength​(javax.servlet.http.HttpServletResponse response, java.lang.String content)
      Generates Content-Length HTTP header for a string using platform encoding
      static void setContentLength​(javax.servlet.http.HttpServletResponse response, java.lang.String content, java.lang.String encoding)
      Generates Content-Length HTTP header for a string using specified encoding
      static void setCookie​(javax.servlet.http.HttpServletResponse response, java.lang.String path, java.lang.String name, java.lang.String value)
      Sets cookie with 1 year max age
      static void setCookie​(javax.servlet.http.HttpServletResponse response, java.lang.String path, java.lang.String name, java.lang.String value, int maxAge)
      Sets cookie
      static void setCookie​(javax.servlet.http.HttpServletResponse response, java.lang.String domain, java.lang.String path, java.lang.String name, java.lang.String value, int maxAge)
      Sets cookie
      static void setHTTPCacheHeaders​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int maxAge)
      Generates cache related HTTP headers
      static void setHTTPCacheHeaders​(javax.servlet.http.HttpServletResponse response, int maxAge)
      Deprecated. 
      static void setHTTPExportMimeType​(javax.servlet.http.HttpServletResponse response, java.lang.String media, java.lang.String fileName)
      Generates particular HTTP mime type headers for content exports
      static void setHTTPHeaders​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Generates default HTTP headers
      static void setHTTPHeaders​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String mimeType, int maxAge)
      Generates HTTP headers
      static void setHTTPHeadersForCSS​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int maxAge)
      Generates HTTP headers for CSS stylesheet
      static void setHTTPHeadersForCSV​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Generates HTTP headers for CSV data
      static void setHTTPHeadersForHTML​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Generates HTTP headers for HTML page
      static void setHTTPHeadersForJPG​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int maxAge)
      Generates HTTP headers for JPG data
      static void setHTTPHeadersForJS​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int maxAge)
      Generates HTTP headers for javascript
      static void setHTTPHeadersForJSON​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Generates HTTP headers for JSON data
      static void setHTTPHeadersForPNG​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int maxAge)
      Generates HTTP headers for PNG data
      static void setHTTPHeadersForRSS​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Generates HTTP headers for RSS data
      static void setHTTPHeadersForTXT​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Generates HTTP headers for plain text
      static void setHTTPHeadersForXML​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Generates HTTP headers for XML data
      static void setHTTPHeadersForZIP​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Generates HTTP headers for ZIP data
      static void setObjectFields​(ObjectDB obj, Parameters params, int context, java.lang.String dotReplacement, boolean checkUpdatable)  
      static void setObjectFieldsFromParameters​(ObjectDB obj, Parameters params, java.lang.String dotReplacement)
      Sets object field values from parameters
      static void setObjectFilterFromRequest​(ObjectDB obj, ServletParameters params, ObjectField field, java.lang.String fieldParamName)  
      static void setObjectFiltersFromRequest​(ObjectDB obj, ServletParameters params)
      Sets object field filters from HTTP parameters
      static void setObjectFiltersFromRequest​(ObjectDB obj, ServletParameters params, java.lang.String dotReplacement)
      Sets object field filters from HTTP parameters
      static java.lang.String[] split​(javax.servlet.http.HttpServletRequest request)
      Split request cleaned URI into parts (without the context path)
      static void unauthorized​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object data, boolean requestAuthentication)
      Unauthorized response (HTTP code 401)
      static int writeStream​(java.io.InputStream in, java.lang.String name, java.lang.String contentType, java.lang.String contentDisposition, int maxAge, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Stream data as response
      • Methods inherited from class java.lang.Object

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

      • HTTP_STATUS_LABELS

        public static final java.util.HashMap<java.lang.Integer,​java.lang.String> HTTP_STATUS_LABELS
        HTTP status code labels
      • REDIRECT_TYPE_HTTP

        public static final int REDIRECT_TYPE_HTTP
        HTTP redirect
        See Also:
        Constant Field Values
      • REDIRECT_TYPE_JSON

        public static final int REDIRECT_TYPE_JSON
        JSON with redirect information
        See Also:
        Constant Field Values
      • REDIRECT_TYPE_JS

        public static final int REDIRECT_TYPE_JS
        Client side JavaScript redirect
        See Also:
        Constant Field Values
    • Constructor Detail

      • ServletTool

        public ServletTool()
        Constructor
        Don't instantiate this class, it only provides static variables and methods
    • Method Detail

      • getRemoteAddr

        public static java.lang.String getRemoteAddr​(javax.servlet.http.HttpServletRequest request)
        Get remote address (either from the X-Real-IP header or directly using request.getRemoteAddr())
        Parameters:
        request - HTTP request
        Returns:
        Remote IP address
      • getCacheMaxAge

        public static int getCacheMaxAge​(Grant g)

        Returns configured maximum cache age

        Parameters:
        g - Grant
        Returns:
        Max cache age in seconds
      • setHTTPCacheHeaders

        @Deprecated
        public static void setHTTPCacheHeaders​(javax.servlet.http.HttpServletResponse response,
                                               int maxAge)
        Deprecated.
      • setHTTPCacheHeaders

        public static void setHTTPCacheHeaders​(javax.servlet.http.HttpServletRequest request,
                                               javax.servlet.http.HttpServletResponse response,
                                               int maxAge)

        Generates cache related HTTP headers

        Parameters:
        response - HTTP response
        maxAge - Max cache age, <= 0 means no caching allowed, > 0 means cached for specified number of seconds
      • setHTTPHeaders

        public static void setHTTPHeaders​(javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response)

        Generates default HTTP headers

        Parameters:
        request - HTTP request
        response - HTTP response
      • setHTTPHeadersForHTML

        public static void setHTTPHeadersForHTML​(javax.servlet.http.HttpServletRequest request,
                                                 javax.servlet.http.HttpServletResponse response)

        Generates HTTP headers for HTML page

        Parameters:
        request - HTTP request
        response - HTTP response
      • setHTTPHeadersForJSON

        public static void setHTTPHeadersForJSON​(javax.servlet.http.HttpServletRequest request,
                                                 javax.servlet.http.HttpServletResponse response)

        Generates HTTP headers for JSON data

        Parameters:
        request - HTTP request
        response - HTTP response
      • setHTTPHeadersForXML

        public static void setHTTPHeadersForXML​(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response)

        Generates HTTP headers for XML data

        Parameters:
        request - HTTP request
        response - HTTP response
      • setHTTPHeadersForCSV

        public static void setHTTPHeadersForCSV​(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response)

        Generates HTTP headers for CSV data

        Parameters:
        request - HTTP request
        response - HTTP response
      • setHTTPHeadersForTXT

        public static void setHTTPHeadersForTXT​(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response)

        Generates HTTP headers for plain text

        Parameters:
        request - HTTP request
        response - HTTP response
      • setHTTPHeadersForRSS

        public static void setHTTPHeadersForRSS​(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response)

        Generates HTTP headers for RSS data

        Parameters:
        request - HTTP request
        response - HTTP response
      • setHTTPHeadersForJS

        public static void setHTTPHeadersForJS​(javax.servlet.http.HttpServletRequest request,
                                               javax.servlet.http.HttpServletResponse response,
                                               int maxAge)

        Generates HTTP headers for javascript

        Parameters:
        request - HTTP request
        response - HTTP response
        maxAge - Max cache age, <= 0 means no caching allowed, > 0 means cached for specified number of seconds, < 0 means custom cache headers (no cache header is generated)
      • setHTTPHeadersForCSS

        public static void setHTTPHeadersForCSS​(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response,
                                                int maxAge)

        Generates HTTP headers for CSS stylesheet

        Parameters:
        request - HTTP request
        response - HTTP response
        maxAge - Max cache age, <= 0 means no caching allowed, > 0 means cached for specified number of seconds, < 0 means custom cache headers (no cache header is generated)
      • setHTTPHeadersForZIP

        public static void setHTTPHeadersForZIP​(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response)

        Generates HTTP headers for ZIP data

        Parameters:
        request - HTTP request
        response - HTTP response
      • setHTTPHeadersForPNG

        public static void setHTTPHeadersForPNG​(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response,
                                                int maxAge)

        Generates HTTP headers for PNG data

        Parameters:
        request - HTTP request
        response - HTTP response
        maxAge - Max cache age, <= 0 means no caching allowed, > 0 means cached for specified number of seconds, < 0 means custom cache headers (no cache header is generated)
      • setHTTPHeadersForJPG

        public static void setHTTPHeadersForJPG​(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response,
                                                int maxAge)

        Generates HTTP headers for JPG data

        Parameters:
        request - HTTP request
        response - HTTP response
        maxAge - Max cache age, <= 0 means no caching allowed, > 0 means cached for specified number of seconds, < 0 means custom cache headers (no cache header is generated)
      • getMethod

        public static java.lang.String getMethod​(javax.servlet.http.HttpServletRequest request)

        Request method (taking into account HTTP method override header if present

        Parameters:
        request - HTTP request
      • cleanURI

        public static java.lang.String cleanURI​(javax.servlet.http.HttpServletRequest request)
        Get clean URI
        Parameters:
        request - Request
      • split

        public static java.lang.String[] split​(javax.servlet.http.HttpServletRequest request)
        Split request cleaned URI into parts (without the context path)
        Parameters:
        request - Request
      • setHTTPHeaders

        public static void setHTTPHeaders​(javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response,
                                          java.lang.String mimeType,
                                          int maxAge)

        Generates HTTP headers

        Parameters:
        request - HTTP request
        response - HTTP response
        mimeType - Forced MIME type, null means no forced MIME type
        maxAge - Max cache age, <= 0 means no caching allowed, > 0 means cached for specified number of seconds, < 0 means custom cache headers (no cache header is generated)
      • setContentLength

        public static void setContentLength​(javax.servlet.http.HttpServletResponse response,
                                            byte[] content)

        Generates Content-Length HTTP header for a string using platform encoding

        Parameters:
        response - HTTP response
        content - Content as byte array
      • setContentLength

        public static void setContentLength​(javax.servlet.http.HttpServletResponse response,
                                            java.lang.String content,
                                            java.lang.String encoding)

        Generates Content-Length HTTP header for a string using specified encoding

        Parameters:
        response - HTTP response
        content - Content as string
        encoding - Encoding
      • setContentLength

        public static void setContentLength​(javax.servlet.http.HttpServletResponse response,
                                            java.lang.String content)

        Generates Content-Length HTTP header for a string using platform encoding

        Parameters:
        response - HTTP response
        content - Content as string
      • getContextPath

        @Deprecated
        public static java.lang.String getContextPath​(javax.servlet.http.HttpServletRequest request)
        Deprecated.
      • isUIRequest

        public static boolean isUIRequest​(javax.servlet.http.HttpServletRequest request)

        Checks whether request is done on the UI endpoint

        Parameters:
        request - Request
      • isAPIRequest

        public static boolean isAPIRequest​(javax.servlet.http.HttpServletRequest request)

        Checks whether request is done on the API endpoint

        Parameters:
        request - Request
      • isIORequest

        public static boolean isIORequest​(javax.servlet.http.HttpServletRequest request)

        Checks whether request is done on the I/O endpoint

        Parameters:
        request - Request
      • isGitRequest

        public static boolean isGitRequest​(javax.servlet.http.HttpServletRequest request)

        Checks whether request is done on the Git endpoint

        Parameters:
        request - Request
      • getBaseRequestURL

        public static java.lang.String getBaseRequestURL​(javax.servlet.http.HttpServletRequest request)

        Return base request URL

        Parameters:
        request - Request
        Returns:
        Base request URL
      • getFullRequestURL

        public static java.lang.String getFullRequestURL​(javax.servlet.http.HttpServletRequest request)

        Return full request URL including GET parameters

        Parameters:
        request - Request
        Returns:
        Full request URL
      • getServerURL

        public static java.lang.String getServerURL​(javax.servlet.http.HttpServletRequest request)

        Get server URL for HTTP request

        Parameters:
        request - HTTP request
      • getContextURL

        public static java.lang.String getContextURL​(javax.servlet.http.HttpServletRequest request)

        Get context URL for HTTP request

        Parameters:
        request - HTTP request
      • getContentType

        public static java.lang.String getContentType​(javax.servlet.http.HttpServletRequest request)

        Get content type (without charset)

        Parameters:
        request - HTTP request
      • getCharset

        public static java.lang.String getCharset​(javax.servlet.http.HttpServletRequest request)

        Get content charset

        Parameters:
        request - HTTP request
      • setHTTPExportMimeType

        public static void setHTTPExportMimeType​(javax.servlet.http.HttpServletResponse response,
                                                 java.lang.String media,
                                                 java.lang.String fileName)

        Generates particular HTTP mime type headers for content exports

        Parameters:
        response - HTTP response
        media - One of MEDIA_* constant
        fileName - Output file name (if no extension is in file name then media-related extension is appended)
      • isSOAP

        public static boolean isSOAP​(javax.servlet.http.HttpServletRequest request)
        Checks if request is from a SOAP call (checking the presence of the SOAPAction header).
        Parameters:
        request - HTTP request
      • isAjax

        public static boolean isAjax​(javax.servlet.http.HttpServletRequest request)
        Checks if request is from an Ajax call (checking the non normative X-Requested-With header).
        Parameters:
        request - HTTP request
      • getUserAgent

        public static java.lang.String getUserAgent​(javax.servlet.http.HttpServletRequest request)
        Get UserAgent
        Parameters:
        request - HTTP request
      • isBrowser

        public static boolean isBrowser​(javax.servlet.http.HttpServletRequest request,
                                        java.lang.String browser)
        Checks if user agent is specified browser.
        Parameters:
        request - HTTP request
        browser - Browser's pattern in user agent (user BROWSER_* constants)
      • isIE

        public static boolean isIE​(javax.servlet.http.HttpServletRequest request)
        Checks if user agent is Internet Explorer.
        Parameters:
        request - HTTP request
      • isFirefox

        public static boolean isFirefox​(javax.servlet.http.HttpServletRequest request)
        Checks if user agent is Firefox.
        Parameters:
        request - HTTP request
      • isChrome

        public static boolean isChrome​(javax.servlet.http.HttpServletRequest request)
        Checks if user agent is Chrome.
        Parameters:
        request - HTTP request
      • isOpera

        public static boolean isOpera​(javax.servlet.http.HttpServletRequest request)
        Checks if user agent is Opera.
        Parameters:
        request - HTTP request
      • isSafari

        public static boolean isSafari​(javax.servlet.http.HttpServletRequest request)
        Checks if user agent is Safari.
        Parameters:
        request - HTTP request
      • getIEVersion

        public static int getIEVersion​(javax.servlet.http.HttpServletRequest request)
        Get Internet Explorer major version number (returns -1 if other browser)
        Parameters:
        request - HTTP request
      • isIEMaxVersion

        public static boolean isIEMaxVersion​(javax.servlet.http.HttpServletRequest request,
                                             int maxVersion)
        Check if browser is Internet Explorer with specified major version number or less
        Parameters:
        request - HTTP request
        maxVersion - Maximum version to check if browser version is less or equals to it
      • isMobileWebkit

        public static boolean isMobileWebkit​(javax.servlet.http.HttpServletRequest request)
        Checks if user agent is a iPhone/iPad/iPod/Android Safari browser.
        Parameters:
        request - HTTP request
      • isMobileBrowser

        public static boolean isMobileBrowser​(javax.servlet.http.HttpServletRequest request)
        Checks if user agent is a mobile browser.
        Parameters:
        request - HTTP request
      • getParamValue

        public static java.lang.String getParamValue​(javax.servlet.http.HttpServletRequest request,
                                                     java.lang.String name)

        Gets single string value from HTTP parameter

        Parameters:
        request - HTTP request
        name - Parameter name
        Returns:
        Parameter value as string (if parameter is not present an empty string ("") is returned)
      • getParamValue

        public static java.lang.String getParamValue​(javax.servlet.http.HttpServletRequest request,
                                                     java.lang.String name,
                                                     java.lang.String def)

        Gets single string value from HTTP parameter

        Parameters:
        request - HTTP request
        name - Parameter name
        def - Default value
        Returns:
        Parameter value as string (if parameter is not present default value or, if default value is null, an empty string ("") is returned)
      • getBooleanParamValue

        public static boolean getBooleanParamValue​(javax.servlet.http.HttpServletRequest request,
                                                   java.lang.String name)

        Gets single boolean value from HTTP parameter

        Parameters:
        request - HTTP request
        name - Parameter name
        Returns:
        Parameter value as boolean (if parameter is not present false is returned)
      • getIntParamValue

        public static int getIntParamValue​(javax.servlet.http.HttpServletRequest request,
                                           java.lang.String name)

        Gets single integer value from HTTP parameter

        Parameters:
        request - HTTP request
        name - Parameter name
        Returns:
        Parameter value as integer (if parameter is not present 0 is returned)
      • getLongParamValue

        public static long getLongParamValue​(javax.servlet.http.HttpServletRequest request,
                                             java.lang.String name)

        Gets single long value from HTTP parameter

        Parameters:
        request - HTTP request
        name - Parameter name
        Returns:
        Parameter value as long (if parameter is not present 0 is returned)
      • getFloatParamValue

        public static float getFloatParamValue​(javax.servlet.http.HttpServletRequest request,
                                               java.lang.String name)

        Gets single float value from HTTP parameter

        Parameters:
        request - HTTP request
        name - Parameter name
        Returns:
        Parameter value as float (if parameter is not present 0 is returned)
      • getDoubleParamValue

        public static double getDoubleParamValue​(javax.servlet.http.HttpServletRequest request,
                                                 java.lang.String name)

        Gets single double value from HTTP parameter

        Parameters:
        request - HTTP request
        name - Parameter name
        Returns:
        Parameter value as double (if parameter is not present 0 is returned)
      • getParamValues

        public static java.lang.String[] getParamValues​(javax.servlet.http.HttpServletRequest request,
                                                        java.lang.String name)

        Gets multiple string values HTTP parameter

        Parameters:
        request - HTTP request
        name - Parameter name
        Returns:
        Parameter values as string array (if parameter is absent empty array (String[0]) is returned)
      • getRequestBody

        public static java.lang.String getRequestBody​(javax.servlet.http.HttpServletRequest request)
                                               throws java.lang.Exception

        Reads request body from HTTP request

        Parameters:
        request - HTTP request
        Throws:
        java.lang.Exception
      • getRequestBodyAsByteArray

        public static byte[] getRequestBodyAsByteArray​(javax.servlet.http.HttpServletRequest request)
                                                throws java.lang.Exception

        Reads request body as byte array from HTTP request

        Parameters:
        request - HTTP request
        Throws:
        java.lang.Exception
      • getCookieValue

        public static java.lang.String getCookieValue​(javax.servlet.http.HttpServletRequest request,
                                                      java.lang.String name)
        Get a cookie value from request
      • getMobileFromRequest

        public static java.lang.String getMobileFromRequest​(javax.servlet.http.HttpServletRequest request)
        Get mobile parameter from request
        Parameters:
        request - Request
        Returns:
        Mobile
      • getScopeFromRequest

        public static java.lang.String getScopeFromRequest​(javax.servlet.http.HttpServletRequest request)
        Get scope parameter from request
        Parameters:
        request - Request
        Returns:
        Scope
      • getDeepLinkFromRequest

        public static java.lang.String getDeepLinkFromRequest​(javax.servlet.http.HttpServletRequest request)
        Get deep link parameter from request
        Parameters:
        request - Request
        Returns:
        Deep link
      • debugHTTPRequest

        public static java.lang.String debugHTTPRequest​(javax.servlet.http.HttpServletRequest request)
        Displays HTTP request information (request items, parameters and cookies) for debug purposes
        Parameters:
        request - HTTP request
        Returns:
        HTTP debug dump
      • debugHTTPRequest

        public static java.lang.String debugHTTPRequest​(javax.servlet.http.HttpServletRequest request,
                                                        boolean parameters)
        Displays HTTP request information (request items, parameters and cookies) for debug purposes
        Parameters:
        request - HTTP request
        parameters - Include request parameters ?
        Returns:
        HTTP debug dump
      • debugHTTPRequest

        public static java.lang.String debugHTTPRequest​(javax.servlet.http.HttpServletRequest request,
                                                        boolean parameters,
                                                        boolean attributes)
        Displays HTTP request information (request items, parameters and cookies) for debug purposes
        Parameters:
        request - HTTP request
        parameters - Include request parameters ?
        attributes - Include session attributes parameters ?
        Returns:
        HTTP debug dump
      • getCookie

        public static java.lang.String getCookie​(javax.servlet.http.HttpServletRequest request,
                                                 java.lang.String name)

        Gets cookie value (or null if cookie is not defined)

        Parameters:
        request - HTTP request
        name - Cookie name
        Returns:
        Cookie value
      • setCookie

        public static void setCookie​(javax.servlet.http.HttpServletResponse response,
                                     java.lang.String path,
                                     java.lang.String name,
                                     java.lang.String value)

        Sets cookie with 1 year max age

        Parameters:
        response - HTTP response
        path - Optional cookie path
        name - Cookie name
        value - Cookie value
      • setCookie

        public static void setCookie​(javax.servlet.http.HttpServletResponse response,
                                     java.lang.String path,
                                     java.lang.String name,
                                     java.lang.String value,
                                     int maxAge)

        Sets cookie

        Parameters:
        response - HTTP response
        path - Optional cookie path
        name - Cookie name
        value - Cookie value
        maxAge - Max age of cookie (seconds)
      • setCookie

        public static void setCookie​(javax.servlet.http.HttpServletResponse response,
                                     java.lang.String domain,
                                     java.lang.String path,
                                     java.lang.String name,
                                     java.lang.String value,
                                     int maxAge)

        Sets cookie

        Parameters:
        response - HTTP response
        domain - Optional cookie domain
        path - Optional cookie path
        name - Cookie name
        value - Cookie value
        maxAge - Max age of cookie (seconds)
      • removeCookie

        public static void removeCookie​(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        java.lang.String name)

        Remove a cookie

        Parameters:
        request - HTTP request
        response - HTTP response
        name - Cookie name
      • removeCookie

        public static void removeCookie​(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        java.lang.String domain,
                                        java.lang.String path,
                                        java.lang.String name)

        Remove a cookie

        Parameters:
        request - HTTP request
        response - HTTP response
        name - Cookie name
      • getClientId

        public static java.lang.String getClientId​(javax.servlet.http.HttpServletRequest request,
                                                   javax.servlet.http.HttpServletResponse response)
        Set and get unique client ID and store it as a cookie
        Parameters:
        request - HTTP request
        response - HTTP response
      • setObjectFiltersFromRequest

        public static void setObjectFiltersFromRequest​(ObjectDB obj,
                                                       ServletParameters params)

        Sets object field filters from HTTP parameters

        Parameters:
        obj - Object
        params - HTTP parameters
      • setObjectFiltersFromRequest

        public static void setObjectFiltersFromRequest​(ObjectDB obj,
                                                       ServletParameters params,
                                                       java.lang.String dotReplacement)

        Sets object field filters from HTTP parameters

        Parameters:
        obj - Object
        params - HTTP parameters
        dotReplacement - "." replacement in field HTTP parameter name (e.g. Globals.DOT_REPLACEMENT)
      • getRowIdFromRequest

        public static java.lang.String getRowIdFromRequest​(ObjectDB obj,
                                                           javax.servlet.http.HttpServletRequest request)

        Get object row ID field values from HTTP request (using actual object row ID name or, if not found, default row ID name)

        Parameters:
        obj - Object (can be null, then look for actual object row ID name is - obviously - skipped)
        request - HTTP request
      • getRowIdFromParameters

        public static java.lang.String getRowIdFromParameters​(ObjectDB obj,
                                                              Parameters params)

        Get object row ID field values from parameters (using actual object row ID name or, if not found, default row ID name)

        Parameters:
        obj - Object (can be null, then look for actual object row ID name is - obviously - skipped)
        params - Parameters
      • selectObjectContext

        public static void selectObjectContext​(ObjectDB obj,
                                               java.lang.String rowId,
                                               int context,
                                               Parameters.ParamContext params)
                                        throws GetException

        Select the record and apply the context on different rowId

        Parameters:
        obj - Object
        rowId - Object row ID
        context - Context to apply if the current object is not this rowId (ex: stateless usage)
        params - optional parent context
        Throws:
        GetException
      • setObjectFieldsFromParameters

        public static void setObjectFieldsFromParameters​(ObjectDB obj,
                                                         Parameters params,
                                                         java.lang.String dotReplacement)

        Sets object field values from parameters

        Parameters:
        obj - Object
        params - HTTP request
        dotReplacement - "." replacement in field HTTP parameter name (e.g. Globals.DOT_REPLACEMENT)
      • setObjectFields

        public static void setObjectFields​(ObjectDB obj,
                                           Parameters params,
                                           int context,
                                           java.lang.String dotReplacement,
                                           boolean checkUpdatable)
      • getLoginFromRequest

        public static java.lang.String getLoginFromRequest​(javax.servlet.http.HttpServletRequest request,
                                                           boolean force)
        Retrieve current user login from HTTP request (defaults to public user login)
        Parameters:
        request - HTTP request
        force - Force login search and parse
        Returns:
        User login
      • jspInclude

        public static java.lang.String jspInclude​(java.lang.String url)
        JSP include statement in dynamic content (to be processed from including JSP by the processContent() method)
        Parameters:
        url - JSP relative URL
      • processContent

        public static void processContent​(java.lang.String content,
                                          java.io.Writer out,
                                          javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response)
                                   throws java.lang.Exception
        Process dynamic content with JSP includes substitution if any (added using the jspInclude() method)
        Parameters:
        content - Dynamic content to process
        out - Output writer
        request - Request
        response - Response
        Throws:
        java.lang.Exception
      • getTokenData

        public static org.json.JSONObject getTokenData​(javax.servlet.http.HttpServletRequest request,
                                                       javax.servlet.http.HttpServletResponse response)
        Get token data from request ad response
        Parameters:
        request - Request
        response - Response
        Returns:
        JSON
      • getGrant

        public static Grant getGrant​(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response)
                              throws java.lang.Exception
        Gets the UI grant from request (creates it if not found and loads it if not loaded)
        Parameters:
        request - Request
        response - Response
        Throws:
        java.lang.Exception
      • getGrant

        public static Grant getGrant​(javax.servlet.http.HttpSession session)
        Gets the UI grant from request (it is supposed to be existing in this case, otherwise getGrant(request) must be used instead))
        Parameters:
        session - Session
      • getPublicGrant

        public static Grant getPublicGrant​(javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response)
        Gets the UI public grant from request (creates it if not found and loads it if not loaded)
        Parameters:
        request - Request
        response - Response
      • getPublicGrant

        public static Grant getPublicGrant​(javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response,
                                           boolean create)
        Gets the UI public grant from request (creates it if not found and loads it if not loaded)
        Parameters:
        request - Request
        response - Response
        create - Creates and loads it if not found
      • getPublicGrant

        public static Grant getPublicGrant​(javax.servlet.http.HttpSession session)
        Gets the UI public grant from request (it is supposed to be existing in this case, otherwise getGrant(request) must be used instead))
        Parameters:
        session - Session
      • getTreeview

        public static com.simplicite.webapp.ObjectTreeview getTreeview​(javax.servlet.http.HttpServletRequest request,
                                                                       javax.servlet.http.HttpServletResponse response)
                                                                throws java.lang.Exception
        Gets the UI tree view manager
        Parameters:
        request - Request
        response - Response
        Throws:
        java.lang.Exception
      • hasPage

        public static boolean hasPage​(javax.servlet.http.HttpServletRequest request)
        Check if the UI page is present and initialized
        Parameters:
        request - Request
      • getPage

        public static HTMLPage getPage​(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response)
                                throws java.lang.Exception
        Gets the UI page from request (creates and initializes it if not found)
        Parameters:
        request - Request
        Throws:
        java.lang.Exception
      • getPage

        public static HTMLPage getPage​(javax.servlet.http.HttpSession session)
        Gets the UI page from session (it is supposed to be existing in this case, otherwise getPage(request) must be used instead))
        Parameters:
        session - Session
      • hasPublicPage

        public static boolean hasPublicPage​(javax.servlet.http.HttpServletRequest request)
        Check if the UI public page is present and initialized
        Parameters:
        request - Request
      • getPublicPage

        public static HTMLPage getPublicPage​(javax.servlet.http.HttpServletRequest request,
                                             javax.servlet.http.HttpServletResponse response)
        Gets the UI public page from request (creates and initializes it if not found)
        Parameters:
        request - Request
        response - Response
      • getPublicPage

        public static HTMLPage getPublicPage​(javax.servlet.http.HttpServletRequest request,
                                             javax.servlet.http.HttpServletResponse response,
                                             boolean load)
        Gets the UI public page from request (creates and initializes it if not found)
        Parameters:
        request - Request
        response - Response
        load - Load if needed ?
      • getPublicPage

        public static HTMLPage getPublicPage​(javax.servlet.http.HttpSession session)
        Gets the UI public page from session (it is supposed to be existing in this case, otherwise gePublictPage(request) must be used instead))
        Parameters:
        session - Session
      • badRequest

        public static void badRequest​(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response,
                                      java.lang.Object data)
        Bad request response (HTTP code 400)
        Parameters:
        request - Request
        response - Response
        data - Optional data
      • unauthorized

        public static void unauthorized​(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        java.lang.Object data,
                                        boolean requestAuthentication)
        Unauthorized response (HTTP code 401)
        Parameters:
        request - Request
        response - Response
        data - Optional data
        requestAuthentication - Ask browser to request authentication (by adding a WWW-Authenticate header to the response)
      • forbidden

        public static void forbidden​(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response,
                                     java.lang.Object data)
        Forbidden response (HTTP code 403)
        Parameters:
        request - Request
        response - Response
        data - Optional data
      • notFound

        public static void notFound​(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response,
                                    java.lang.Object data)
        Not found response (HTTP code 404)
        Parameters:
        request - Request
        response - Response
        data - Optional data
      • internalServerError

        public static void internalServerError​(javax.servlet.http.HttpServletRequest request,
                                               javax.servlet.http.HttpServletResponse response,
                                               java.lang.Object data)
        Internal server error response (HTTP code 500)
        Parameters:
        request - Request
        response - Response
        data - Optional data
      • redirect

        public static void redirect​(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response,
                                    java.lang.String url)
        Send an HTTP redirect
        Parameters:
        request - Request
        response - Response
        url - URL to redirect to
      • redirect

        public static void redirect​(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response,
                                    java.lang.String url,
                                    int type)
        Send a redirect
        Parameters:
        request - Request
        response - Response
        url - URL to redirect to
        type - Redirect type (one of REDIRECT_TYPE_* constants)
      • javascript

        public static void javascript​(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response,
                                      java.lang.String script,
                                      java.lang.String title,
                                      java.lang.String icon,
                                      java.lang.String help,
                                      java.lang.String html,
                                      java.lang.String[] css,
                                      java.lang.String[] js,
                                      org.json.JSONObject metadata)
        Send a JavaScript statement with optional elements (for use in the responsive UI)
        Parameters:
        request - Request
        response - Response
        script - JavaScript statement
        title - optional title
        help - optional help
        html - optional HTML
        css - optional CSS URLs
        js - optional Javascript URLs
        metadata - optional meta data
      • send

        public static final void send​(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response,
                                      java.lang.String mime,
                                      java.lang.Object data)
        Send response
        Parameters:
        request - Request
        response - Response
        mime - MIME type
        data - Data
      • send

        public static void send​(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                java.lang.String mime,
                                java.lang.Object data,
                                int status)
        Send response
        Parameters:
        request - Request
        response - Response
        mime - MIME type
        data - Data
        status - HTTP status
      • send

        public static void send​(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                java.lang.String mime,
                                java.lang.Object data,
                                int status,
                                java.util.Map<java.lang.String,​java.lang.String> headers)
        Send response
        Parameters:
        request - Request
        response - Response
        mime - MIME type
        data - Data
        status - HTTP status
        headers - Additional HTTP headers
      • addHeaders

        public static void addHeaders​(javax.servlet.http.HttpServletResponse response,
                                      java.util.Map<java.lang.String,​java.lang.String> headers)
        Add HTTP headers to reponse
        Parameters:
        response - Response
        headers - Headers
      • getBasicAuthLoginPassword

        public static java.util.Map<java.lang.String,​java.lang.Object> getBasicAuthLoginPassword​(javax.servlet.http.HttpServletRequest request,
                                                                                                       java.lang.String header)
                                                                                                throws java.lang.Exception
        Return user and password from a HTTP basic authentication header (base64 encoded).
        Parameters:
        request - Request
        header - Header (defaults to "Authorization")
        Throws:
        java.lang.Exception
      • getAPIAuthToken

        public static java.lang.String getAPIAuthToken​(javax.servlet.http.HttpServletRequest request)
        Get auth token in the API endpoint context
        Parameters:
        request - Request
      • getAPIGrant

        public static Grant getAPIGrant​(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response)
                                 throws GrantException
        Gets an API grant from request (creates it if not found in session and loads it if not loaded). NB: This is only used by the services API endpoint (/api/*), not by the other webservices endpoints (internal UI, public UI and webservices gateway)
        Parameters:
        request - Request
        response - Request
        Throws:
        GrantException
      • getIOGrant

        public static Grant getIOGrant​(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response)
                                throws GrantException
        Gets an IO grant from request (creates it if not found in session and loads it if not loaded). NB: This is only used by the I/O and Git endpoints (/io/*, /git/*), not by the other endpoints (internal UI, public UI and API endpoint)
        Parameters:
        request - Request
        response - Request
        Throws:
        GrantException
      • getWebServicesFactory

        public static WebServicesFactory getWebServicesFactory​(Grant g,
                                                               javax.servlet.http.HttpServletRequest request,
                                                               int endpoint)
        Gets a web services factory from request (creates it if not found)
        Parameters:
        g - Grant
        request - Request
        endpoint - Endpoint
      • writeStream

        public static int writeStream​(java.io.InputStream in,
                                      java.lang.String name,
                                      java.lang.String contentType,
                                      java.lang.String contentDisposition,
                                      int maxAge,
                                      javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response)
                               throws java.lang.Exception
        Stream data as response
        Parameters:
        in - Data input stream
        name - Name
        contentType - Content type
        contentDisposition - Content disposition
        maxAge - Max age
        request - Request
        response - Response
        Throws:
        java.lang.Exception
      • reset

        public static void reset​(javax.servlet.http.HttpServletResponse response,
                                 boolean all)
        Reset the response buffer
        Parameters:
        response - HTTP response
        all - true to clear also the headers and the response status