com.plumtree.openfoundation.web
Class XPRequest

java.lang.Object
  extended by com.plumtree.openfoundation.web.XPRequest
All Implemented Interfaces:
IXPRequest

public class XPRequest
extends java.lang.Object
implements IXPRequest

For Servlet 2.3 systems the class will use 2.3 methods and assume UTF-8 character set.
For Servlet 2.2 systems it is more complicated. Servlet 2.2 engines by default will convert the body to Unicode with a default character set (most are hard coded to 8859-1). This creates a problem because in some character sets, it is not possible to get the original bytes back once converted to Unicode. NOTE: Only use XPRequest with UTF-8 incoming character sets.


Field Summary
static java.lang.String HTTPGet
          Plublic Constant for GET Request.
 
Constructor Summary
XPRequest(HttpServletRequest request)
          interface to provide request information for HTTP servlets.
XPRequest(HttpServletRequest request, boolean bConsumeAndParsePostdata)
          Only the gateway should call this constructor and will pass false for bConsumeAndParsePostdata Normally XPRequest constructor calls "ParseRequest()" method to provide the same behaviour on both Java and .NET platforms.
 
Method Summary
 void ClearUnderlyingObject()
          This method clears all the instance variable to avoid memory leak.
 java.lang.Object GetAttribute(java.lang.String name)
          Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
 java.lang.String GetAuthType()
          Returns the name of the authentication scheme used to protect the servlet.
 java.lang.String GetBasicAuthPassword()
          Get the basic authentication password.
 java.lang.String GetBasicAuthUserName()
          Get the basic authentication user name.
 byte[] GetBytes()
          MES- GetBytes allows a client to retrieve the uploaded data as a byte array.
 java.lang.String GetClientAddress()
          Returns the IP address of the client as a String in dotted quad form.
 java.lang.String GetCompletePath()
          This method returns full name of the saved uploaded file.
 int GetContentLength()
          Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.
 java.lang.String GetContentType()
          Returns the MIME type of the body of the request, or null if the type is not known.
 XPCookie[] GetCookies()
          Returns an array containing all of the Cookie objects the client sent with this request.
 java.lang.String GetHeader(java.lang.String name)
          Returns the value of the specified request header as a String.
 IXPEnumerator GetHeaderNames()
          Returns an enumeration of all the header names this request contains.
 XPInputStream GetInputStream()
          Retrieves the body of the request as binary data using a ServletInputStream.
 IXPEnumerator GetLocales()
          Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.
 java.lang.String GetMethod()
          Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
 IXPEnumerator GetParameterNames()
          Returns an Enumeration of String objects containing the names of the parameters contained in this request.
 java.lang.String GetParameterValue(java.lang.String name)
          Returns the value of a request parameter as a String, or null if the parameter does not exist.
 java.lang.String[] GetParameterValues(java.lang.String name)
          Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
 java.lang.String GetQueryString()
          Returns the query string that is contained in the request URL after the path.
 java.lang.String GetRemoteFilePath()
          This method returns full name of the last file in the uploaded file list.
 java.lang.String GetRemoteUser()
          This method returns the authenticated remote user name.
 java.lang.String GetRequestedSessionId()
          Returns the session ID specified by the client.
 java.lang.String GetRequestURI()
          Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
 java.lang.String GetRequestURL()
          Returns the URL the client used to make the request, using information in the HttpServletRequest object.
 java.lang.String GetScheme()
          Returns the name of the scheme used to make this request, for example, http, https, or ftp.
 java.lang.String GetServerName()
          Returns the host name of the server that received the request.
 int GetServerPort()
          Returns the port number on which this request was received.
 java.lang.String GetServerVariable(java.lang.String name)
          Deprecated. This method is deprecated, because it will always behave differently in Java and .NET
 IXPEnumerator GetServerVariableNames()
          Deprecated. This method is deprecated, because it will always behave differently in Java and .NET
 XPSession GetSession()
          Returns the current HttpSession associated with this request wrapped in XPSession, or if the request does not have a session, creates one.
 HttpServletRequest GetUnderlyingObject()
          Returns underlying HttpServletRequest object.
 boolean IsSecureConnection()
          Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
 void ParseRequest()
          This method is a helper method to parse the request body.
 void Save(java.lang.String _sFilePath)
          This method only saves the last file in the uploaded files list.
 void SetAttribute(java.lang.String name, java.lang.Object _value)
          Stores an attribute in this request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTPGet

public static final java.lang.String HTTPGet
Plublic Constant for GET Request.

See Also:
Constant Field Values
Constructor Detail

XPRequest

public XPRequest(HttpServletRequest request,
                 boolean bConsumeAndParsePostdata)
