atg.rest.processor
Class BeanProcessor

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.rest.processor.GenericRestProcessor
              extended by atg.rest.processor.BeanProcessor
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, RestProcessor, java.util.EventListener

public class BeanProcessor
extends GenericRestProcessor

The base type for processing bean property based rest requests. This class handles GET, POST, and PUT requests. DELETE requests pass through this servlet to the next servlet in the chain.

See Also:
GenericRestProcessor, RestProcessor

Nested Class Summary
 class BeanProcessor.FormHandlerExceptions
           
 class BeanProcessor.FormHandlerOutputObject
           
 class BeanProcessor.FormHandlerProperties
           
 class BeanProcessor.FormHandlerPropertiesAndExceptions
           
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
BeanProcessor()
          Constructor
 
Method Summary
 void doRESTDelete(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method handles a REST "DELETE" request.
 void doRESTGet(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method handles the processing for a rest GET request.
 void doRESTPost(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method handles the processing for a rest POST resource request.
 void doRESTPut(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method handles the processing for a rest PUT request.
protected  java.lang.reflect.Method findMethodByParameterCount(java.util.List<java.lang.reflect.Method> pAllMethods)
          Try to find a method by comparing the number of supplied parameters with the number of parameters the method accepts.
protected  java.lang.reflect.Method findMethodBySignature(java.util.List<java.lang.reflect.Method> pAllMethods, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Attempts to find a method by method signature if the "atg-rest-method" parameter was supplied
 java.lang.String[] getAdditionalFormHandlerClassNames()
          This property is a list of fully qualified class names which represent form handler classes which do not extend atg.droplet.DropletFormHandler or atg.droplet.ObjectFormHandler.
protected  java.lang.Object[] getMethodArguments(java.lang.reflect.Method pMethod, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method gets the method arguments from either the input stream or url parameters
 RestSecurityManager getRestSecurityManager()
           
 RestSecurityProcessor getRestSecurityProcessor()
           
 boolean isReturnFormHandlerExceptionsByDefault()
          get ReturnFormHandlerExceptionsByDefault
 boolean isReturnFormHandlerPropertiesByDefault()
          get ReturnFormHandlerPropertiesByDefault
 void setAdditionalFormHandlerClassNames(java.lang.String[] pAdditionalFormHandlerClassNames)
           
 void setRestSecurityManager(RestSecurityManager pRestSecurityManager)
           
 void setRestSecurityProcessor(RestSecurityProcessor pRestSecurityProcessor)
           
 void setReturnFormHandlerExceptionsByDefault(boolean pReturnFormHandlerExceptionsByDefault)
          set ReturnFormHandlerExceptionsByDefault
 void setReturnFormHandlerPropertiesByDefault(boolean pReturnFormHandlerPropertiesByDefault)
          set ReturnFormHandlerPropertiesByDefault
 
Methods inherited from class atg.rest.processor.GenericRestProcessor
determineJSONControlParams, determineJSONUsage, getBooleanControlParam, getComponentResolver, getFilteringManager, getOutputCustomizer, getParentServlet, getStringControlParam, isAcceptJSONInput, isResourceWritable, isResourceWritable, setAcceptJSONInput, setComponentResolver, setOutputCustomizer, setParentServlet, useSimpleResponseCodes, validateResource
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
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

Constructor Detail

BeanProcessor

public BeanProcessor()
Constructor

Method Detail

getAdditionalFormHandlerClassNames

public java.lang.String[] getAdditionalFormHandlerClassNames()
This property is a list of fully qualified class names which represent form handler classes which do not extend atg.droplet.DropletFormHandler or atg.droplet.ObjectFormHandler. This allows the logic in doRESTPost() to treat the object as a form handler rather than a plain java object. Only form handler classes which do not extend atg.droplet.DropletFormHandler or atg.droplet.ObjectFormHandler should be listed here.

Returns:
the value of additionalFormHandlerClassNames

setAdditionalFormHandlerClassNames

public void setAdditionalFormHandlerClassNames(java.lang.String[] pAdditionalFormHandlerClassNames)
Parameters:
pAdditionalFormHandlerClassNames - the additionalFormHandlerClassNames to set

setReturnFormHandlerPropertiesByDefault

public void setReturnFormHandlerPropertiesByDefault(boolean pReturnFormHandlerPropertiesByDefault)
set ReturnFormHandlerPropertiesByDefault

Parameters:
pReturnFormHandlerPropertiesByDefault - the ReturnFormHandlerPropertiesByDefault

isReturnFormHandlerPropertiesByDefault

public boolean isReturnFormHandlerPropertiesByDefault()
get ReturnFormHandlerPropertiesByDefault

Returns:
the ReturnFormHandlerPropertiesByDefault

setReturnFormHandlerExceptionsByDefault

public void setReturnFormHandlerExceptionsByDefault(boolean pReturnFormHandlerExceptionsByDefault)
set ReturnFormHandlerExceptionsByDefault

Parameters:
pReturnFormHandlerExceptionsByDefault - the ReturnFormHandlerExceptionsByDefault

isReturnFormHandlerExceptionsByDefault

public boolean isReturnFormHandlerExceptionsByDefault()
get ReturnFormHandlerExceptionsByDefault

Returns:
the ReturnFormHandlerExceptionsByDefault

getRestSecurityProcessor

public RestSecurityProcessor getRestSecurityProcessor()
Returns:
restSecurityProcessor

setRestSecurityProcessor

public void setRestSecurityProcessor(RestSecurityProcessor pRestSecurityProcessor)
Parameters:
pRestSecurityProcessor - - set restSecurityProcessor

getRestSecurityManager

public RestSecurityManager getRestSecurityManager()
Returns:
restSecurityManager

setRestSecurityManager

public void setRestSecurityManager(RestSecurityManager pRestSecurityManager)
Parameters:
pRestSecurityManager - - set restSecurityManager

doRESTGet

public void doRESTGet(DynamoHttpServletRequest pRequest,
                      DynamoHttpServletResponse pResponse)
               throws RestException,
                      java.io.IOException
This method handles the processing for a rest GET request. It uses the componentResolver to find the resource's parent and then passes the resource to the output customizer.

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an input or output stream exception occurs

doRESTPost

public void doRESTPost(DynamoHttpServletRequest pRequest,
                       DynamoHttpServletResponse pResponse)
                throws RestException,
                       java.io.IOException
This method handles the processing for a rest POST resource request. A POST request translates into a method call on the resource's parent container.

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an input or output stream exception occurs

getMethodArguments

protected java.lang.Object[] getMethodArguments(java.lang.reflect.Method pMethod,
                                                DynamoHttpServletRequest pRequest,
                                                DynamoHttpServletResponse pResponse)
                                         throws RestException
This method gets the method arguments from either the input stream or url parameters

Parameters:
pMethod - the method for which to get the arguments
pRequest - the servlet request
pResponse - the servlet response
Returns:
an array of Objects which are the arguments to pass to the method for execution
Throws:
RestException - if an unexpected error occurs

findMethodBySignature

protected java.lang.reflect.Method findMethodBySignature(java.util.List<java.lang.reflect.Method> pAllMethods,
                                                         DynamoHttpServletRequest pRequest,
                                                         DynamoHttpServletResponse pResponse)
                                                  throws RestException
Attempts to find a method by method signature if the "atg-rest-method" parameter was supplied

Parameters:
pAllMethods - a list of all the methods to look through. This is a list of methods that have the same name.
pRequest - the servlet request
pResponse - the servlet response
Returns:
the method to call, null if it cannot determine a unique method
Throws:
RestException - if an invalid method signature is supplied

findMethodByParameterCount

protected java.lang.reflect.Method findMethodByParameterCount(java.util.List<java.lang.reflect.Method> pAllMethods)
Try to find a method by comparing the number of supplied parameters with the number of parameters the method accepts.

Parameters:
pAllMethods - a list of all the methods to look through
Returns:
the method to call, null if it cannot determine a unique method

doRESTPut

public void doRESTPut(DynamoHttpServletRequest pRequest,
                      DynamoHttpServletResponse pResponse)
               throws RestException,
                      java.io.IOException
This method handles the processing for a rest PUT request. A PUT request translates into a request to set a property on the resource.

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an input or output stream exception occurs

doRESTDelete

public void doRESTDelete(DynamoHttpServletRequest pRequest,
                         DynamoHttpServletResponse pResponse)
                  throws java.io.IOException,
                         RestException
This method handles a REST "DELETE" request. This operation is a no-op for this processor.

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an input or output stream exception occurs
See Also:
RestProcessor#handleRESTDeleteRequest(java.lang.String, atg.servlet.DynamoHttpServletRequest, atg.servlet.DynamoHttpServletResponse)