atg.servlet.pipeline
Class FileFinderPipelineServlet

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.servlet.pipeline.PipelineableServletImpl
                  extended by atg.servlet.pipeline.FileFinderPipelineServlet
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, PathTranslator, PipelineableServlet, java.util.EventListener, javax.servlet.Servlet

public class FileFinderPipelineServlet
extends PipelineableServletImpl
implements PathTranslator

This pipeline servlet will set the pathTranslated by appending the pathInfo to the document root (set as a property). If the pathInfo maps to a directory, then this will attempt to find an index file in that directory as specified by the "indexFiles" property, which lists the index files to try to find in order. If the pathTranslated is modified, then pathInfo and requestURI is also modified to keep the requestURI=contextPath+servletPath+pathInfo+queryArgs equation true.

If none of the index files are found for a directory reference, and "shouldListDirectory" is true, then the directory listing will be returned as the result of the request and the request will not be passed on.

If the pathInfo cannot map to any file or directory listing, then a 404 error is returned and the request is not passed on.

If the pathInfo maps to a directory but does not end with a "/", then a redirect is issued with the "/" and the request is not passed on.

If the pathTranslated is already set (is non-null), then all of the above functionality is skipped.


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
FileFinderPipelineServlet()
          Constructs a new FileFinderPipelineServlet
 
Method Summary
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
 int getDirectoryListingsServedCount()
          Returns the number of directory listings served by this
 java.lang.String getDocRootServicePrefix()
          Returns the property that specifies the path to find services in the nucleus component hierarchy that are in the doc root.
 java.io.File getDocumentRoot()
          Returns the first entry in the document root path.
 java.io.File[] getDocumentRootPath()
          Returns the document root from which path references will be resolved.
 java.lang.String getErrorURL()
          Returns the value of the property ErrorURL.
 atg.service.filecache.FileAttributesCache getFileAttributesCache()
          Return the file attributes cache
 int getFileNotFoundCount()
          Returns the number of files not found by this
 java.lang.String[] getIndexFiles()
          Returns the list of files to be searched in order when a request is sent referring to a directory.
 int getIndexFilesServedCount()
          Returns the number of index files served by this
 boolean getProcessIndexFiles()
          Returns the flag that indicates whether we should we try to process index files on already translated paths.
 java.lang.String getRealPath(DynamoHttpServletRequest pRequest, java.lang.String pPathInfo)
          This implements the PathTranslator method.
 boolean getReportFileNotFound()
          Gets the flag that tells whether or not we report file not found errors.
 boolean getShouldListDirectory()
          Returns the flag indicating whether a directory should be listed in response to a directory reference in which no index files can be found.
 java.util.Properties getVirtualDirectoryMap()
          Gets the virtual directory map.
 boolean isAlwaysTranslate()
          Returns the flag indicating if this should always translate files, even if the request comes in with a pathTranslated.
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Services a DynamoHttpServletRequest/Response pair
 void setAlwaysTranslate(boolean pAlwaysTranslate)
          Sets the flag indicating if this should always translate files, even if the request comes in with a pathTranslated.
 void setDocRootServicePrefix(java.lang.String pDocRootServicePrefix)
          Sets the property that specifies the path to find services in the nucleus component hierarchy that are in the doc root.
 void setDocumentRoot(java.io.File pDocumentRoot)
          For convenience, users can also set the DocumentRoot property as a single file if documentRootPath has not already been set.
 void setDocumentRootPath(java.io.File[] pDocumentRootPath)
          Sets the document root from which path references will be resolved.
 void setErrorURL(java.lang.String pErrorURL)
          Sets the property ErrorURL.
 void setFileAttributesCache(atg.service.filecache.FileAttributesCache pFileAttributesCache)
          Set the file attributes cache
 void setIndexFiles(java.lang.String[] pIndexFiles)
          Sets the list of files to be searched in order when a request is sent referring to a directory.
 void setProcessIndexFiles(boolean pProcessIndexFiles)
          Should we try to process index files on already translated paths? This option should be used for servers that translate the paths, but do not do index file translating (such as the Java Web Server).
 void setReportFileNotFound(boolean pReportFileNotFound)
          Should we report file not found errors?
 void setShouldListDirectory(boolean pShouldListDirectory)
          Sets the flag indicating whether a directory should be listed in response to a directory reference in which no index files can be found.
 void setVirtualDirectoryMap(java.util.Properties pMap)
          Sets the virtual directory map.
 
Methods inherited from class atg.servlet.pipeline.PipelineableServletImpl
createAdminServlet, destroy, getAdminServlet, getNextServlet, getServletConfig, getServletInfo, init, isUsePathInfo, passRequest, passRequest, service, service, setNextServlet, setServletInfo, setUsePathInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, doStopService, getAbsoluteName, 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, 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 java.lang.String CLASS_VERSION
Class version string

