atg.rest.util
Class ParameterContext

java.lang.Object
  extended by atg.rest.util.ParameterContext

public class ParameterContext
extends java.lang.Object

A class which provides access to all the parameters in a request whether they are request parameters or parameters which are supplied via the input stream in a supported format. By default this is either json or xml. Request parameters always take precedence over parameters in the input stream. So a parameter supplied as a request parameter and in the input stream, its value will be that which was supplied via a request parameter.


Field Summary
static java.lang.String APPEND_MULTI_VALUES
           
static java.lang.String APPLICATION_JSON
           
static java.lang.String APPLICATION_XML
           
static java.lang.String ARG
           
static java.lang.String ARG1
           
static java.lang.String ATG_REST
           
static java.lang.String CLASS_DESCRIPTOR
           
static java.lang.String CLASS_TYPE
           
static java.lang.String CLASS_TYPES_FOR_JSON_INPUT
           
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String COUNT
           
static java.lang.String DEPTH
           
static java.lang.String DESCRIPTOR_COMPONENT_TYPE
           
static java.lang.String DESCRIPTOR_KEY_TYPE
           
static java.lang.String DESCRIPTOR_TYPE
           
static java.lang.String ENABLE_FORM_HANDLER_RETURN_EXCEPTIONS
           
static java.lang.String ENABLE_FORM_HANDLER_RETURN_PROPERTIES
           
static java.lang.String FORM_TAG_PRIORITIES
           
static java.lang.String HTTP_METHOD
           
static java.lang.String INDEX
           
static java.lang.String INPUT
           
static java.lang.String METHOD
           
static java.lang.String MULTIPART_FORM_DATA
           
static java.lang.String NULL
           
static java.lang.String OUTPUT
           
static java.lang.String PROPERTY_FILTERS
           
static java.lang.String RESPONSE_KEY
           
static java.lang.String RQL
           
static java.lang.String SHOW_PROPERTY_PATHS
           
static java.lang.String SIMPLE_RESPONSE_CODES
           
static java.lang.String TEMPLATE_IDS
           
static java.lang.String TRANSIENT
           
static java.lang.String USE_JSON_FOR_INPUT
           
static java.lang.String USER_INPUT
           
static java.lang.String VIEW
           
static java.lang.String WWW_FORM_URLENCODED
           
 
Method Summary
static void clearParameterContext()
          removes the value in the thread local parameterContext
