Class NetworkRequest

    • Field Detail

      • HTTP_USHER_HEADER_ERROR

        public static final java.lang.String HTTP_USHER_HEADER_ERROR
        See Also:
        Constant Field Values
      • requestParams

        protected java.util.Map<java.lang.String,​java.lang.String> requestParams
      • jsonDataParam

        protected java.lang.String jsonDataParam
      • requestProps

        protected java.util.Map<java.lang.String,​java.lang.String> requestProps
      • responseHeaderFields

        protected java.util.Map<java.lang.String,​java.util.List<java.lang.String>> responseHeaderFields
      • isPost

        protected boolean isPost
    • Constructor Detail

      • NetworkRequest

        public NetworkRequest​(java.lang.String baseURLIn,
                              int whichHandle,
                              boolean isPost)
      • NetworkRequest

        public NetworkRequest​(java.lang.String baseURL,
                              java.lang.String extraPath,
                              int whichHandle,
                              boolean isPost)
    • Method Detail

      • handleResponse

        protected abstract void handleResponse​(java.io.InputStream imageStream,
                                               java.lang.String contentType,
                                               java.util.Map<java.lang.String,​java.util.List<java.lang.String>> headers)
                                        throws TaskException
        Throws:
        TaskException
      • getJsonStringIfExists

        protected java.lang.String getJsonStringIfExists​(JSONObject json,
                                                         java.lang.String key)
        Parameters:
        json -
        key -
        Returns:
      • handleErrorCodes

        public static void handleErrorCodes​(int responseCode,
                                            java.lang.String errorDetails)
                                     throws TaskInternalException
        Throws the appropriate Usher Error code depending on type of error
        Parameters:
        responseCode -
        response -
        Throws:
        TaskInternalException
      • buildURL

        protected java.net.URL buildURL​(java.util.Map<java.lang.String,​java.lang.String> params,
                                        boolean isPost,
                                        boolean sanitize)
                                 throws java.io.UnsupportedEncodingException,
                                        java.net.MalformedURLException
        builds up the query to be executed with any additional parameters specified by the child request
        Parameters:
        params -
        Returns:
        Throws:
        java.io.UnsupportedEncodingException
        java.net.MalformedURLException
      • getResponseFromRequest

        public java.lang.String getResponseFromRequest()
      • setResponseFromRequest

        public void setResponseFromRequest​(java.lang.String responseFromRequest)
      • getCookieFromResponseHeader

        public static java.lang.String getCookieFromResponseHeader​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> headers,
                                                                   java.lang.String cookieName)
      • getErrorDetails

        public static java.lang.String getErrorDetails​(java.net.HttpURLConnection urlConn)
        In case of error gets error details
        Parameters:
        urlConn -
        Returns:
        StringBuilder with error details
      • makePath

        public static java.lang.String makePath​(java.lang.String url,
                                                java.lang.String params)
        Helper function to generate new URL by connecting a path with a given URL. If the given URL does not have "/" at the then, it will append "/" at the end of the URL.
        Parameters:
        url - The URL link string
        params - The second part of the link
        Returns:
        A full URL constructed with given url and the second part path