Package net.shibboleth.metadata.dom
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
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:
parserPoolsource
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether an error parsing one source file causes this entireStageto fail, or just excludes the material from the offending source file.private static final org.slf4j.LoggerClass logger.private booleanWhether the lack of source files is treated as an error.private net.shibboleth.shared.xml.ParserPoolPool of DOM parsers used to parse the XML file in to a DOM.private booleanWhether or not directories are recursed if the given input file is a directory.private FileThe file path to the DOM material provided by this source.private FileFilterFilter used to determine if a file should be included. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidPerforms the stage processing on the given Item collection.protected voidfinal booleanGets whether an error parsing a single file causes the source to fail.final net.shibboleth.shared.xml.ParserPoolGets the pool of DOM parsers used to parse the XML file in to a DOM.final booleanGets whether directories will be recursively searched for XML input files.final FileGets the path to the DOM material provided by this source.final FileFilterGets the filter used to determine if a file, in a directory, should be treated as a source file.protected voidgetSourceFiles(File input, List<File> collector) Gets the source files from a given input.final booleanGet whether the lack of source files is considered an error.protected DOMElementItemprocessSourceFile(File source) Reads in an XML source file, parses it, and creates the appropriateDOMElementItemfor the data.voidsetErrorCausesSourceFailure(boolean causesFailure) Sets whether an error parsing a single file causes the source to fail.voidsetNoSourceFilesAnError(boolean isError) Sets whether the lack of source files is considered an error.voidsetParserPool(net.shibboleth.shared.xml.ParserPool pool) Sets the pool of DOM parsers used to parse the XML file in to a DOM.voidsetRecurseDirectories(boolean recurse) Sets whether directories will be recursively searched for XML input files.voidSets the path to the DOM material provided by this source.voidsetSourceFileFilter(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.AbstractStage
execute, getCollectionPredicate, setCollectionPredicateMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentExceptionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.DestructableComponent
destroy, isDestroyedMethods inherited from interface net.shibboleth.shared.component.IdentifiedComponent
getIdMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitialized
-
Field Details
-
LOG
@Nonnull private static final org.slf4j.Logger LOGClass logger. -
parserPool
@NonnullAfterInit private net.shibboleth.shared.xml.ParserPool parserPoolPool of DOM parsers used to parse the XML file in to a DOM. -
sourceFile
The file path to the DOM material provided by this source. May be a file or a directory. -
sourceFileFilter
Filter used to determine if a file should be included. This is only used if thesourceFileis a directory. -
recurseDirectories
private boolean recurseDirectoriesWhether or not directories are recursed if the given input file is a directory. Default value:false -
noSourceFilesAnError
private boolean noSourceFilesAnErrorWhether the lack of source files is treated as an error. Default value:false -
errorCausesSourceFailure
private boolean errorCausesSourceFailureWhether an error parsing one source file causes this entireStageto 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
-
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
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
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
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:AbstractStagePerforms 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:
doExecutein classAbstractStage<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 andrecurseDirectoriesis true, then this process is repeated for each child direcrory.- Parameters:
input- the source input file, never nullcollector- 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 appropriateDOMElementItemfor the data.- Parameters:
source- XML file to read in- Returns:
- the resultant
DOMElementItem, may benullif there was an error parsing the data anderrorCausesSourceFailureis false - Throws:
StageProcessingException- thrown if there is a problem reading in the Element anderrorCausesSourceFailureis true
-
doInitialize
protected void doInitialize() throws net.shibboleth.shared.component.ComponentInitializationException- Overrides:
doInitializein classnet.shibboleth.shared.component.AbstractIdentifiedInitializableComponent- Throws:
net.shibboleth.shared.component.ComponentInitializationException
-