org.tigris.scarab.util.xmlissues
Class ImportIssues

java.lang.Object
  extended byorg.tigris.scarab.util.xmlissues.ImportIssues
All Implemented Interfaces:
org.xml.sax.ErrorHandler

public class ImportIssues
extends java.lang.Object
implements org.xml.sax.ErrorHandler

This is a bean'ish object which allows one to set values for importing issues, and then run the actual import. Amenable to the ant task wrapper or you can pass an explicit file for explicit import if turbine is already up and running.

The way the ant task wrapper works is simple: call all the appropriate set methods to define the properties. Then you will need to call the init() and execute methods to start running things. Note: If Turbine is already initialized, there is no need to call the init() method.

Instances of this class are not thread-safe.

Since:
Scarab beta 14
Version:
$Id: ImportIssues.java 10065 2006-04-23 21:02:14Z hair $
Author:
Jon S. Stevens, Daniel Rall

Nested Class Summary
static class ImportIssues.ImportType
           
(package private)  class ImportIssues.ScarabIssuesSetupRule
          A rule to perform setup of the a ScarabIssues instance.
(package private)  class ImportIssues.TransformResolver
          A URI Resolver for use with the XSL transforms This resolver will map a URI in the XSL transform to an absolute file path.
 
Field Summary
static java.lang.String SYSTEM_DTD_URI
           
 
Constructor Summary
ImportIssues()
           
ImportIssues(boolean allowFileAttachments)
           
 
Method Summary
protected  org.apache.commons.betwixt.io.BeanReader createScarabIssuesBeanReader()
          Return a bean reader for ScarabIssue.
protected  org.apache.commons.betwixt.XMLIntrospector createXMLIntrospector()
           
 void error(org.xml.sax.SAXParseException e)
          Receive notification of a recoverable error.
 void execute()
          Hook method called by Ant's Task wrapper.
 void fatalError(org.xml.sax.SAXParseException e)
          Receive notification of a non-recoverable error.
 java.io.File getConfigDir()
           
 java.lang.String getConfigFile()
           
 ScarabIssues getScarabIssuesBeanReader()
          Get instance of the ScarabIssues used importing.
 boolean getSendEmail()
           
 java.lang.String getTurbineResources()
           
 java.io.File getXmlFile()
           
 void init()
           
protected  ScarabIssues insert(java.lang.String name, java.io.Reader is, org.apache.commons.betwixt.io.BeanReader reader)
          Do actual issue insert.
 java.util.Collection runImport(java.io.File importFile)
          Run an import.
 java.util.Collection runImport(org.apache.commons.fileupload.FileItem importFile)
          Run an import.
 java.util.Collection runImport(org.apache.commons.fileupload.FileItem importFile, Module currentModule, ImportIssues.ImportType type)
          Run an import.
 java.util.Collection runImport(java.io.File importFile, Module currentModule)
          Run an import.
protected  java.util.Collection runImport(java.lang.String filePath, java.lang.Object input, Module currentModule, ImportIssues.ImportType type)
           
 void setConfigDir(java.io.File configDir)
           
 void setConfigFile(java.lang.String configProps)
           
 void setSendEmail(boolean state)
           
 void setTurbineResources(java.lang.String trProps)
           
 void setXmlFile(java.io.File xmlFile)
           
protected  void validate(java.lang.String name, java.io.Reader is, org.apache.commons.betwixt.io.BeanReader reader, Module currentModule)
          Run validation phase.
 void warning(org.xml.sax.SAXParseException e)
          Receive notification of a warning.
protected  void write(java.lang.Object bean, java.io.Writer out)
          Method to output the bean object as XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYSTEM_DTD_URI

public static final java.lang.String SYSTEM_DTD_URI
See Also:
Constant Field Values
Constructor Detail

ImportIssues

public ImportIssues()

ImportIssues

public ImportIssues(boolean allowFileAttachments)
Method Detail

getSendEmail

public boolean getSendEmail()

setSendEmail

public void setSendEmail(boolean state)

getXmlFile

public java.io.File getXmlFile()

setXmlFile

public void setXmlFile(java.io.File xmlFile)

getConfigDir

public java.io.File getConfigDir()

setConfigDir

public void setConfigDir(java.io.File configDir)

getConfigFile

public java.lang.String getConfigFile()

setConfigFile

public void setConfigFile(java.lang.String configProps)

getTurbineResources

public java.lang.String getTurbineResources()

setTurbineResources

public void setTurbineResources(java.lang.String trProps)

init

public void init()
          throws ScarabException,
                 java.net.MalformedURLException,
                 java.io.IOException
Throws:
ScarabException
java.net.MalformedURLException
java.io.IOException

execute

public void execute()
             throws ScarabException
Hook method called by Ant's Task wrapper.

Throws:
ScarabException

runImport

public java.util.Collection runImport(java.io.File importFile)
                               throws ScarabException
Run an import. Assumes we're up and running inside of turbine.

