net.shibboleth.metadata.dom
Class DomFilesystemSourceStage

java.lang.Object
  extended by net.shibboleth.metadata.pipeline.AbstractComponent
      extended by net.shibboleth.metadata.pipeline.BaseStage<DomElementItem>
          extended by net.shibboleth.metadata.dom.DomFilesystemSourceStage
All Implemented Interfaces:
Component, Stage<DomElementItem>

@ThreadSafe
public class DomFilesystemSourceStage
extends BaseStage<DomElementItem>

A stage which reads XML information from the filesystem and places it in the given DomElementItem collection.

This stage requires the following properties be set prior to initialization:


Field Summary
private  boolean errorCausesSourceFailure
          Whether an error parsing one source file causes this entire Stage to fail, or just excludes the material from the offending source file.
private  Logger log
          Class logger.
private  boolean noSourceFilesAnError
          Whether the lack of source files is treated as an error.
private  org.opensaml.util.xml.ParserPool parserPool
          Pool of DOM parsers used to parse the XML file in to a DOM.
private  boolean recurseDirectories
          Whether or not directories are recursed if the given input file is a directory.
private  File sourceFile
          The file path to the DOM material provided by this source.
private  FileFilter sourceFileFilter
          Filter used to determine if a file should be included.
 
Constructor Summary
DomFilesystemSourceStage()
           
 
Method Summary
protected  void doExecute(Collection<DomElementItem> itemCollection)
          Performs the stage processing on the given Item collection.
protected  void doInitialize()
          Do the initialization of the component.
 boolean getErrorCausesSourceFailure()
          Gets whether an error parsing a single file causes the source to fail.
 org.opensaml.util.xml.ParserPool getParserPool()
          Gets the pool of DOM parsers used to parse the XML file in to a DOM.
 boolean getRecurseDirectories()
          Gets whether directories will be recursively searched for XML input files.
 File getSource()
          Gets the path to the DOM material provided by this source.
 FileFilter getSourceFileFilter()
          Gets the filter used to determine if a file, in a directory, should be treated as a source file.
protected  void getSourceFiles(File input, List<File> collector)
          Gets the source files from a given input.
 boolean isNoSourceFilesAnError()
          Get whether the lack of source files is considered an error.
protected  DomElementItem processSourceFile(File source)
          Reads in an XML source file, parses it, and creates the appropriate DomElementItem for the data.
 void setErrorCausesSourceFailure(boolean causesFailure)
          Sets whether an error parsing a single file causes the source to fail.
 void setNoSourceFilesAnError(boolean isError)
          Sets whether the lack of source files is considered an error.
 void setParserPool(org.opensaml.util.xml.ParserPool pool)
          Sets the pool of DOM parsers used to parse the XML file in to a DOM.
 void setRecurseDirectories(boolean recurse)
          Sets whether directories will be recursively searched for XML input files.
 void setSource(File source)
          Sets the path to the DOM material provided by this source.
 void setSourceFileFilter(FileFilter filter)
          Sets the filter used to determine if a file, in a directory, should be treated as a source file.
 
Methods inherited from class net.shibboleth.metadata.pipeline.BaseStage
execute
 
Methods inherited from class net.shibboleth.metadata.pipeline.AbstractComponent
equals, getId, getInitializationInstant, hashCode, initialize, isInitialized, setId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.shibboleth.metadata.pipeline.Component
getId, getInitializationInstant, initialize, isInitialized
 

Field Detail

log

private final Logger log
Class logger.


parserPool

private org.opensaml.util.xml.ParserPool parserPool
Pool of DOM parsers used to parse the XML file in to a DOM.


sourceFile

private File sourceFile
The file path to the DOM material provided by this source. May be a file or a directory.


sourceFileFilter

private FileFilter sourceFileFilter
Filter used to determine if a file should be included. This is only used if the sourceFile is a directory.


recurseDirectories

private boolean recurseDirectories
Whether or not directories are recursed if the given input file is a directory. Default value: false


noSourceFilesAnError

private boolean noSourceFilesAnError
Whether the lack of source files is treated as an error. Default value: false


errorCausesSourceFailure

private boolean errorCausesSourceFailure
Whether an error parsing one source file causes this entire Stage to fail, or just excludes the material from the offending source file. Default value: true