static ParameterContext create(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           
 java.util.Map<java.lang.String,java.lang.Object> getControlParameters()
          Returns all the parameters which are control parameters.
 int getCountParameter()
          Returns the count parameter from the URL if present
 java.util.Map<java.lang.String,java.lang.Object> getFunctionalParameters()
          Returns all the parameters which are not control parameters.
 int getIndexParameter()
          Returns the index parameter from the URL if present
 int getMaxNestingDepth()
          Returns the maximum allowed nesting depth for this request.
 java.lang.Object getParameter(java.lang.String pName)
          Returns the parameter with the given name or null if the parameter does not exist
static ParameterContext getParameterContext()
           
 java.util.Map<java.lang.String,java.lang.Object> getParameters()
           
protected  void initialize(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Initializes the parameter context object by reading parameters from the input stream and the request
protected  java.util.Map<java.lang.String,java.lang.Object> parseFormUrlEncodedRequest(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Returns a map of parameters which were read from the input stream of a request whose content type is application/x-www-form-urlencoded
protected  java.lang.Object parseMultiPartRequest(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Parses a multi-part request and returns each item in a List.
protected  java.lang.String readInputStream(java.io.InputStream pInputStream)
          Deprecated. this method has been depreciated
protected  java.lang.String readInputStreamFromRequest(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Returns the content of the input stream as a string from the given request/response.
protected  java.util.Map<java.lang.String,java.lang.Object> readParametersFromInputStream(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Returns a map of parameters which were read from the input stream
 void setParameters(java.util.Map<java.lang.String,java.lang.Object> pParameters)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


DEPTH

public static final java.lang.String DEPTH
See Also:
Constant Field Values

OUTPUT

public static final java.lang.String OUTPUT
See Also:
Constant Field Values

INPUT

public static final java.lang.String INPUT
See Also:
Constant Field Values

INDEX

public static final java.lang.String INDEX
See Also:
Constant Field Values

COUNT

public static final java.lang.String COUNT
See Also:
Constant Field Values

RQL

public static final java.lang.String RQL
See Also:
Constant Field Values

TRANSIENT

public static final java.lang.String TRANSIENT
See Also:
Constant Field Values

METHOD

public static final java.lang.String METHOD
See Also:
Constant Field Values

CLASS_TYPE

public static final java.lang.String CLASS_TYPE
See Also:
Constant Field Values

CLASS_DESCRIPTOR

public static final java.lang.String CLASS_DESCRIPTOR
See Also:
Constant Field Values

HTTP_METHOD

public static final java.lang.String HTTP_METHOD
See Also:
Constant Field Values

SIMPLE_RESPONSE_CODES

public static final java.lang.String SIMPLE_RESPONSE_CODES
See Also:
Constant Field Values

APPEND_MULTI_VALUES

public static final java.lang.String APPEND_MULTI_VALUES
See Also:
Constant Field Values

USE_JSON_FOR_INPUT

public static final java.lang.String USE_JSON_FOR_INPUT
See Also:
Constant Field Values

CLASS_TYPES_FOR_JSON_INPUT

public static final java.lang.String CLASS_TYPES_FOR_JSON_INPUT
See Also:
Constant Field Values

ENABLE_FORM_HANDLER_RETURN_PROPERTIES

public static final java.lang.String ENABLE_FORM_HANDLER_RETURN_PROPERTIES
See Also:
Constant Field Values

ENABLE_FORM_HANDLER_RETURN_EXCEPTIONS

public static final java.lang.String ENABLE_FORM_HANDLER_RETURN_EXCEPTIONS
See Also:
Constant Field Values

PROPERTY_FILTERS

public static final java.lang.String PROPERTY_FILTERS
See Also:
Constant Field Values

TEMPLATE_IDS

public static final java.lang.String TEMPLATE_IDS
See Also:
Constant Field Values

SHOW_PROPERTY_PATHS

public static final java.lang.String SHOW_PROPERTY_PATHS
See Also:
Constant Field Values

VIEW

public static final java.lang.String VIEW
See Also:
Constant Field Values

USER_INPUT

public static final java.lang.String USER_INPUT
See Also:
Constant Field Values

RESPONSE_KEY

public static final java.lang.String RESPONSE_KEY
See Also:
Constant Field Values

FORM_TAG_PRIORITIES

public static final java.lang.String FORM_TAG_PRIORITIES
See Also:
Constant Field Values

ATG_REST

public static final java.lang.String ATG_REST
See Also:
Constant Field Values

NULL

public static final java.lang.String NULL
See Also:
Constant Field Values

ARG

public static final java.lang.String ARG
See Also:
Constant Field Values

ARG1

public static final java.lang.String ARG1
See Also:
Constant Field Values

MULTIPART_FORM_DATA

public static final java.lang.String MULTIPART_FORM_DATA
See Also:
Constant Field Values

WWW_FORM_URLENCODED

public static final java.lang.String WWW_FORM_URLENCODED
See Also:
Constant Field Values

APPLICATION_JSON

public static final java.lang.String APPLICATION_JSON
See Also:
Constant Field Values

APPLICATION_XML

public static final java.lang.String APPLICATION_XML
See Also:
Constant Field Values

DESCRIPTOR_TYPE

public static final java.lang.String DESCRIPTOR_TYPE
See Also:
Constant Field Values

DESCRIPTOR_COMPONENT_TYPE

public static final java.lang.String DESCRIPTOR_COMPONENT_TYPE
See Also:
Constant Field Values

DESCRIPTOR_KEY_TYPE

public static final java.lang.String DESCRIPTOR_KEY_TYPE
See Also:
Constant Field Values
Method Detail

getParameterContext

public static ParameterContext getParameterContext()
Returns:
the value of parameterContext

clearParameterContext

public static void clearParameterContext()
removes the value in the thread local parameterContext


getParameters

public java.util.Map<java.lang.String,java.lang.Object> getParameters()
Returns:
the value of parameters

setParameters

public void setParameters(java.util.Map<java.lang.String,java.lang.Object> pParameters)
Parameters:
pParameters - the parameters to set

getFunctionalParameters

public java.util.Map<java.lang.String,java.lang.Object> getFunctionalParameters()
Returns all the parameters which are not control parameters. Control parameters are those whose names begin with "atg-rest-"

Returns:
a Map of functional parameters

getControlParameters

public java.util.Map<java.lang.String,java.lang.Object> getControlParameters()
Returns all the parameters which are control parameters. Control parameters are those whose names begin with "atg-rest-"

Returns:
a Map of controlParameters

create

public static ParameterContext create(DynamoHttpServletRequest pRequest,
                                      DynamoHttpServletResponse pResponse)
                               throws RestException,
                                      java.io.IOException
Throws:
RestException
java.io.IOException

initialize

protected void initialize(DynamoHttpServletRequest pRequest,
                          DynamoHttpServletResponse pResponse)
                   throws RestException,
                          java.io.IOException
Initializes the parameter context object by reading parameters from the input stream and the request

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if the parameters could not be read from the stream or the type of data in the stream could not be handled
java.io.IOException

readParametersFromInputStream

protected java.util.Map<java.lang.String,java.lang.Object> readParametersFromInputStream(DynamoHttpServletRequest pRequest,
                                                                                         DynamoHttpServletResponse pResponse)
                                                                                  throws RestException,
                                                                                         java.io.IOException
Returns a map of parameters which were read from the input stream

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Returns:
a Map representing the parameters
Throws:
RestException - if the parameters could not be read from the stream or the type of data in the stream could not be handled
java.io.IOException

parseFormUrlEncodedRequest

protected java.util.Map<java.lang.String,java.lang.Object> parseFormUrlEncodedRequest(DynamoHttpServletRequest pRequest,
                                                                                      DynamoHttpServletResponse pResponse)
                                                                               throws RestException
Returns a map of parameters which were read from the input stream of a request whose content type is application/x-www-form-urlencoded

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Returns:
a Map representing the parameters
Throws:
RestException - if the parameters could not be read from the stream

readInputStream

@Deprecated
protected java.lang.String readInputStream(java.io.InputStream pInputStream)
                                    throws java.io.IOException
Deprecated. this method has been depreciated

Returns the contents of the input stream as a String

Parameters:
pInputStream - the input stream to read from
Returns:
a String which contains the contents from the input stream
Throws:
java.io.IOException

readInputStreamFromRequest

protected java.lang.String readInputStreamFromRequest(DynamoHttpServletRequest pRequest,
                                                      DynamoHttpServletResponse pResponse)
                                               throws RestException,
                                                      java.io.IOException
Returns the content of the input stream as a string from the given request/response. Uses the encoding set in the RestInputCustomizer to decode the input stream

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Returns:
A string which contains the contents from the input stream
Throws:
RestException - If the InputCustomizer can't be found for the mime-type
java.io.IOException

parseMultiPartRequest

protected java.lang.Object parseMultiPartRequest(DynamoHttpServletRequest pRequest,
                                                 DynamoHttpServletResponse pResponse)
                                          throws RestException
Parses a multi-part request and returns each item in a List. The returned object is created by the appropriate input customizer. The input customizer chosen is based on the contentType of the input.

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Returns:
an object representing the input data
Throws:
RestException - if the contents could not be read from the stream or the type of data in the stream could not be handled

getParameter

public java.lang.Object getParameter(java.lang.String pName)
Returns the parameter with the given name or null if the parameter does not exist

Parameters:
pName - the parameter name
Returns:
the parameter value or null

getMaxNestingDepth

public int getMaxNestingDepth()
                       throws RestException
Returns the maximum allowed nesting depth for this request.

Returns:
the maximum allowed nesting depth
Throws:
RestException

getIndexParameter

public int getIndexParameter()
                      throws RestException
Returns the index parameter from the URL if present

Returns:
the value of the index URL parameter
Throws:
RestException

getCountParameter

public int getCountParameter()
                      throws RestException
Returns the count parameter from the URL if present

Parameters:
pRequest - the request object
pResponse - the response object
Returns:
the value of the count URL parameter
Throws:
RestException