atg.rest.filtering
Class FilteringManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.rest.filtering.FilteringManager
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, java.util.EventListener

public class FilteringManager
extends GenericService

This class manages REST filtering and aliasing configuration. It is responsible for initialization of the filtering and aliasing configuration. In addition it provides runtime functionality which implements the rules from the configuration.

See Also:
ComponentConfiguration, PropertyConfiguration, RestPropertyCustomizer

Nested Class Summary
protected  class FilteringManager.ClassComparator
          a comparator class that sorts Class objects based on inheritance.
 
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
FilteringManager()
          Constructor
 
Method Summary
protected  void addComponentConfiguration(org.w3c.dom.Document pDocument)
          Adds the configuration for components for the given XML Document object
protected  void addItemDescriptorConfiguration(org.w3c.dom.Element pComponentElement, java.lang.Object pComponent, org.w3c.dom.NodeList pItemDescriptors, java.lang.String pTemplateId)
          Adds the filtering configuration for item descriptors
protected  void addPropertyConfiguration(org.w3c.dom.NodeList pProperties, ComponentConfiguration pComponentFilteringConfiguration)
          Adds property level configuration to the ComponentFilteringConfiguration object
 void doStartService()
          Initializes filtering and aliasing by reading in the configuration and generating the needed objects
 void doStopService()
          This is called when a Service is required to shut down.
protected  ComponentConfiguration getClassFilteredComponent(java.lang.String pName, java.util.Set<java.lang.Class<?>> pClassFilters, java.util.Map<java.lang.String,ComponentConfiguration> pMap)
          check for any component config matches based on superclasses/interfaces in the passed in map of component configs
 java.util.List<java.lang.String> getClassNameForJSONFilter(java.lang.String pClassName, JSONObject pJSON)
          given a class name, determine possible class names to use for looking up a filter in a json filter construct
 atg.xml.XMLFile[] getConfigurationFiles()
           
protected  java.lang.Class getFilterClassFromName(java.lang.String pClassName)
          get the class object for the given class name
 ComponentConfiguration getFilteredComponent(java.lang.String pName)
          Returns the filtering configuration for the given component name.
 ComponentConfiguration getFilteredComponent(java.lang.String pName, java.lang.String pTemplateId)
          Returns the filtering configuration for the given component name and template id.
 ComponentConfiguration getFilteredComponent(java.lang.String pName, java.lang.String[] pTemplateIds)
          Returns the filtering configuration for the given component name and template ids.
 java.util.HashMap<java.lang.String,ComponentConfiguration> getFilteredComponents()
          A Map of ComponentConfiguration objects whose key is a property name
 boolean getIgnoreExpandableOutputForSpecificClasses()
           
 java.lang.String[] getNonExpandableClassesList()
           
 atg.xml.tools.XMLToDOMParser getXMLToDOMParser()
           
 atg.xml.tools.XMLToolsFactory getXMLToolsFactory()
           
protected  void initializeConfiguration(atg.xml.XMLFile[] pFiles)
          Initializes the configuration of the FilteringManager by parsing the configuration files
protected  void processComponentConfiguration(org.w3c.dom.Element pElement, ComponentResolver pComponentResolver)
          process a component configuration
 void setConfigurationFiles(atg.xml.XMLFile[] pConfigurationFiles)
           
 void setIgnoreExpandableOutputForSpecificClasses(boolean pIgnoreExpandableOutputForSpecificClasses)
           
 void setNonExpandableClassesList(java.lang.String[] pNonExpandableClassesList)
           
 void setXMLToolsFactory(atg.xml.tools.XMLToolsFactory pXMLToolsFactory)
           
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, 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

FilteringManager

public FilteringManager()
Constructor

Method Detail

getFilteredComponents

public java.util.HashMap<java.lang.String,ComponentConfiguration> getFilteredComponents()
A Map of ComponentConfiguration objects whose key is a property name

Returns:
the value of filteredComponents

getConfigurationFiles

public atg.xml.XMLFile[] getConfigurationFiles()
Returns:
the value of configurationFiles

setConfigurationFiles

public void setConfigurationFiles(atg.xml.XMLFile[] pConfigurationFiles)
Parameters:
pConfigurationFiles - the configurationFiles to set

getIgnoreExpandableOutputForSpecificClasses

public boolean getIgnoreExpandableOutputForSpecificClasses()
Returns:
mIgnoreExpandableOutputForSpecificClasses

setIgnoreExpandableOutputForSpecificClasses

public void setIgnoreExpandableOutputForSpecificClasses(boolean pIgnoreExpandableOutputForSpecificClasses)
Parameters:
pIgnoreExpandableOutputForSpecificClasses -

setXMLToolsFactory

public void setXMLToolsFactory(atg.xml.tools.XMLToolsFactory pXMLToolsFactory)
Parameters:
pXMLToolsFactory - new value to set

getXMLToolsFactory

public atg.xml.tools.XMLToolsFactory getXMLToolsFactory()
Returns:
XMLToolsFactory