Constructor Detail

DomFilesystemSourceStage

public DomFilesystemSourceStage()
Method Detail

getParserPool

public org.opensaml.util.xml.ParserPool getParserPool()
Gets the pool of DOM parsers used to parse the XML file in to a DOM.

Returns:
pool of DOM parsers used to parse the XML file in to a DOM

setParserPool

public void setParserPool(org.opensaml.util.xml.ParserPool pool)
Sets the pool of DOM parsers used to parse the XML file in to a DOM.

Parameters:
pool - pool of DOM parsers used to parse the XML file in to a DOM

getSource

public File getSource()
Gets the path to the DOM material provided by this source. May be a file or a directory.

Returns:
path to the DOM material provided by this source

setSource

public void setSource(File source)
Sets the path to the DOM material provided by this source. May be a file or a directory.

Parameters:
source - path to the DOM material provided by this source

getSourceFileFilter

public FileFilter getSourceFileFilter()
Gets the filter used to determine if a file, in a directory, should be treated as a source file. If no filter is set then all files are used as source files. If the source file is not a directory this filter is meaningless.

Returns:
filter used to determine if a file, in a directory, should be treated as a source file, may be null

setSourceFileFilter

public void setSourceFileFilter(FileFilter filter)
Sets the filter used to determine if a file, in a directory, should be treated as a source file.

Parameters:
filter - filter used to determine if a file, in a directory, should be treated as a source file, may be null

getRecurseDirectories

public boolean getRecurseDirectories()
Gets whether directories will be recursively searched for XML input files.

Returns:
whether directories will be recursively searched for XML input files

setRecurseDirectories

public void setRecurseDirectories(boolean recurse)
Sets whether directories will be recursively searched for XML input files.

Parameters:
recurse - whether directories will be recursively searched for XML input files

isNoSourceFilesAnError

public boolean isNoSourceFilesAnError()
Get whether the lack of source files is considered an error.

Returns:
whether the lack of source files is considered an error

setNoSourceFilesAnError

public void setNoSourceFilesAnError(boolean isError)
Sets whether the lack of source files is considered an error.

Parameters:
isError - whether the lack of source files is considered an error

getErrorCausesSourceFailure

public boolean getErrorCausesSourceFailure()
Gets whether an error parsing a single file causes the source to fail. If not, the parsed file is simply ignored.

Returns:
whether an error parsing a single file causes the source to fail

setErrorCausesSourceFailure

public void setErrorCausesSourceFailure(boolean causesFailure)
Sets whether an error parsing a single file causes the source to fail. If not, the parsed file is simply ignored.

Parameters:
causesFailure - whether an error parsing a single file causes the source to fail

doExecute

protected void doExecute(Collection<DomElementItem> itemCollection)
                  throws StageProcessingException
Performs the stage processing on the given Item collection.

Specified by:
doExecute in class BaseStage<DomElementItem>
Parameters:
itemCollection - collection to be processed
Throws:
StageProcessingException - thrown if there is an unrecoverable problem when processing the stage

getSourceFiles

protected void getSourceFiles(File input,
                              List<File> collector)
Gets the source files from a given input. If the input is an XML file, it's added to the collector. If the input file is a directory, all of its XML files are added to the collector. If the directory contains other directories and recurseDirectories is true, then this process is repeated for each child direcrory.

Parameters:
input - the source input file, never null
collector - the collector of XML input files

processSourceFile

protected DomElementItem processSourceFile(File source)
                                    throws StageProcessingException
Reads in an XML source file, parses it, and creates the appropriate DomElementItem for the data.

Parameters:
source - XML file to read in
Returns:
the resultant Element Itme, may be null if there was an error parsing the data and errorCausesSourceFailure is false
Throws:
StageProcessingException - thrown if there is a problem reading in the Element and errorCausesSourceFailure is true

doInitialize

protected void doInitialize()
                     throws ComponentInitializationException
Do the initialization of the component. Default implementation of this method is a no-op. Extending classes should override this method to perform any initialization logic necessary.

Overrides:
doInitialize in class AbstractComponent
Throws:
ComponentInitializationException - throw if there is a problem initializing the component


Copyright © 2009-2011. All Rights Reserved.