Parameters:
importFile - File to import.
Returns:
List of errors if any.
Throws:
java.lang.Exception
ScarabException

runImport

public java.util.Collection runImport(java.io.File importFile,
                                      Module currentModule)
                               throws ScarabException
Run an import. Assumes we're up and running inside of turbine.

Parameters:
importFile - File to import.
currentModule - If non-null, run check that import is going against this module.
Returns:
List of errors if any.
Throws:
java.lang.Exception
ScarabException

runImport

public java.util.Collection runImport(org.apache.commons.fileupload.FileItem importFile)
                               throws ScarabException
Run an import. Assumes we're up and running inside of turbine. Awkwardly duplicates import but duplication is so we can do the reget of the input stream; FileInput "manages" backing up the Upload for us on the second get of the input stream (It creates new ByteArrayInputStream w/ the src being a byte array of the file its kept in memory or in temporary storage on disk).

Parameters:
importFile - FileItem reference to use importing.
Returns:
List of errors if any.
Throws:
java.lang.Exception
ScarabException

runImport

public java.util.Collection runImport(org.apache.commons.fileupload.FileItem importFile,
                                      Module currentModule,
                                      ImportIssues.ImportType type)
                               throws ScarabException
Run an import. Assumes we're up and running inside of turbine. Awkwardly duplicates import but duplication is so we can do the reget of the input stream; FileInput "manages" backing up the Upload for us on the second get of the input stream (It creates new ByteArrayInputStream w/ the src being a byte array of the file its kept in memory or in temporary storage on disk).

Parameters:
importFile - FileItem reference to use importing.
currentModule - If non-null, run check that import is going against this module.
Returns:
List of errors if any.
Throws:
java.lang.Exception
ScarabException

runImport

protected java.util.Collection runImport(java.lang.String filePath,
                                         java.lang.Object input,
                                         Module currentModule,
                                         ImportIssues.ImportType type)
                                  throws ScarabException
Parameters:
input - A File or FileItem.
Throws:
ScarabException

validate

protected void validate(java.lang.String name,
                        java.io.Reader is,
                        org.apache.commons.betwixt.io.BeanReader reader,
                        Module currentModule)
                 throws javax.xml.parsers.ParserConfigurationException,
                        org.xml.sax.SAXException,
                        java.io.IOException
Run validation phase. Starts by performing XML-well formed-ness and DTD validation (if present), then checks the content.

Parameters:
name - Filename to output in log message. May be null.
is - Input stream to read.
reader - ScarabIssues bean reader instance.
currentModule - If not null, check whether import is going against this module.
Returns:
Any errors encountered during XML or content validation.
Throws:
java.lang.Exception
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException

insert

protected ScarabIssues insert(java.lang.String name,
                              java.io.Reader is,
                              org.apache.commons.betwixt.io.BeanReader reader)
                       throws javax.xml.parsers.ParserConfigurationException,
                              org.xml.sax.SAXException,
                              java.io.IOException,
                              ScarabException
Do actual issue insert. Assumes issues passed have already been validated. If they haven't been, could damage scarab.

Parameters:
name - Name to use in log messages (E.g. filename). May be null.
is - Input stream of xml to insert.
reader - ScarabIssues bean reader instance.
Returns:
The instance of scarabissues we inserted in case you need to display info about the issues inserted.
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
ScarabException

getScarabIssuesBeanReader

public ScarabIssues getScarabIssuesBeanReader()
Get instance of the ScarabIssues used importing. You'd use this method to get at the instance of scarab issues used importing for case where you want to print out info on the import thats just happened. Call after a successful import. Calling before will give undefined results.

Returns:
Instance of ScarabIssues we ran the import with.

createScarabIssuesBeanReader

protected org.apache.commons.betwixt.io.BeanReader createScarabIssuesBeanReader()
                                                                         throws javax.xml.parsers.ParserConfigurationException,
                                                                                java.beans.IntrospectionException,
                                                                                org.xml.sax.SAXNotRecognizedException,
                                                                                org.xml.sax.SAXNotSupportedException
Return a bean reader for ScarabIssue.

Returns:
A bean reader.
Throws:
javax.xml.parsers.ParserConfigurationException
java.beans.IntrospectionException
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException

createXMLIntrospector

protected org.apache.commons.betwixt.XMLIntrospector createXMLIntrospector()

write

protected void write(java.lang.Object bean,
                     java.io.Writer out)
              throws java.io.IOException,
                     org.xml.sax.SAXException,
                     java.beans.IntrospectionException
Method to output the bean object as XML. Not used right now.

Throws:
java.io.IOException
org.xml.sax.SAXException
java.beans.IntrospectionException

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXParseException
Receive notification of a recoverable error.

Specified by:
error in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXParseException

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXParseException
Receive notification of a non-recoverable error.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXParseException

warning

public void warning(org.xml.sax.SAXParseException e)
Receive notification of a warning.

Specified by:
warning in interface org.xml.sax.ErrorHandler


Copyright © 2000-2004 Tigris.org. All Rights Reserved.