Constructor Detail

FileFinderPipelineServlet

public FileFinderPipelineServlet()
Constructs a new FileFinderPipelineServlet

Method Detail

setVirtualDirectoryMap

public void setVirtualDirectoryMap(java.util.Properties pMap)
Sets the virtual directory map.


getVirtualDirectoryMap

public java.util.Properties getVirtualDirectoryMap()
Gets the virtual directory map.


setDocumentRootPath

public void setDocumentRootPath(java.io.File[] pDocumentRootPath)
Sets the document root from which path references will be resolved. This is an ordered list of directories that are searched for files.


getDocumentRootPath

public java.io.File[] getDocumentRootPath()
Returns the document root from which path references will be resolved. This is an ordered list of directories that are searched for files.


setDocumentRoot

public void setDocumentRoot(java.io.File pDocumentRoot)
For convenience, users can also set the DocumentRoot property as a single file if documentRootPath has not already been set. This just gets mapped into a path with one entry.


getDocumentRoot

public java.io.File getDocumentRoot()
Returns the first entry in the document root path.


setIndexFiles

public void setIndexFiles(java.lang.String[] pIndexFiles)
Sets the list of files to be searched in order when a request is sent referring to a directory.


getIndexFiles

public java.lang.String[] getIndexFiles()
Returns the list of files to be searched in order when a request is sent referring to a directory.


setShouldListDirectory

public void setShouldListDirectory(boolean pShouldListDirectory)
Sets the flag indicating whether a directory should be listed in response to a directory reference in which no index files can be found.


getShouldListDirectory

public boolean getShouldListDirectory()
Returns the flag indicating whether a directory should be listed in response to a directory reference in which no index files can be found.


setReportFileNotFound

public void setReportFileNotFound(boolean pReportFileNotFound)
Should we report file not found errors?


getReportFileNotFound

public boolean getReportFileNotFound()
Gets the flag that tells whether or not we report file not found errors.


setErrorURL

public void setErrorURL(java.lang.String pErrorURL)
Sets the property ErrorURL. If this is not null, it indicates a URL to redirect the browser to if an error occurs.

Parameters:
pErrorURL - new Error URL

getErrorURL

public java.lang.String getErrorURL()
Returns the value of the property ErrorURL.

Returns:
value of the property ErrorURL

isAlwaysTranslate

public boolean isAlwaysTranslate()
Returns the flag indicating if this should always translate files, even if the request comes in with a pathTranslated.


setAlwaysTranslate

public void setAlwaysTranslate(boolean pAlwaysTranslate)
Sets the flag indicating if this should always translate files, even if the request comes in with a pathTranslated.


setProcessIndexFiles

public void setProcessIndexFiles(boolean pProcessIndexFiles)
Should we try to process index files on already translated paths? This option should be used for servers that translate the paths, but do not do index file translating (such as the Java Web Server).


getProcessIndexFiles

public boolean getProcessIndexFiles()
Returns the flag that indicates whether we should we try to process index files on already translated paths. This option should be used for servers that translate the paths, but do not do index file translating (such as the Java Web Server).


getDocRootServicePrefix

public java.lang.String getDocRootServicePrefix()
Returns the property that specifies the path to find services in the nucleus component hierarchy that are in the doc root.


setDocRootServicePrefix

public void setDocRootServicePrefix(java.lang.String pDocRootServicePrefix)
Sets the property that specifies the path to find services in the nucleus component hierarchy that are in the doc root.


getFileNotFoundCount

public int getFileNotFoundCount()
Returns the number of files not found by this


getIndexFilesServedCount

public int getIndexFilesServedCount()
Returns the number of index files served by this


getDirectoryListingsServedCount

public int getDirectoryListingsServedCount()
Returns the number of directory listings served by this


setFileAttributesCache

public void setFileAttributesCache(atg.service.filecache.FileAttributesCache pFileAttributesCache)
Set the file attributes cache


getFileAttributesCache

public atg.service.filecache.FileAttributesCache getFileAttributesCache()
Return the file attributes cache


doStartService

public void doStartService()
                    throws ServiceException
Description copied from class: GenericService
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. The Service should override this method to start any processes it requires.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

service

public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws java.io.IOException,
                    javax.servlet.ServletException
Services a DynamoHttpServletRequest/Response pair

Overrides:
service in class PipelineableServletImpl
Throws:
javax.servlet.ServletException - if an error occurred while processing the servlet request
java.io.IOException - if an error occurred while reading or writing the servlet request

getRealPath

public java.lang.String getRealPath(DynamoHttpServletRequest pRequest,
                                    java.lang.String pPathInfo)
This implements the PathTranslator method. It is called from the DynamoHttpServletRequest.getRealPath method by looking up the PATH_TRANSLATOR attribute.

Specified by:
getRealPath in interface PathTranslator