com.plumtree.remote.util
Class RequestParameterParser

java.lang.Object
  extended bycom.plumtree.remote.util.RequestParameterParser

public class RequestParameterParser
extends java.lang.Object

Handles request body using the character set passed by Plumtree. Form bodies have one of 3 content types, "multipart/form-data" | "text/plain" | "application/x-www-form-urlencoded". This information is set in the html form tag, FORM ENCTYPE="multipart/form-data", (browsers default to "application/x-www-form-urlencoded" if one is not specified).

"application/x-www-form-urlencoded"
-- For Servlet 2.3 systems the class will use 2.3 methods to convert the body to Unicode.
-- 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. RequestParameterParser will attempt to get the original bytes back by assuming a character set of 8859-1, and convert to the bytes to the character set that was passed from the Portal Server. Weblogic 6.0sp2 has a problem with certain characters being lost.

"multipart/form-data"
Application Servers will not parse bodies with this content type. RequestParameterParser will not read this data.

"text/plain"
Application Servers will not parse bodies with this content type. RequestParameterParser will not read this data.

NOTE: Version 4.5 and above pass the character set in a portal header.


Constructor Summary
RequestParameterParser(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles request parameters using the character set passed by the portal.
RequestParameterParser(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String overridingCharacterSet)
          Handles request parameters using the character set passed as parameter overridingCharacterSet.
 
Method Summary
static java.lang.String convertStringToHex(java.lang.String strIn)
          Helper method for getting a hex string.
 boolean getBooleanParameter(java.lang.String name)
          Returns the value of a request parameter.
 boolean getBooleanParameter(java.lang.String name, boolean defaultValue)
          Returns the value of a request parameter or the default value if not specified.
 byte getByteParameter(java.lang.String name)
          Returns the value of a request parameter.
 byte getByteParameter(java.lang.String name, byte defaultValue)
          Returns the value of a request parameter or the default value if not specified.
 char getCharParameter(java.lang.String name)
          Returns the value of a request parameter.
 char getCharParameter(java.lang.String name, char defaultValue)
          Returns the value of a request parameter or the default value if not specified.
 double getDoubleParameter(java.lang.String name)
          Returns the value of a request parameter.
 double getDoubleParameter(java.lang.String name, double defaultValue)
          Returns the value of a request parameter or the default value if not specified.
 float getFloatParameter(java.lang.String name)
          Returns the value of a request parameter.
 float getFloatParameter(java.lang.String name, float defaultValue)
          Returns the value of a request parameter or the default value if not specified.
 int getIntParameter(java.lang.String name)
          Returns the value of a request parameter.
 int getIntParameter(java.lang.String name, int defaultValue)
          Returns the value of a request parameter or the default value if not specified.
 long getLongParameter(java.lang.String name)
          Returns the value of a request parameter.
 long getLongParameter(java.lang.String name, long defaultValue)
          Returns the value of a request parameter or the default value if not specified.
 java.lang.String getParameter(java.lang.String name)
          Returns the value of a request parameter as a string, null if the parameter does not exist.
 java.lang.String getParameter(java.lang.String name, java.lang.String defaultValue)
          Returns the value of a request parameter or the default value if not specified.
 java.util.Enumeration getParameterNames()
          Returns an enumeration of the parameter names.
 java.lang.String[] getParameterValues(java.lang.String name)
          Returns an array of String objects containing all of the values the given request parameter has, null if the parameter does not exist.
 short getShortParameter(java.lang.String name)
          Returns the value of a request parameter.
 short getShortParameter(java.lang.String name, short defaultValue)
          Returns the value of a request parameter or the default value if not specified.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestParameterParser

public RequestParameterParser(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws java.io.UnsupportedEncodingException
Handles request parameters using the character set passed by the portal. This will parse the data if the enc type is set to "multipart/form-data" | "text/plain". If "application/x-www-form-urlencoded" is set (this is the default) it will do its best to reconstruct the data. Converting to some character sets can cause data loss.

NOTE: This will not use portal headers to determine the character set.

Parameters:
request - The HTTP request object
response - The HTTP response object
Throws:
java.io.UnsupportedEncodingException - if the request is encoded in an unsupported encoding scheme

RequestParameterParser

public RequestParameterParser(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response,
                              java.lang.String overridingCharacterSet)
                       throws java.io.UnsupportedEncodingException
Handles request parameters using the character set passed as parameter overridingCharacterSet. This will parse the data if the enc type is set to "multipart/form-data" | "text/plain". If "application/x-www-form-urlencoded" is set (this is the default) it will do its best to reconstruct the data. Converting to some character sets can cause data loss.

NOTE: This ctor allows user to override the gateway specific character encoding settings

Parameters:
request - The HTTP request object
response - The HTTP response object
overridingCharacterSet - Character set user explicitly wants to use
Throws:
java.io.UnsupportedEncodingException - if the request is encoded in an unsupported encoding scheme
Method Detail

getParameterNames

public java.util.Enumeration getParameterNames()
Returns an enumeration of the parameter names.

Returns:
Enumeration of parameter names.

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, null if the parameter does not exist. If the parameter has a single value, the array has a length of 1.

Parameters:
name - A string containing the name of the parameter whose value is requested.
Returns:
An array of String objects containing the parameter's values.

getParameter

public java.lang.String getParameter(java.lang.String name)
Returns the value of a request parameter as a string, null if the parameter does not exist.

Parameters:
name - The name of the parameter to look up.
Returns:
The value in the parameter or null.

getParameter

public java.lang.String getParameter(java.lang.String name,
                                     java.lang.String defaultValue)
Returns the value of a request parameter or the default value if not specified.

Parameters:
name - The parameter name.
defaultValue - The default parameter value.
Returns:
The parameter value or default if not found.

getBooleanParameter

public boolean getBooleanParameter(java.lang.String name)
                            throws java.lang.NumberFormatException,
                                   java.lang.NullPointerException
Returns the value of a request parameter. If not found, will throw a NullPointerException.

Parameters:
name - The parameter name.
Returns:
The parameter value.
Throws:
java.lang.NumberFormatException - if the parameter cannot be interpreted as a boolean.
java.lang.NullPointerException - if the parameter does not exist

getBooleanParameter

public boolean getBooleanParameter(java.lang.String name,
                                   boolean defaultValue)
Returns the value of a request parameter or the default value if not specified.

Parameters:
name - The parameter name.
defaultValue - The default parameter value.
Returns:
The parameter value or default if not found.

getByteParameter

public byte getByteParameter(java.lang.String name)
                      throws java.lang.NullPointerException,
                             java.lang.NumberFormatException
Returns the value of a request parameter. If not found, will throw a NullPointerException.

Parameters:
name - The parameter name.
Returns:
The parameter value.
Throws:
java.lang.NumberFormatException - if the parameter cannot be interpreted as a byte.
java.lang.NullPointerException - if the parameter does not exist

getByteParameter

public byte getByteParameter(java.lang.String name,
                             byte defaultValue)
Returns the value of a request parameter or the default value if not specified.

Parameters:
name - The parameter name.
defaultValue - The default parameter value.
Returns:
The parameter value or default if not found.

getCharParameter

public char getCharParameter(java.lang.String name)
                      throws java.lang.NullPointerException
Returns the value of a request parameter. If not found, will throw a NullPointerException.

Parameters:
name - The parameter name.
Returns:
The parameter value.
Throws:
java.lang.NumberFormatException - if the parameter cannot be interpreted as a char.
java.lang.NullPointerException - if the parameter does not exist

getCharParameter

public char getCharParameter(java.lang.String name,
                             char defaultValue)
Returns the value of a request parameter or the default value if not specified.

Parameters:
name - The parameter name.
defaultValue - The default parameter value.
Returns:
The parameter value or default if not found.

getDoubleParameter

public double getDoubleParameter(java.lang.String name)
                          throws java.lang.NullPointerException,
                                 java.lang.NumberFormatException
Returns the value of a request parameter. If not found, will throw a NullPointerException.

Parameters:
name - The parameter name.
Returns:
The parameter value.
Throws:
java.lang.NumberFormatException - if the parameter cannot be interpreted as a double.
java.lang.NullPointerException - if the parameter does not exist

getDoubleParameter

public double getDoubleParameter(java.lang.String name,
                                 double defaultValue)
Returns the value of a request parameter or the default value if not specified.

Parameters:
name - The parameter name.
defaultValue - The default parameter value.
Returns:
The parameter value or default if not found.

getFloatParameter

public float getFloatParameter(java.lang.String name)
                        throws java.lang.NullPointerException,
                               java.lang.NumberFormatException
Returns the value of a request parameter. If not found, will throw a NullPointerException.

Parameters:
name - The parameter name.
Returns:
The parameter value.
Throws:
java.lang.NumberFormatException - if the parameter cannot be interpreted as a float.
java.lang.NullPointerException - if the parameter does not exist

getFloatParameter

public float getFloatParameter(java.lang.String name,
                               float defaultValue)
Returns the value of a request parameter or the default value if not specified.

Parameters:
name - The parameter name.
defaultValue - The default parameter value.
Returns:
The parameter value or default if not found.

getIntParameter

public int getIntParameter(java.lang.String name)
                    throws java.lang.NullPointerException,
                           java.lang.NumberFormatException
Returns the value of a request parameter. If not found, will throw a NullPointerException.

Parameters:
name - The parameter name.
Returns:
The parameter value.
Throws:
java.lang.NumberFormatException - if the parameter cannot be interpreted as an int.
java.lang.NullPointerException - if the parameter does not exist

getIntParameter

public int getIntParameter(java.lang.String name,
                           int defaultValue)
Returns the value of a request parameter or the default value if not specified.

Parameters:
name - The parameter name.
defaultValue - The default parameter value.
Returns:
The parameter value or default if not found.

getLongParameter

public long getLongParameter(java.lang.String name)
                      throws java.lang.NullPointerException,
                             java.lang.NumberFormatException
Returns the value of a request parameter. If not found, will throw a NullPointerException.

Parameters:
name - The parameter name.
Returns:
The parameter value.
Throws:
java.lang.NumberFormatException - if the parameter cannot be interpreted as a long.
java.lang.NullPointerException - if the parameter does not exist

getLongParameter

public long getLongParameter(java.lang.String name,
                             long defaultValue)
Returns the value of a request parameter or the default value if not specified.

Parameters:
name - The parameter name.
defaultValue - The default parameter value.
Returns:
The parameter value or default if not found.

getShortParameter

public short getShortParameter(java.lang.String name)
                        throws java.lang.NullPointerException,
                               java.lang.NumberFormatException
Returns the value of a request parameter. If not found, will throw a NullPointerException.

Parameters:
name - The parameter name.
Returns:
The parameter value.
Throws:
java.lang.NumberFormatException - if the parameter cannot be interpreted as a short.
java.lang.NullPointerException - if the parameter does not exist

getShortParameter

public short getShortParameter(java.lang.String name,
                               short defaultValue)
Returns the value of a request parameter or the default value if not specified.

Parameters:
name - The parameter name.
defaultValue - The default parameter value.
Returns:
The parameter value or default if not found.

convertStringToHex

public static java.lang.String convertStringToHex(java.lang.String strIn)
Helper method for getting a hex string. This is helpful for debuging I18N strings.

Parameters:
strIn - The string to print out the hex values.
Returns:
The hex version of the string.


For additional information on the Oracle® WebCenter Interaction Development Kit, including tutorials, blogs, code samples and more, see the Oracle Technology Network (http://www.oracle.com/technology/index.html).

Copyright ©2010 Oracle® Corporation. All Rights Reserved.