Only the gateway should call this constructor and will pass false for bConsumeAndParsePostdata Normally XPRequest constructor calls "ParseRequest()" method to provide the same behaviour on both Java and .NET platforms. However, calling this method results in failures when trying to read binary body from the InputStream of the request. Since GateWay rely on this functionality we introduced additional argument that specifies whether the client will try to read binary body of the request or not. when bConsumeAndParsePostdata is "false", the behaviour of this constructor is exactly the same as the behaviour of the other one.

Parameters:
request - HttpServletRequest to be wrapped into XPRequest.
bConsumeAndParsePostdata - flag that indicates to consume and parse post data.

XPRequest

public XPRequest(HttpServletRequest request)
interface to provide request information for HTTP servlets.

Parameters:
request - HttpServletRequest to be wrapped into XPRequest.
Method Detail

GetBasicAuthPassword

public java.lang.String GetBasicAuthPassword()
Get the basic authentication password.

Specified by:
GetBasicAuthPassword in interface IXPRequest
Returns:
password value.

GetBasicAuthUserName

public java.lang.String GetBasicAuthUserName()
Get the basic authentication user name.

Specified by:
GetBasicAuthUserName in interface IXPRequest
Returns:
user name.

GetRemoteUser

public java.lang.String GetRemoteUser()
This method returns the authenticated remote user name.

Specified by:
GetRemoteUser in interface IXPRequest
Returns:
Remote User Name.

GetBytes

public byte[] GetBytes()
MES- GetBytes allows a client to retrieve the uploaded data as a byte array.

Specified by:
GetBytes in interface IXPRequest
Returns:
The byte[] data that was uploaded, or null if nothing was uploaded.

GetCompletePath

public java.lang.String GetCompletePath()
This method returns full name of the saved uploaded file.

Specified by:
GetCompletePath in interface IXPRequest
Returns:
Complete Path of the file.

GetRemoteFilePath

public java.lang.String GetRemoteFilePath()
This method returns full name of the last file in the uploaded file list.

Specified by:
GetRemoteFilePath in interface IXPRequest
Returns:
returns full path name of the last file on client side.

Save

public void Save(java.lang.String _sFilePath)
This method only saves the last file in the uploaded files list. If the uploaded file already exists, it generates the unique name and allows to save multiple version of the same file.

Specified by:
Save in interface IXPRequest
Parameters:
_sFilePath - Path of the upload file.

GetContentLength

public int GetContentLength()
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.

Specified by:
GetContentLength in interface IXPRequest
Returns:
The length of the request content.

GetContentType

public java.lang.String GetContentType()
Returns the MIME type of the body of the request, or null if the type is not known.

Specified by:
GetContentType in interface IXPRequest
Returns:
MIME type of the body of the request.

GetInputStream

public XPInputStream GetInputStream()
Retrieves the body of the request as binary data using a ServletInputStream.

Specified by:
GetInputStream in interface IXPRequest
Returns:
Result XPInputStream after conversion of request data.

GetCookies

public XPCookie[] GetCookies()
Returns an array containing all of the Cookie objects the client sent with this request.

Specified by:
GetCookies in interface IXPRequest
Returns:
the array of cookies found in this request.

GetHeader

public java.lang.String GetHeader(java.lang.String name)
Returns the value of the specified request header as a String.

Specified by:
GetHeader in interface IXPRequest
Parameters:
name - request header.
Returns:
the value of the requested header field, or null if not known.

GetHeaderNames

public IXPEnumerator GetHeaderNames()
Returns an enumeration of all the header names this request contains.

Specified by:
GetHeaderNames in interface IXPRequest
Returns:
an enumeration of strings representing the header names for this request. Some server implementations do not allow headers to be accessed in this way, in which case this method will return null.

GetLocales

public IXPEnumerator GetLocales()
Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns an Enumeration containing one Locale, the default locale for the server.

Specified by:
GetLocales in interface IXPRequest
Returns:
Returns an Enumeration of Locale objects.

GetMethod

public java.lang.String GetMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.

Specified by:
GetMethod in interface IXPRequest
Returns:
HTTP method of this request.

GetParameterNames

public IXPEnumerator GetParameterNames()
Returns an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Enumeration.

Specified by:
GetParameterNames in interface IXPRequest
Returns:
Enumeration of names of the parameters.

GetParameterValue

public java.lang.String GetParameterValue(java.lang.String name)
Returns the value of a request parameter as a String, or null if the parameter does not exist. This method should only be used when you are sure the parameter has only one value. If the parameter might have more than one value, use GetParameterValues(String). If this method is used with a multivalued parameter, the value returned is equal to the first value in the array returned by GetParameterValues.

