atg.rest.processor
Class GenericRestProcessor

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.rest.processor.GenericRestProcessor
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
Direct Known Subclasses:
BeanProcessor, RepositoryProcessor, RestSecurityProcessor

public abstract class GenericRestProcessor
extends GenericService
implements RestProcessor

The base class for processing rest requests.


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
GenericRestProcessor()
          Constructor
 
Method Summary
protected  JSONObject determineJSONControlParams()
          This method determines JSON control params
protected  boolean determineJSONUsage()
          This method determines whether to use JSON input
protected  boolean getBooleanControlParam(java.lang.String pName, boolean pDefault)
          get a specified boolean control param value
 ComponentResolver getComponentResolver()
           
 FilteringManager getFilteringManager()
           
 RestOutputCustomizer getOutputCustomizer()
          Returns the requested or configured rest output customizer.
 RestPipelineServlet getParentServlet()
           
protected  java.lang.String getStringControlParam(java.lang.String pName)
          get a specified string control param value
 boolean isAcceptJSONInput()
          get AcceptJSONInput
protected  boolean isResourceWritable(ParsedURI pParsedURI)
          Returns true if the property is writable based on the filtering configuration.
protected  boolean isResourceWritable(java.lang.String pPropertyName, ParsedURI pParsedURI)
          Returns true if the property is writable based on the filtering configuration.
 void setAcceptJSONInput(boolean pAcceptJSONInput)
          set AcceptJSONInput
 void setComponentResolver(ComponentResolver pComponentResolver)
           
 void setOutputCustomizer(RestOutputCustomizer pOutputCustomizer)
          Set the configured rest output customizer.
 void setParentServlet(RestPipelineServlet pParentServlet)
          This method sets the parent rest pipeline servlet
protected  boolean useSimpleResponseCodes()
          Returns true if simple response codes should be used for responses.
protected  boolean validateResource(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Validates that the REST request is for a valid resource type.
 
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
 
Methods inherited from interface atg.rest.processor.RestProcessor
doRESTDelete, doRESTGet, doRESTPost, doRESTPut
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

GenericRestProcessor

public GenericRestProcessor()
Constructor

Method Detail

getOutputCustomizer

public RestOutputCustomizer getOutputCustomizer()
                                         throws RestException,
                                                java.io.IOException
Returns the requested or configured rest output customizer.

Returns:
the requested or configured rest output customizer
Throws:
RestException
java.io.IOException

setOutputCustomizer

public void setOutputCustomizer(RestOutputCustomizer pOutputCustomizer)
Set the configured rest output customizer.

Parameters:
pOutputCustomizer - the outputCustomizer to set

getParentServlet

public RestPipelineServlet getParentServlet()
Returns:
the value of parentServlet

setParentServlet

public void setParentServlet(RestPipelineServlet pParentServlet)
Description copied from interface: RestProcessor
This method sets the parent rest pipeline servlet

Specified by:
setParentServlet in interface RestProcessor
Parameters:
pParentServlet - the parentServlet to set

getComponentResolver

public ComponentResolver getComponentResolver()
Returns:
the componentResolver which is used for finding components. In this context, it is mainly nucleus components.

setComponentResolver

public void setComponentResolver(ComponentResolver pComponentResolver)
Parameters:
pComponentResolver - the componentResolver to set

getFilteringManager

public FilteringManager getFilteringManager()
Returns:
the value of filteringManager

setAcceptJSONInput

public void setAcceptJSONInput(boolean pAcceptJSONInput)
set AcceptJSONInput

Parameters:
pAcceptJSONInput - the AcceptJSONInput

isAcceptJSONInput

public boolean isAcceptJSONInput()
get AcceptJSONInput

Returns:
the AcceptJSONInput

validateResource

protected boolean validateResource(DynamoHttpServletRequest pRequest,
                                   DynamoHttpServletResponse pResponse)
                            throws RestException,
                                   java.io.IOException
Validates that the REST request is for a valid resource type.

Parameters:
parsedURI - an object containing the parsed URI
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

isResourceWritable

protected boolean isResourceWritable(ParsedURI pParsedURI)
Returns true if the property is writable based on the filtering configuration. Note that this method does not evaluate security.

Parameters:
pParsedURI - an object containing the parsed URI
Returns:
true if the property is writable, false if it is not (based on filtering configuration only)

isResourceWritable

protected boolean isResourceWritable(java.lang.String pPropertyName,
                                     ParsedURI pParsedURI)
Returns true if the property is writable based on the filtering configuration. Note that this method does not evaluate security.

Parameters:
pPropertyName - the property name
pParsedURI - an object containing the parsed URI
Returns:
true if the property is writable, false if it is not (based on filtering configuration only)

useSimpleResponseCodes

protected boolean useSimpleResponseCodes()
Returns true if simple response codes should be used for responses. This means that we should use SC_OK (200) for success instead of the more granular codes. To use simple response codes, a request should pass in the url parameter "atg-rest-simple-response-codes=true".

Returns:
true if simple response codes should be used, false otherwise

getBooleanControlParam

protected boolean getBooleanControlParam(java.lang.String pName,
                                         boolean pDefault)
get a specified boolean control param value

Parameters:
pName - the name of the control param
pDefault - the default value for the control param
Returns:
the value of the control param

getStringControlParam

protected java.lang.String getStringControlParam(java.lang.String pName)
get a specified string control param value

Parameters:
pName - the name of the control param
Returns:
the value of the control param

determineJSONControlParams

protected JSONObject determineJSONControlParams()
                                         throws RestException
This method determines JSON control params

Returns:
JSONObject which contains map of control params in case of JSON input
Throws:
java.lang.IllegalArgumentException - if an unexpected error occurs during parsing JSON input param
RestException

determineJSONUsage

protected boolean determineJSONUsage()
This method determines whether to use JSON input

Returns:
true if we accept JSON input