org.fcrepo.client.batch
Class BatchModifyParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.fcrepo.client.batch.BatchModifyParser
All Implemented Interfaces:
Constants, ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class BatchModifyParser
extends DefaultHandler
implements Constants

Parses a stream of batch modify directives and makes appropriate calls to the a Fedora server. The parsing is configured to parse directives in the file sequentially. Logs are written for each successful and failed directive that is processed. Recoverable(non-fatal) errors are written to the log file and processing continues. Catastrophic errors will cause parsing to halt and set the count of failed directives to -1 indicating that parsing was halted prior to the end of the file. In this case the logs will contain all directives processed up to the point of failure.

Author:
Ross Wayland

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.fcrepo.common.Constants
Constants.FedoraHome
 
Field Summary
 
Fields inherited from interface org.fcrepo.common.Constants
ACCESS, ACTION, API, ATOM_APIM1_0, ATOM_ZIP1_1, ATOM1_1, AUDIT, AUDIT1_0, BATCH_MODIFY, BATCH_MODIFY1_1, BE_SECURITY, BE_SECURITY1_0, BINDING_SPEC, DATASTREAM, DC, DISSEMINATOR, DS_COMPOSITE_MODEL, DS_COMPOSITE_MODEL1_0, DS_INPUT_SPEC1_0, DS_INPUT_SPEC1_1, ENVIRONMENT, FCFG, FEDORA, FEDORA_APP_CONTEXT_NAME, FEDORA_DEFAULT_APP_CONTEXT, FEDORA_HOME, FOXML, FOXML1_0, FOXML1_0_LEGACY, FOXML1_1, HTTP_REQUEST, MANAGEMENT, METHOD_MAP, METS, METS_EXT, METS_EXT1_0, METS_EXT1_0_LEGACY, METS_EXT1_1, MODEL, MULGARA, OAI_DC, OAI_DC2_0, OAI_FRIENDS, OAI_FRIENDS2_0, OAI_IDENTIFIER, OAI_IDENTIFIER2_0, OAI_PMH, OAI_PMH2_0, OAI_PROV, OAI_PROV2_0, OBJ_DATASTREAMS1_0, OBJ_HISTORY1_0, OBJ_ITEMS1_0, OBJ_METHODS1_0, OBJ_PROFILE1_0, OBJ_VALIDATION1_0, OBJECT, OLD_XLINK, PID_LIST1_0, RDF, RDF_XSD, RECOVERY, RELS_EXT, RELS_EXT1_0, RELS_INT1_0, REPO_DESC1_0, RESOURCE, SDEF, SDEF_METHOD_MAP1_0, SDEP, SDEP_METHOD_MAP1_0, SDEP_METHOD_MAP1_1, SERVICE_PROFILE, SOAP, SOAP_ENC, SUBJECT, TYPES, VIEW, WSDL, WSDL_HTTP, WSDL_MIME, XACML_POLICY, XACML_POLICY1_0, XLINK, XML_XSD, XMLNS, XSI
 
Constructor Summary
BatchModifyParser(Uploader UPLOADER, FedoraAPIMMTOM APIM, FedoraAPIAMTOM APIA, InputStream in, PrintStream out)
           Constructor allows this class to initiate the parsing.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endElement(String namespaceURI, String localName, String qName)
           
static Map getDeploymentLabelMap(String sDefPID)
          Get a map of pid-to-label of service deployments that implement the service defined by the indicated definition.
 int getFailedCount()
           Get the count of failed directives.
static Map getServiceLabelMap()
           
 int getSucceededCount()
           Get the count of successful directives.
static void main(String[] args)
           Main method for testing only.
 void skippedEntity(String name)
           
 void startElement(String namespaceURI, String localName, String qName, Attributes attrs)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BatchModifyParser

public BatchModifyParser(Uploader UPLOADER,
                         FedoraAPIMMTOM APIM,
                         FedoraAPIAMTOM APIA,
                         InputStream in,
                         PrintStream out)

Constructor allows this class to initiate the parsing.

Parameters:
UPLOADER - - An instance of Uploader.
APIM - - An instance of FedoraAPIM.
APIA - - An instance of Fedora APIA.
in - - An input stream containing the xml to be parsed.
out - - A print stream used for writing log info.
Method Detail

getFailedCount

public int getFailedCount()

Get the count of failed directives. Note that a failed count value of -1 indicates that a fatal parsing error occurred before all directives could be parsed and the number of unprocessed directives is indeterminate. The log file will contain details on how many directives were successfully processed before the fatal error was encountered.

Returns:
The count of failed directives.

getSucceededCount

public int getSucceededCount()

Get the count of successful directives.

Returns:
The count of successful directives.

skippedEntity

public void skippedEntity(String name)
                   throws SAXException
Specified by:
skippedEntity in interface ContentHandler
Overrides:
skippedEntity in class DefaultHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Throws:
SAXException

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes attrs)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

getServiceLabelMap

public static Map getServiceLabelMap()
                              throws IOException
Throws:
IOException

getDeploymentLabelMap

public static Map getDeploymentLabelMap(String sDefPID)
                                 throws IOException
Get a map of pid-to-label of service deployments that implement the service defined by the indicated definition.

Parameters:
sDefPID - PID of the associated service defintion object.
Returns:
A list of the service deployment labels.
Throws:
IOException - If an error occurs in retrieving the list of labels.

main

public static void main(String[] args)

Main method for testing only.

Parameters:
args - Array of input parms consisting of hostname, port, username, password, protocol, directives, log.


Copyright © 2012 DuraSpace. All Rights Reserved.