public abstract class

NetworkRequest

extends Object
implements EnumUsherRequest
java.lang.Object
   ↳ com.microstrategy.web.app.utils.usher.NetworkRequest
Known Direct Subclasses

Class Overview

Generic network request. It allows a subclass to add parameters in the url and read the response.

Summary

Constants
String FORMAT_JSON
String FORMAT_XML
String HTTP_USHER_HEADER_ERROR
[Expand]
Inherited Constants
From interface com.microstrategy.web.app.utils.usher.EnumUsherRequest
Fields
protected boolean isPost
protected String jsonDataParam
protected Map<String, String> requestParams
protected Map<String, String> requestProps
protected Map<String, List<String>> responseHeaderFields
Public Constructors
NetworkRequest(String baseURLIn, int whichHandle, boolean isPost)
NetworkRequest(String baseURL, String extraPath, int whichHandle, boolean isPost)
Public Methods
String executeStringContentType()
@return
static String getCookieFromResponseHeader(Map<String, List<String>> headers, String cookieName)
static String getErrorDetails(HttpURLConnection urlConn)
In case of error gets error details
String getResponseFromRequest()
static void handleErrorCodes(int responseCode, String errorDetails)
Throws the appropriate Usher Error code depending on type of error
static String makePath(String url, String params)
Helper function to generate new URL by connecting a path with a given URL.
void setResponseFromRequest(String responseFromRequest)
Protected Methods
void addBody(OutputStream out)
void addJsonDataParam()
abstract void addRequestParameters()
abstract void addRequestProperties()
URL buildURL(Map<String, String> params, boolean isPost, boolean sanitize)
builds up the query to be executed with any additional parameters specified by the child request@return
String getJsonStringIfExists(JSONObject json, String key)
abstract void handleResponse(String result)
abstract void handleResponse(InputStream imageStream, String contentType, Map<String, List<String>> headers)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String FORMAT_JSON

Constant Value: "json"

public static final String FORMAT_XML

Constant Value: "xml"

public static final String HTTP_USHER_HEADER_ERROR

Constant Value: "X-FW-Exception"

Fields

protected boolean isPost

protected String jsonDataParam

protected Map<String, String> requestParams

protected Map<String, String> requestProps

protected Map<String, List<String>> responseHeaderFields

Public Constructors

public NetworkRequest (String baseURLIn, int whichHandle, boolean isPost)

public NetworkRequest (String baseURL, String extraPath, int whichHandle, boolean isPost)

Public Methods

public String executeStringContentType ()

public static String getCookieFromResponseHeader (Map<String, List<String>> headers, String cookieName)

public static String getErrorDetails (HttpURLConnection urlConn)

In case of error gets error details

Returns
  • StringBuilder with error details

public String getResponseFromRequest ()

public static void handleErrorCodes (int responseCode, String errorDetails)

Throws the appropriate Usher Error code depending on type of error

public static String makePath (String url, 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

public void setResponseFromRequest (String responseFromRequest)

Protected Methods

protected void addBody (OutputStream out)

Throws
TaskException

protected void addJsonDataParam ()

Throws
TaskException

protected abstract void addRequestParameters ()

Throws
TaskException

protected abstract void addRequestProperties ()

Throws
TaskException

protected URL buildURL (Map<String, String> params, boolean isPost, boolean sanitize)

builds up the query to be executed with any additional parameters specified by the child request@return

Throws
UnsupportedEncodingException
MalformedURLException
UnsupportedEncodingException

protected String getJsonStringIfExists (JSONObject json, String key)

protected abstract void handleResponse (String result)

Throws
TaskException

protected abstract void handleResponse (InputStream imageStream, String contentType, Map<String, List<String>> headers)

Throws
TaskException