atg.rest.output
Class XMLOutputCustomizer

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.rest.output.RestOutputCustomizerImpl
              extended by atg.rest.output.XMLOutputCustomizer
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, RestOutputCustomizer, java.util.EventListener

public class XMLOutputCustomizer
extends RestOutputCustomizerImpl

This class implements an XML REST output customizer.

See Also:
RestOutputCustomizer

Nested Class Summary
 
Nested classes/interfaces inherited from class atg.rest.output.RestOutputCustomizerImpl
RestOutputCustomizerImpl.NucleusComponentReferenceObject, RestOutputCustomizerImpl.RepositoryItemReferenceObject
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.rest.output.RestOutputCustomizerImpl
REQUEST_SCOPE_PATH, SESSION_SCOPE_PATH, SPACE
 
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
XMLOutputCustomizer()
          Constructor.
 
Method Summary
protected  void addArrayToElement(ParsedURI pParsedURI, java.lang.Object pValue, org.dom4j.Element pElement, int pNestingDepth, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method will add an array to the given element.
protected  void addListToElement(ParsedURI pParsedURI, java.util.List<?> pValue, org.dom4j.Element pElement, int pNestingDepth, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method will add the given java.util.List to the given element.
protected  void addMapToElement(ParsedURI pParsedURI, java.util.Map<?,?> pValue, org.dom4j.Element pElement, int pNestingDepth, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method will add the given java.util.Map to the given element.
protected  void addObjectArrayToElement(ParsedURI pParsedURI, java.lang.Object[] pValue, int pIndex, int pCount, org.dom4j.Element pElement, int pNestingDepth, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method will add the given object array to the given element.
protected  void addObjectToElement(ParsedURI pParsedURI, java.lang.Object pValue, org.dom4j.Element pElement, int pNestingDepth, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method will add the given object value to the given element
protected  void addPrimitiveArrayToElement(java.lang.Object pValue, int pIndex, int pCount, org.dom4j.Element pElement, int pNestingDepth, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method will add the given primitive array to the given element.
protected  void addSetToElement(ParsedURI pParsedURI, java.util.Set<?> pValue, org.dom4j.Element pElement, int pNestingDepth, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method will add the given java.util.Set to the given element.
 void addValueToOutputObject(java.lang.String pPropertyName, java.lang.Object pValue, ParsedURI pParsedURI, java.lang.Object pContainer, java.lang.Object pParent, int pNestingDepth, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method will add the given value to the given Element object
 java.lang.Object createBeanOutput(ParsedURI pParsedURI, java.lang.Object pResContainer, int pNestingDepth, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method outputs all the properties of an object to the response's output stream
 java.lang.Object createBeanValueOutput(ParsedURI pParsedURI, java.lang.String pResourceName, java.lang.Object pValue, int pNestingDepth, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Outputs a bean property value to the output stream in XML.
protected  org.dom4j.io.OutputFormat createDefaultOutputFormat()
          Creates the default org.dom4j.io.OutputFormat object that is used to format the XML output.
 java.lang.Object createOutputContainer()
          This method creates the output container, a JSONObject.
protected  java.lang.Object getNucleusComponentReferenceObject(GenericService pService, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          create a nucleus component reference object
protected  java.lang.Object getRepositoryItemReferenceObject(RepositoryItem pItem, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          create a repository item reference object
 boolean isOmitEncoding()
          Flag indicating if the encoding declaration should be suppressed or not.
 boolean isSuppressDeclaration()
          Flag indicating if the XML declaration () is suppressed or not.
 boolean isXHTML()
          Flag indicating whether or not the output should be strict XHTML or not.
 void sendToOutputStream(java.lang.Object pDocument, DynamoHttpServletResponse pResponse)
          Writes the XML document to the servlet output stream
 void setOmitEncoding(boolean pOmitEncoding)
          Sets flag indicating if the encoding declaration should be suppressed or not.
 void setSuppressDeclaration(boolean pSuppressDeclaration)
          Sets flag indicating if the XML declaration () is suppressed or not.
 void setXHTML(boolean pXhtml)
          Sets flag indicating whether or not the output should be strict XHTML or not.
 
Methods inherited from class atg.rest.output.RestOutputCustomizerImpl
checkAgainstNonExpandableList, createComponentConfiguration, createOutputObject, createOutputObjectNoFiltering, createOutputObjectWithDefaultIncludes, createOutputObjectWithoutDefaultIncludes, enableShowRESTPaths, findComponentConfigJSON, getArrayElementString, getBooleanControlParam, getCollectionElementString, getComponentConfiguration, getComponentConfiguration, getComponentResolver, getContentType, getEncoding, getFilteringManager, getFormat, getHostAndPortString, getIndentSize, getMapElementString, getMapKeyElementString, getMapValueElementString, getNucleusComponentPropertyReferenceString, getNucleusComponentPropertyReferenceString, getNucleusComponentReferenceString, getNucleusComponentReferenceString, getReferenceStringRoot, getRepositoryItemPropertyReferenceString, getRepositoryItemReferenceString, getRootElementString, getStringControlParam, getTimeZoneId, isEnableFormatDateOutput, isEnablePerRequestClassFilters, isEnablePerRequestComponentFilters, isEnablePerRequestFilters, isEnablePerRequestRepositoryFilters, isLoggingPropertyDebug, isObjectANonGenericServiceNucleusComponent, isShowRESTPaths, loadNucleusComponentIntoMap, loadNucleusComponentIntoMap, outputBean, outputBeanProperty, outputBeanValue, outputFilteredProperty, outputNonFilteredProperty, searchComponentConfigs, setArrayElementString, setCollectionElementString, setContentType, setEnableFormatDateOutput, setEnablePerRequestClassFilters, setEnablePerRequestComponentFilters, setEnablePerRequestFilters, setEnablePerRequestRepositoryFilters, setEncoding, setFormat, setIndentSize, setLoggingPropertyDebug, setMapElementString, setMapKeyElementString, setMapValueElementString, setRootElementString, setShowRESTPaths, setTimeZoneId
 
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

XMLOutputCustomizer

public XMLOutputCustomizer()
Constructor. Sets the format to "xml". Calls createDefaultOutputFormat() method.

Method Detail

isOmitEncoding

public boolean isOmitEncoding()
Flag indicating if the encoding declaration should be suppressed or not. Default is true.

Returns:
the omitEncoding

setOmitEncoding

public void setOmitEncoding(boolean pOmitEncoding)
Sets flag indicating if the encoding declaration should be suppressed or not.

Parameters:
pOmitEncoding - the omitEncoding to set

isSuppressDeclaration

public boolean isSuppressDeclaration()
Flag indicating if the XML declaration () is suppressed or not. Default is true.

Returns:
the suppressDeclaration

setSuppressDeclaration

public void setSuppressDeclaration(boolean pSuppressDeclaration)
Sets flag indicating if the XML declaration () is suppressed or not.

Parameters:
pSuppressDeclaration - the suppressDeclaration to set

isXHTML

public boolean isXHTML()
Flag indicating whether or not the output should be strict XHTML or not. Default is true.

Returns:
the xHTML

setXHTML

public void setXHTML(boolean pXhtml)
Sets flag indicating whether or not the output should be strict XHTML or not.

Parameters:
pXhtml - the xHTML to set

createDefaultOutputFormat

protected org.dom4j.io.OutputFormat createDefaultOutputFormat()
Creates the default org.dom4j.io.OutputFormat object that is used to format the XML output.

Returns:
an instance of DefaultOutputFormat
See Also:
org.dom4j.io.OutputFormat

sendToOutputStream

public void sendToOutputStream(java.lang.Object pDocument,
                               DynamoHttpServletResponse pResponse)
                        throws RestException,
                               java.io.IOException
Writes the XML document to the servlet output stream

Parameters:
pDocument - the document to write
pResponse - the servlet response
Throws:
RestException - not thrown, inherited from interface declaration
java.io.IOException - if an input or output stream exception occurs

createOutputContainer

public java.lang.Object createOutputContainer()
This method creates the output container, a JSONObject.

Returns:
the output container, a JSONObject

createBeanOutput

public java.lang.Object createBeanOutput(ParsedURI pParsedURI,
                                         java.lang.Object pResContainer,
                                         int pNestingDepth,
                                         DynamoHttpServletRequest pRequest,
                                         DynamoHttpServletResponse pResponse)
                                  throws RestException,
                                         java.io.IOException
This method outputs all the properties of an object to the response's output stream

Specified by:
createBeanOutput in interface RestOutputCustomizer
Overrides:
createBeanOutput in class RestOutputCustomizerImpl
Parameters:
pParsedURI - an object containing the parsed URI
pResContainer - the object container which is the resource
pNestingDepth - the current nesting depth from the resource
pRequest - the servlet request
pResponse - the servlet response
Returns:
an object representing the data to be output
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an input or output stream exception occurs

createBeanValueOutput

public java.lang.Object createBeanValueOutput(ParsedURI pParsedURI,
                                              java.lang.String pResourceName,
                                              java.lang.Object pValue,
                                              int pNestingDepth,
                                              DynamoHttpServletRequest pRequest,
                                              DynamoHttpServletResponse pResponse)
                                       throws RestException,
                                              java.io.IOException
Outputs a bean property value to the output stream in XML.

Specified by:
createBeanValueOutput in interface RestOutputCustomizer
Overrides:
createBeanValueOutput in class RestOutputCustomizerImpl
Parameters:
pParsedURI - an object containing the parsed URI
pResourceName - the name of the resource being output
pValue - the value of the resource
pNestingDepth - the current nesting depth from the resource
pRequest - the servlet request
pResponse - the servlet response
Returns:
an object representing the data to be output
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an input or output stream exception occurs
See Also:
atg.rest.output.RestOutputCustomizer#outputBeanValue(java.lang.String, java.lang.Object, atg.servlet.DynamoHttpServletRequest, atg.servlet.DynamoHttpServletResponse)

addValueToOutputObject

public void addValueToOutputObject(java.lang.String pPropertyName,
                                   java.lang.Object pValue,
                                   ParsedURI pParsedURI,
                                   java.lang.Object pContainer,
                                   java.lang.Object pParent,
                                   int pNestingDepth,
                                   DynamoHttpServletRequest pRequest,
                                   DynamoHttpServletResponse pResponse)
                            throws RestException,
                                   java.io.IOException
This method will add the given value to the given Element object

Parameters:
pPropertyName - the name of the property value
pValue - the object representing the value
pParsedURI - an object containing the parsed URI
pContainer - the parent container of the given property or null if the parent container is not needed
pParent - the element to add the value to as a text element
pNestingDepth - the current nesting depth in the object tree
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

addArrayToElement

protected void addArrayToElement(ParsedURI pParsedURI,
                                 java.lang.Object pValue,
                                 org.dom4j.Element pElement,
                                 int pNestingDepth,
                                 DynamoHttpServletRequest pRequest,
                                 DynamoHttpServletResponse pResponse)
                          throws RestException,
                                 java.io.IOException
This method will add an array to the given element. If atg-rest-index and/or atg-rest-count parameters were submitted in the request, they will be taken into account and include only the requested elements from the array.

Parameters:
pParsedURI - an object containing the parsed URI
pValue - the object representing the array value
pElement - the element to add the value to as a text element
pNestingDepth - the current nesting depth from the resource
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an error occurs writing to the output stream

addPrimitiveArrayToElement

protected void addPrimitiveArrayToElement(java.lang.Object pValue,
                                          int pIndex,
                                          int pCount,
                                          org.dom4j.Element pElement,
                                          int pNestingDepth,
                                          DynamoHttpServletRequest pRequest,
                                          DynamoHttpServletResponse pResponse)
                                   throws RestException
This method will add the given primitive array to the given element. If atg-rest-index and/or atg-rest-count parameters were submitted in the request, they will be taken into account and include only the requested elements from the array.

Parameters:
pValue - the object representing the primitive array value
pIndex - the index from which to start returning items from the array
pCount - the number of elements to return from the starting point in the array
pElement - the element to add the value to as a text element
pNestingDepth - the current nesting depth from the resource
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an error occurs writing to the output stream

addObjectArrayToElement

protected void addObjectArrayToElement(ParsedURI pParsedURI,
                                       java.lang.Object[] pValue,
                                       int pIndex,
                                       int pCount,
                                       org.dom4j.Element pElement,
                                       int pNestingDepth,
                                       DynamoHttpServletRequest pRequest,
                                       DynamoHttpServletResponse pResponse)
                                throws RestException,
                                       java.io.IOException
This method will add the given object array to the given element. If atg-rest-index and/or atg-rest-count parameters were submitted in the request, they will be taken into account and include only the requested elements from the array.

Parameters:
pParsedURI - an object containing the parsed URI
pValue - the object representing the object array value
pIndex - the index from which to start returning items from the array
pCount - the number of elements to return from the starting point in the array
pElement - the element to add the value to as a text element
pNestingDepth - the current nesting depth from the resource
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an error occurs writing to the output stream

addListToElement

protected void addListToElement(ParsedURI pParsedURI,
                                java.util.List<?> pValue,
                                org.dom4j.Element pElement,
                                int pNestingDepth,
                                DynamoHttpServletRequest pRequest,
                                DynamoHttpServletResponse pResponse)
                         throws RestException,
                                java.io.IOException
This method will add the given java.util.List to the given element. If atg-rest-index and/or atg-rest-count parameters were submitted in the request, they will be taken into account and include only the requested elements from the List.

Parameters:
pParsedURI - an object containing the parsed URI
pValue - the object representing the List
pElement - the element to add the value to as a text element
pNestingDepth - the current nesting depth from the resource
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an error occurs writing to the output stream

addSetToElement

protected void addSetToElement(ParsedURI pParsedURI,
                               java.util.Set<?> pValue,
                               org.dom4j.Element pElement,
                               int pNestingDepth,
                               DynamoHttpServletRequest pRequest,
                               DynamoHttpServletResponse pResponse)
                        throws RestException,
                               java.io.IOException
This method will add the given java.util.Set to the given element. If atg-rest-index and/or atg-rest-count parameters were submitted in the request, they will be ignored because Sets do not have order.

Parameters:
pParsedURI - an object containing the parsed URI
pValue - the object representing the Set
pElement - the element to add the value to as a text element
pNestingDepth - the current nesting depth from the resource
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an error occurs writing to the output stream

addMapToElement

protected void addMapToElement(ParsedURI pParsedURI,
                               java.util.Map<?,?> pValue,
                               org.dom4j.Element pElement,
                               int pNestingDepth,
                               DynamoHttpServletRequest pRequest,
                               DynamoHttpServletResponse pResponse)
                        throws RestException,
                               java.io.IOException
This method will add the given java.util.Map to the given element. If atg-rest-index and/or atg-rest-count parameters were submitted in the request, they will be ignored because Maps do not have order.

Parameters:
pParsedURI - an object containing the parsed URI
pValue - the object representing the Map
pElement - the element to add the value to as a text element
pNestingDepth - the current nesting depth from the resource
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an error occurs writing to the output stream

addObjectToElement

protected void addObjectToElement(ParsedURI pParsedURI,
                                  java.lang.Object pValue,
                                  org.dom4j.Element pElement,
                                  int pNestingDepth,
                                  DynamoHttpServletRequest pRequest,
                                  DynamoHttpServletResponse pResponse)
                           throws RestException,
                                  java.io.IOException
This method will add the given object value to the given element

Parameters:
pParsedURI - an object containing the parsed URI
pValue - the object representing the object value
pElement - the element to add the value to as a text element
pNestingDepth - the current nesting depth from the resource
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an error occurs writing to the output stream

getRepositoryItemReferenceObject

protected java.lang.Object getRepositoryItemReferenceObject(RepositoryItem pItem,
                                                            DynamoHttpServletRequest pRequest,
                                                            DynamoHttpServletResponse pResponse)
                                                     throws RestException
create a repository item reference object

Parameters:
pValue - the RepositoryItem
pRequest - the request
pResponse - the response
Returns:
an object containing the repository item reference values
Throws:
RestException - if there's an error getting the repository item reference values

getNucleusComponentReferenceObject

protected java.lang.Object getNucleusComponentReferenceObject(GenericService pService,
                                                              DynamoHttpServletRequest pRequest,
                                                              DynamoHttpServletResponse pResponse)
                                                       throws RestException
create a nucleus component reference object

Parameters:
pService - the GenericService
pRequest - the request
pResponse - the response
Returns:
an object containing the nucleus component path
Throws:
RestException - if there's an error getting the nucleus component reference values