org.jboss.dna.graph.util
Class GraphImporter

java.lang.Object
  extended by org.jboss.dna.graph.util.GraphImporter

public class GraphImporter
extends Object

Author:
Randall Hauch

Nested Class Summary
protected  class GraphImporter.ImportedContentUsingSequencer
           
protected  class GraphImporter.ImporterCommands
           
protected  class GraphImporter.ImporterContext
           
static interface GraphImporter.ImportSpecification
           
protected  class GraphImporter.SingleRepositorySourceConnectionFactory
           
protected  class GraphImporter.UriImportedContent
           
 
Constructor Summary
GraphImporter(RepositoryConnectionFactory sources, ExecutionContext context)
           
 
Method Summary
protected  Path extractInputPathFrom(URI contentUri)
           
 ExecutionContext getContext()
          Get the context in which the importer will be executed.
protected  void importWithSequencer(StreamSequencer sequencer, URI contentUri, String mimeType, String sourceName, Path destinationPathInSource, NodeConflictBehavior conflictBehavior)
          Use the supplied sequencer to read the content at the given URI (with the specified MIME type) and write that content to the repository source into the specified location.
 GraphImporter.ImportSpecification importXml(File file)
          Import the content from the supplied XML file, specifying on the returned GraphImporter.ImportSpecification where the content is to be imported.
 GraphImporter.ImportSpecification importXml(String pathToFile)
          Import the content from the XML file at the supplied file location, specifying on the returned GraphImporter.ImportSpecification where the content is to be imported.
 GraphImporter.ImportSpecification importXml(URI uri)
          Import the content from the XML file at the supplied URI, specifying on the returned GraphImporter.ImportSpecification where the content is to be imported.
 void importXml(URI uri, String sourceName, Path destinationPathInSource)
          Read the content from the supplied URI and import into the repository at the supplied location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphImporter

public GraphImporter(RepositoryConnectionFactory sources,
                     ExecutionContext context)
Method Detail

getContext

public ExecutionContext getContext()
Get the context in which the importer will be executed.

Returns:
the execution context; never null

importXml

public GraphImporter.ImportSpecification importXml(URI uri)
Import the content from the XML file at the supplied URI, specifying on the returned GraphImporter.ImportSpecification where the content is to be imported.

Parameters:
uri - the URI where the importer can read the content that is to be imported
Returns:
the object that should be used to specify into which the content is to be imported
Throws:
IllegalArgumentException - if the uri or destination path are null

importXml

public GraphImporter.ImportSpecification importXml(String pathToFile)
Import the content from the XML file at the supplied file location, specifying on the returned GraphImporter.ImportSpecification where the content is to be imported.

Parameters:
pathToFile - the path to the XML file that should be imported.
Returns:
the object that should be used to specify into which the content is to be imported
Throws:
IllegalArgumentException - if the uri or destination path are null

importXml

public GraphImporter.ImportSpecification importXml(File file)
Import the content from the supplied XML file, specifying on the returned GraphImporter.ImportSpecification where the content is to be imported.

Parameters:
file - the XML file that should be imported.
Returns:
the object that should be used to specify into which the content is to be imported
Throws:
IllegalArgumentException - if the uri or destination path are null

importXml

public void importXml(URI uri,
                      String sourceName,
                      Path destinationPathInSource)
               throws IOException,
                      RepositorySourceException
Read the content from the supplied URI and import into the repository at the supplied location.

Parameters:
uri - the URI where the importer can read the content that is to be imported
sourceName - the name of the source into which the content is to be imported
destinationPathInSource - the path in the repository source where the content is to be written; may not be null
Throws:
IllegalArgumentException - if the uri or destination path are null
IOException - if there is a problem reading the content
RepositorySourceException - if there is a problem while writing the content to the repository source

importWithSequencer

protected void importWithSequencer(StreamSequencer sequencer,
                                   URI contentUri,
                                   String mimeType,
                                   String sourceName,
                                   Path destinationPathInSource,
                                   NodeConflictBehavior conflictBehavior)
                            throws IOException,
                                   RepositorySourceException
Use the supplied sequencer to read the content at the given URI (with the specified MIME type) and write that content to the repository source into the specified location.

Parameters:
sequencer - the sequencer that should be used; may not be null
contentUri - the URI where the content can be found; may not be null
mimeType - the MIME type for the content; may not be null
sourceName - the name of the source into which the content is to be imported
destinationPathInSource - the path in the repository source where the content is to be written; may not be null
conflictBehavior - the behavior when a node is to be created when an existing node already exists; defaults to NodeConflictBehavior.UPDATE if null
Throws:
IOException - if there is a problem reading the content
RepositorySourceException - if there is a problem while writing the content to the repository source

extractInputPathFrom

protected Path extractInputPathFrom(URI contentUri)
Parameters:
contentUri -
Returns:
the input path


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.