Specified by:
GetParameterValue in interface IXPRequest
Parameters:
name - request parameter.
Returns:
Enumeration of values of the parameters.

GetParameterValues

public java.lang.String[] GetParameterValues(java.lang.String name)
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.

Specified by:
GetParameterValues in interface IXPRequest
Parameters:
name - request parameter.
Returns:
Array of Parameter Values.

IsSecureConnection

public boolean IsSecureConnection()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.

Specified by:
IsSecureConnection in interface IXPRequest
Returns:
True if connection is secure else it is false.

GetScheme

public java.lang.String GetScheme()
Returns the name of the scheme used to make this request, for example, http, https, or ftp.

Specified by:
GetScheme in interface IXPRequest
Returns:
String value of the Scheme used in the request.

GetServerName

public java.lang.String GetServerName()
Returns the host name of the server that received the request.

Specified by:
GetServerName in interface IXPRequest
Returns:
Returns the server host name.

GetServerPort

public int GetServerPort()
Returns the port number on which this request was received.

Specified by:
GetServerPort in interface IXPRequest
Returns:
The server's listening port to which request was sent.

GetServerVariable

public java.lang.String GetServerVariable(java.lang.String name)
Deprecated. This method is deprecated, because it will always behave differently in Java and .NET

Returns the value of the named attribute, or null if no attribute of the given name exists.

Specified by:
GetServerVariable in interface IXPRequest
Parameters:
name - named attribute.
Returns:
Returns the value of the named attribute. An empty string will be returned if attribute 'name$apos; does not exist.

GetServerVariableNames

public IXPEnumerator GetServerVariableNames()
Deprecated. This method is deprecated, because it will always behave differently in Java and .NET

Gets a collection of Web server variable names.

Specified by:
GetServerVariableNames in interface IXPRequest
Returns:
Enmerator for the collection of WebServer Variables.

GetQueryString

public java.lang.String GetQueryString()
Returns the query string that is contained in the request URL after the path.

Specified by:
GetQueryString in interface IXPRequest
Returns:
The query String that did the Request.

GetRequestedSessionId

public java.lang.String GetRequestedSessionId()
Returns the session ID specified by the client.

Specified by:
GetRequestedSessionId in interface IXPRequest
Returns:
Returns the Client Session ID.

GetRequestURI

public java.lang.String GetRequestURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.

Specified by:
GetRequestURI in interface IXPRequest
Returns:
Returns the URI part of the request.

GetRequestURL

public java.lang.String GetRequestURL()
Returns the URL the client used to make the request, using information in the HttpServletRequest object.

Specified by:
GetRequestURL in interface IXPRequest
Returns:
Returns the URL part of the request.

GetSession

public XPSession GetSession()
Returns the current HttpSession associated with this request wrapped in XPSession, or if the request does not have a session, creates one.

Specified by:
GetSession in interface IXPRequest
Returns:
Returns the Current Session Object.

GetAuthType

public java.lang.String GetAuthType()
Returns the name of the authentication scheme used to protect the servlet.

Specified by:
GetAuthType in interface IXPRequest
Returns:
The Security Authentication Scheme.

GetAttribute

public java.lang.Object GetAttribute(java.lang.String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Specified by:
GetAttribute in interface IXPRequest
Parameters:
name - Name of the Attribute.
Returns:
The Value Object of the Attribute.

SetAttribute

public void SetAttribute(java.lang.String name,
                         java.lang.Object _value)
Stores an attribute in this request.

Specified by:
SetAttribute in interface IXPRequest
Parameters:
name - Name of the Attribute.
_value - The Value Object of the Attribute.

GetUnderlyingObject

public HttpServletRequest GetUnderlyingObject()
Returns underlying HttpServletRequest object.

Returns:
HttpServletRequest for this given request.

ClearUnderlyingObject

public void ClearUnderlyingObject()
This method clears all the instance variable to avoid memory leak.

Specified by:
ClearUnderlyingObject in interface IXPRequest

ParseRequest

public void ParseRequest()
This method is a helper method to parse the request body. If it is a multipart form, then MultipartParser parses the file and parameter parts. Parameters are added to m_htParameters hashtable. If multiple files are uploaded, this method only preserves the last file in the uploaded list. For this reason, UI should only upload a single file at a time. If it is not a multipart form request, then this method just adds the parameters to m_htParameters.

Specified by:
ParseRequest in interface IXPRequest
Throws:
java.io.IOException - if it can't parse the request.

GetClientAddress

public java.lang.String GetClientAddress()
Returns the IP address of the client as a String in dotted quad form.

Specified by:
GetClientAddress in interface IXPRequest
Returns:
the IP address of the client in dotted quad form.


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