getXMLToDOMParser

public atg.xml.tools.XMLToDOMParser getXMLToDOMParser()

setNonExpandableClassesList

public void setNonExpandableClassesList(java.lang.String[] pNonExpandableClassesList)
Parameters:
pXMLToolsFactory - new value to set

getNonExpandableClassesList

public java.lang.String[] getNonExpandableClassesList()
Returns:
XMLToolsFactory

getFilteredComponent

public ComponentConfiguration getFilteredComponent(java.lang.String pName)
Returns the filtering configuration for the given component name. Returns null if there is no configuration.

Parameters:
pName - the name of the filtering configuration to retrieve
Returns:
the filtering configuration for the given component name

getFilteredComponent

public ComponentConfiguration getFilteredComponent(java.lang.String pName,
                                                   java.lang.String pTemplateId)
Returns the filtering configuration for the given component name and template id. Returns null if there is no configuration.

Parameters:
pName - the name of the filtering configuration to retrieve
pTemplateId - the template id
Returns:
the filtering configuration for the given component name

getFilteredComponent

public ComponentConfiguration getFilteredComponent(java.lang.String pName,
                                                   java.lang.String[] pTemplateIds)
Returns the filtering configuration for the given component name and template ids. Returns null if there is no configuration.

Parameters:
pName - the name of the filtering configuration to retrieve
pTemplateIds - the array of template ids
Returns:
the filtering configuration for the given component name

getClassFilteredComponent

protected ComponentConfiguration getClassFilteredComponent(java.lang.String pName,
                                                           java.util.Set<java.lang.Class<?>> pClassFilters,
                                                           java.util.Map<java.lang.String,ComponentConfiguration> pMap)
check for any component config matches based on superclasses/interfaces in the passed in map of component configs


getClassNameForJSONFilter

public java.util.List<java.lang.String> getClassNameForJSONFilter(java.lang.String pClassName,
                                                                  JSONObject pJSON)
                                                           throws JSONException
given a class name, determine possible class names to use for looking up a filter in a json filter construct

Parameters:
pClassName - the class name for the current container
the - json object containing the filters for the request
Returns:
a List of class name strings to which pClassName is assignable to, sorted by specificity
Throws:
JSONException

doStartService

public void doStartService()
                    throws ServiceException
Initializes filtering and aliasing by reading in the configuration and generating the needed objects

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the configuration cannot be parsed correctly

doStopService

public void doStopService()
                   throws ServiceException
This is called when a Service is required to shut down. The Service should respond by stopping any processes that it has started.

Overrides:
doStopService in class GenericService
Throws:
ServiceException - if the Service had a problem shutting down

initializeConfiguration

protected void initializeConfiguration(atg.xml.XMLFile[] pFiles)
                                throws ServiceException
Initializes the configuration of the FilteringManager by parsing the configuration files

Parameters:
pFiles - the configuration file(s)
Throws:
ServiceException - if the XMLToDOMParser is not configured

addComponentConfiguration

protected void addComponentConfiguration(org.w3c.dom.Document pDocument)
                                  throws ServiceException
Adds the configuration for components for the given XML Document object

Parameters:
pDocument - the XML Document object to read and use to configure the FilteringManager
Throws:
ServiceException - if an invalid item descriptor name is specified

processComponentConfiguration

protected void processComponentConfiguration(org.w3c.dom.Element pElement,
                                             ComponentResolver pComponentResolver)
                                      throws ServiceException
process a component configuration

Parameters:
pElement - the component element
pComponentResolver - the component resolver
Throws:
ServiceException - if an invalid item descriptor name is specified

addItemDescriptorConfiguration

protected void addItemDescriptorConfiguration(org.w3c.dom.Element pComponentElement,
                                              java.lang.Object pComponent,
                                              org.w3c.dom.NodeList pItemDescriptors,
                                              java.lang.String pTemplateId)
                                       throws ServiceException
Adds the filtering configuration for item descriptors

Parameters:
pComponentElement - the DOM element object representing the filtered component
pComponent - the actual component that is filtered
pItemDescriptors - the DOM nodes representing the item descriptors
pTemplateId - if this is a template, the id of the template
Throws:
ServiceException - if an invalid item descriptor name is given

addPropertyConfiguration

protected void addPropertyConfiguration(org.w3c.dom.NodeList pProperties,
                                        ComponentConfiguration pComponentFilteringConfiguration)
                                 throws ServiceException
Adds property level configuration to the ComponentFilteringConfiguration object

Parameters:
pProperties - the NodeList which contains all the property level data
pComponentFilteringConfiguration - the component filtering configuration object which to add the property level data
Throws:
ServiceException - if the property information could not be initialized

getFilterClassFromName

protected java.lang.Class getFilterClassFromName(java.lang.String pClassName)
get the class object for the given class name

Parameters:
pClassName - either just the class name, or the class name plus depth
Returns:
the Class object corresponding to class name, or null if there was an error creating the class