Class DOMFilesystemSourceStage

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.metadata.pipeline.AbstractStage<Element>
net.shibboleth.metadata.dom.DOMFilesystemSourceStage
All Implemented Interfaces:
Stage<Element>, net.shibboleth.shared.component.Component, net.shibboleth.shared.component.DestructableComponent, net.shibboleth.shared.component.IdentifiableComponent, net.shibboleth.shared.component.IdentifiedComponent, net.shibboleth.shared.component.InitializableComponent

@ThreadSafe public class DOMFilesystemSourceStage extends AbstractStage<Element>
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:

  • parserPool
  • source
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    Whether an error parsing one source file causes this entire Stage to fail, or just excludes the material from the offending source file.
    private static final org.slf4j.Logger
    Class logger.
    private boolean
    Whether the lack of source files is treated as an error.
    private net.shibboleth.shared.xml.ParserPool
    Pool of DOM parsers used to parse the XML file in to a DOM.
    private boolean
    Whether or not directories are recursed if the given input file is a directory.
    private File
    The file path to the DOM material provided by this source.
    private FileFilter
    Filter used to determine if a file should be included.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Performs the stage processing on the given Item collection.
    protected void
     
    final boolean
    Gets whether an error parsing a single file causes the source to fail.
    final net.shibboleth.shared.xml.ParserPool
    Gets the pool of DOM parsers used to parse the XML file in to a DOM.
    final boolean
    Gets whether directories will be recursively searched for XML input files.
    final File
    Gets the path to the DOM material provided by this source.
    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.
    final boolean
    Get whether the lack of source files is considered an error.
    protected DOMElementItem
    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(net.shibboleth.shared.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
    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.AbstractStage

    execute, getCollectionPredicate, setCollectionPredicate

    Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent

    setId

    Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent

    ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException

    Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

    checkComponentActive, checkSetterPreconditions, destroy, doDestroy, initialize, isDestroyed, isInitialized

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.shibboleth.shared.component.DestructableComponent

    destroy, isDestroyed

    Methods inherited from interface net.shibboleth.shared.component.IdentifiedComponent

    getId

    Methods inherited from interface net.shibboleth.shared.component.InitializableComponent

    initialize, isInitialized
  • Field Details

    • LOG

      @Nonnull private static final org.slf4j.Logger LOG
      Class logger.
    • parserPool

      @NonnullAfterInit private net.shibboleth.shared.xml.ParserPool parserPool
      Pool of DOM parsers used to parse the XML file in to a DOM.
    • sourceFile

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

      @Nullable 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 Details

    • DOMFilesystemSourceStage

      public DOMFilesystemSourceStage()
  • Method Details

    • getParserPool

      @NonnullAfterInit public final net.shibboleth.shared.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(@Nonnull net.shibboleth.shared.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

      @NonnullAfterInit public final 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(@Nonnull 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

      @Nullable public final 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(@Nonnull 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 final 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 final 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 final 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(@Nonnull @NonnullElements List<Item<Element>> items) throws StageProcessingException
      Description copied from class: AbstractStage
      Performs the stage processing on the given Item collection.

      The stage is guaranteed to be have been initialized and not destroyed when this is invoked.

      Specified by:
      doExecute in class AbstractStage<Element>
      Parameters:
      items - collection to be processed
      Throws:
      StageProcessingException - thrown if there is an unrecoverable problem when processing the stage
    • getSourceFiles

      protected void getSourceFiles(@Nonnull File input, @Nonnull @NonnullElements @Live 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

      @Nullable protected DOMElementItem processSourceFile(@Nonnull 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 DOMElementItem, 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 net.shibboleth.shared.component.ComponentInitializationException
      Overrides:
      doInitialize in class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
      Throws:
      net.shibboleth.shared.component.ComponentInitializationException