net.shibboleth.metadata.dom
Class DomResourceSourceStage

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

@ThreadSafe
public class DomResourceSourceStage
extends BaseStage<DomElementItem>

A pipeline stage which reads an XML document from an Resource, parses the document, and places the resultant document (root) element in to the provided DomElementItem collection.

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


Field Summary
private  org.opensaml.util.resource.Resource domResource
          Resource used to fetch remote XML document.
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  org.opensaml.util.xml.ParserPool parserPool
          Pool of parsers used to parse incoming DOM.
 
Constructor Summary
DomResourceSourceStage()
           
 
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.
 org.opensaml.util.resource.Resource getDomResource()
          Gets the resource from which the XML Document will be fetched.
 boolean getErrorCausesSourceFailure()
          Gets whether an error reading and parsing the XML file causes this stage to fail.
 org.opensaml.util.xml.ParserPool getParserPool()
          Gets the pool of DOM parsers used to parse the XML file in to a DOM.
protected  void populateItemCollection(Collection<DomElementItem> itemCollection, InputStream data)
          Builds an DomElementItem collection from a new XML document.
 void setDomResource(org.opensaml.util.resource.Resource resource)
          Sets the resource from which the XML document will be fetched.
 void setErrorCausesSourceFailure(boolean causesFailure)
          Sets whether an error reading and parsing the XML file causes this stage to fail.
 void setParserPool(org.opensaml.util.xml.ParserPool pool)
          Sets the pool of DOM parsers used to parse the XML file in to a DOM.
 
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.


domResource

private org.opensaml.util.resource.Resource domResource
Resource used to fetch remote XML document.


parserPool

private org.opensaml.util.xml.ParserPool parserPool
Pool of parsers used to parse incoming DOM.


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

DomResourceSourceStage

public DomResourceSourceStage()
Method Detail

getDomResource

public org.opensaml.util.resource.Resource getDomResource()
Gets the resource from which the XML Document will be fetched.

Returns:
resource from which the XML document will be fetched

setDomResource

public void setDomResource(org.opensaml.util.resource.Resource resource)
Sets the resource from which the XML document will be fetched.

Parameters:
resource - resource from which the XML document will be fetched

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

getErrorCausesSourceFailure

public boolean getErrorCausesSourceFailure()
Gets whether an error reading and parsing the XML file causes this stage to fail.

Returns:
whether an error reading and parsing the XML file causes this stage to fail

setErrorCausesSourceFailure

public void setErrorCausesSourceFailure(boolean causesFailure)
Sets whether an error reading and parsing the XML file causes this stage to fail.

Parameters:
causesFailure - whether an error reading and parsing the XML file causes this stage 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

populateItemCollection

protected void populateItemCollection(Collection<DomElementItem> itemCollection,
                                      InputStream data)
                               throws StageProcessingException
Builds an DomElementItem collection from a new XML document. Also caches DOM Element in its parsed form for later use.

Parameters:
itemCollection - collection to which the read in and parsed document element is added
data - XML input file
Throws:
StageProcessingException - thrown if there is a problem reading and parsing the response

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.