atg.service.collections.filter
Class ValidatorFilter

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.collections.filter.CachedCollectionFilter
              extended by atg.service.collections.filter.ValidatorFilter
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class ValidatorFilter
extends CachedCollectionFilter

This filter uses a collection of validators to filter objects in the collection. Any object that fails one or more validations will not be included in the result.

See Also:
CachedCollectionFilter.isCacheEnabled(), generateContextKey(java.util.Collection, java.lang.String, atg.repository.RepositoryItem), generateFilteredCollection(java.util.Collection, java.lang.String, atg.repository.RepositoryItem), CachedCollectionFilter

Field Summary
static java.lang.String CLASS_VERSION
           
protected  CollectionObjectValidator[] mValidators
           
 
Fields inherited from class atg.service.collections.filter.CachedCollectionFilter
FILTER_CACHE_COMPONENT, mCache, mCacheEnabled
 
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
ValidatorFilter()
           
 
Method Summary
 java.lang.Object generateContextKey(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile)
          Generates a context key.
protected  java.util.Collection generateFilteredCollection(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile)
          Called by the filterCollection method to generate the filtered collection.
 CollectionObjectValidator[] getValidators()
          Returns the array of validators that will be executed in succession to produce the final filtered results.
 void setValidators(CollectionObjectValidator[] pValidators)
          Sets the array of validators that will be executed in succession to produce the final filtered results.
 boolean shouldApplyFilter(java.util.Collection pUnfilteredCollection, java.lang.String pCollectionIdentifierKey, RepositoryItem pProfile)
          This method is called by filterCollection prior to looking up the filtered collection in the cache or generating a new filtered collection.
 
Methods inherited from class atg.service.collections.filter.CachedCollectionFilter
dumpCache, filterCollection, filterCollection, filterCollection, filterCollection, flushCache, generateCacheKey, generateCacheKey, generateContextKey, generateFilteredCollection, generateNewCollectionObject, getCache, getDefaultProfile, isCacheEnabled, setCache, setCacheEnabled, shouldApplyFilter, stringIt
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, 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, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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 final java.lang.String CLASS_VERSION
See Also:
Constant Field Values

mValidators

protected CollectionObjectValidator[] mValidators
Constructor Detail

ValidatorFilter

public ValidatorFilter()
Method Detail

setValidators

public void setValidators(CollectionObjectValidator[] pValidators)
Sets the array of validators that will be executed in succession to produce the final filtered results.


getValidators

public CollectionObjectValidator[] getValidators()
Returns the array of validators that will be executed in succession to produce the final filtered results.


generateContextKey

public java.lang.Object generateContextKey(java.util.Collection pUnfilteredCollection,
                                           java.lang.String pCollectionIdentifierKey,
                                           RepositoryItem pProfile)
Generates a context key.

Overrides:
generateContextKey in class CachedCollectionFilter
Returns:
a null context key.

shouldApplyFilter

public boolean shouldApplyFilter(java.util.Collection pUnfilteredCollection,
                                 java.lang.String pCollectionIdentifierKey,
                                 RepositoryItem pProfile)
Description copied from class: CachedCollectionFilter
This method is called by filterCollection prior to looking up the filtered collection in the cache or generating a new filtered collection. Implementations should use this method to bypass the filter when it doesn't apply to the current execution context. (e.g. a profile attribute has the wrong value etc.)

Overrides:
shouldApplyFilter in class CachedCollectionFilter
Parameters:
pUnfilteredCollection - the unfiltered collection
pCollectionIdentifierKey - the key param as passed to filterCollection
pProfile - the user profile
Returns:
true if there are any validators to execute
See Also:
atg.serivce.collections.filter.CachedCollectionFilter#shouldApplyFilter

generateFilteredCollection

protected java.util.Collection generateFilteredCollection(java.util.Collection pUnfilteredCollection,
                                                          java.lang.String pCollectionIdentifierKey,
                                                          RepositoryItem pProfile)
                                                   throws FilterException
Called by the filterCollection method to generate the filtered collection. Each object in the collection is tested against all validators. If the object does not pass any validation it is not included in the filtered results.

Each validator is executed by calling its validateObjects method.

Overrides:
generateFilteredCollection in class CachedCollectionFilter
Parameters:
pUnfilteredCollection - the unfiltered collection
pCollectionIdentifierKey - the key the uniquely identifies the unfiltered collection.
pProfile - Repository item
Returns:
the filtered collection
Throws:
FilterException