com.plumtree.portaluiinfrastructure.restconsumerframework
Class RestRequest

java.lang.Object
  extended by com.plumtree.portaluiinfrastructure.restconsumerframework.RestRequest

public class RestRequest
extends java.lang.Object

Helper class to perform REST API Requests

Author:
rozhang

Field Summary
protected static java.lang.String ACCEPT_LANGUAGE
           
static int AUTHENTICATION_METHOD_BASICAUTH
           
static int AUTHENTICATION_METHOD_CSPLOGINTOKEN
           
static int AUTHENTICATION_METHOD_HEADERTOKEN
           
static int AUTHENTICATION_METHOD_NONE
           
protected static java.lang.String BASICAUTH_PASSWORD
           
protected static java.lang.String BASICAUTH_USERNAME
           
protected static java.lang.String CSPLOGINTOKEN_NAME
           
protected static java.lang.String CSPLOGINTOKEN_VALUE
           
protected static java.lang.String HEADERTOKEN_NAME
           
protected static java.lang.String HEADERTOKEN_VALUE
           
protected  XPHashtable m_authData
          Container to store authentication data
protected  int m_authMethod
          Authentication method
protected  java.lang.String m_contentType
          Content-Type header value
protected  int m_msTimeout
           
protected  byte[] m_postBody
          Request Post body
protected  java.lang.String m_reqMethod
          HTTP Request method
protected  IOKUrl m_url
          HTTP Request url
 
Constructor Summary
protected RestRequest()
          Used by MockRestRequest
 
Method Summary
 java.lang.String GetContentTypeHeader()
          Returns the Content-Type header value being set on this request.
static RestRequest GetInstance(java.lang.String url, IOKHttpService service, IOKHttpSession session)
          Gets an instance of a RestRequest object
 java.lang.String getRequestMethod()
          Getter
 IOKUrl getRequestUrl()
          Getter
protected  void SetAuthenticationOnRequest(IOKHttpRequest req)
          Applies the authentication on the request Extend this method to add additional authentication methods
 void SetContentTypeHeader(java.lang.String contentType)
          This method can be used to set Content-Type header on the rest request.
 void SetCSPLoginToken(java.lang.String tokenValue)
          Set a WCI issued login token recognized by portlets
 void SetHttpAuthentication(java.lang.String userName, java.lang.String password)
          Sets basic http authentication name and passsword
 void SetPostBody(java.lang.String bodyContent)
           
 void SetRequestHeaderTokenAuthentication(java.lang.String tokenName, java.lang.String tokenValue)
          Sets a generic request header name value pair
 void SetRequestMethod(java.lang.String method)
          Setter
 IRestResponse Submit()
          Submits the Rest request
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTHENTICATION_METHOD_NONE

public static final int AUTHENTICATION_METHOD_NONE
See Also:
Constant Field Values

AUTHENTICATION_METHOD_BASICAUTH

public static final int AUTHENTICATION_METHOD_BASICAUTH
See Also:
Constant Field Values

AUTHENTICATION_METHOD_HEADERTOKEN

public static final int AUTHENTICATION_METHOD_HEADERTOKEN
See Also:
Constant Field Values

AUTHENTICATION_METHOD_CSPLOGINTOKEN

public static final int AUTHENTICATION_METHOD_CSPLOGINTOKEN
See Also:
Constant Field Values

BASICAUTH_USERNAME

protected static final java.lang.String BASICAUTH_USERNAME
See Also:
Constant Field Values

BASICAUTH_PASSWORD

protected static final java.lang.String BASICAUTH_PASSWORD
See Also:
Constant Field Values

HEADERTOKEN_NAME

protected static final java.lang.String HEADERTOKEN_NAME
See Also:
Constant Field Values

HEADERTOKEN_VALUE

protected static final java.lang.String HEADERTOKEN_VALUE
See Also:
Constant Field Values

CSPLOGINTOKEN_VALUE

protected static final java.lang.String CSPLOGINTOKEN_VALUE
See Also:
Constant Field Values

CSPLOGINTOKEN_NAME

protected static final java.lang.String CSPLOGINTOKEN_NAME
See Also:
Constant Field Values

ACCEPT_LANGUAGE

protected static final java.lang.String ACCEPT_LANGUAGE
See Also:
Constant Field Values

m_reqMethod

protected java.lang.String m_reqMethod
HTTP Request method


m_url

protected IOKUrl m_url
HTTP Request url


m_authMethod

protected int m_authMethod
Authentication method


m_authData

protected XPHashtable m_authData
Container to store authentication data


m_msTimeout

protected int m_msTimeout

m_postBody

protected byte[] m_postBody
Request Post body


m_contentType

protected java.lang.String m_contentType
Content-Type header value

Constructor Detail

RestRequest

protected RestRequest()
Used by MockRestRequest

Method Detail

GetInstance

public static RestRequest GetInstance(java.lang.String url,
                                      IOKHttpService service,
                                      IOKHttpSession session)
Gets an instance of a RestRequest object

Parameters:
url - Url to the Rest endpoint
service - Same service object should be used for all requests. Available from OpenHTTPServiceHelper
session - Same session object should be used for all requests. Available from OpenHTTPServiceHelper

Submit

public IRestResponse Submit()
Submits the Rest request

Returns:

SetAuthenticationOnRequest

protected void SetAuthenticationOnRequest(IOKHttpRequest req)
Applies the authentication on the request Extend this method to add additional authentication methods

Parameters:
req -

SetHttpAuthentication

public void SetHttpAuthentication(java.lang.String userName,
                                  java.lang.String password)
Sets basic http authentication name and passsword

Parameters:
userName -
password -

SetRequestHeaderTokenAuthentication

public void SetRequestHeaderTokenAuthentication(java.lang.String tokenName,
                                                java.lang.String tokenValue)
Sets a generic request header name value pair

Parameters:
tokenName -
tokenValue -

SetCSPLoginToken

public void SetCSPLoginToken(java.lang.String tokenValue)
Set a WCI issued login token recognized by portlets

Parameters:
tokenValue -

SetRequestMethod

public void SetRequestMethod(java.lang.String method)
Setter

Parameters:
method -

SetPostBody

public void SetPostBody(java.lang.String bodyContent)

getRequestMethod

public java.lang.String getRequestMethod()
Getter

Returns:

getRequestUrl

public IOKUrl getRequestUrl()
Getter

Returns:

SetContentTypeHeader

public void SetContentTypeHeader(java.lang.String contentType)
This method can be used to set Content-Type header on the rest request.

Parameters:
contentType -

GetContentTypeHeader

public java.lang.String GetContentTypeHeader()
Returns the Content-Type header value being set on this request.

Returns:



Copyright © 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.