fedora.server.validation
Class DOValidatorImpl

java.lang.Object
  extended by fedora.server.validation.DOValidatorImpl
All Implemented Interfaces:
DOValidator

public class DOValidatorImpl
extends java.lang.Object
implements DOValidator

Title: DOValidatorImpl.java

Description: The implementation of the digital object validation module (see DOValidator.class and DOValidatorModule.class). The validator operates on digital object XML files encoded in one of the Fedora-supported encoding formats (i.e., FOXML, Fedora METS, and possibly others in the future). The following types of validation can be run:

   0=VALDIATE_ALL : All validation will be done.
   1=VALIDATE_XML_SCHEMA : the digital object will be validated against 
                                the the appropriate XML Schema. An ObjectValidityException 
                                will be thrown if the object fails the schema test.
   2=VALIDATE_SCHEMATRON : the digital object will be validated 
                                against a set of rules expressed by a Schematron schema.  
                                These rules are beyond what can be expressed in XML Schema.  
                                The Schematron schema expresses rules for different phases
                                of the object. There are rules appropriate to a digital 
                                object when it is first ingested into the repository 
                                (ingest phase). There are additional rules that must be met 
                                before a digital object is considered valid for permanent 
                                storage in the repository (completed phase). These rules 
                                pertain to aspects of the object that are system assigned,
                                such as created dates and state codes.
                                An ObjectValidityException will be thrown if the object fails 
                                the Fedora rules test.
 

Version:
$Id: DOValidatorImpl.java 7796 2008-10-21 15:49:14Z pangloss $
Author:
payette@cs.cornell.edu

Field Summary
protected static boolean debug
           
protected static java.lang.String schematronPreprocessorPath
          Configuration variable: schematronPreprocessorPath is the Schematron stylesheet that is used to transform a Schematron schema into a validating stylesheet based on the rules in the schema.
protected static java.lang.String schematronSchemaPath
          Configuration variable: schematronSchemaPath is the Schematron schema that expresses Fedora-specific validation rules.
protected static java.lang.String tempDir
          Configuration variable: tempdir is a working area for validation
static int VALIDATE_ALL
           
static int VALIDATE_SCHEMATRON
           
static int VALIDATE_XML_SCHEMA
           
protected static java.lang.String xmlSchemaPath
          Configuration variable: xmlSchemaPath is the location of the XML Schema.
 
Constructor Summary
DOValidatorImpl(java.lang.String tempDir, java.util.Map xmlSchemaMap, java.lang.String schematronPreprocessorPath, java.util.Map ruleSchemaMap)
          Constructs a new DOValidatorImpl to support all forms of digital object validation, using specified values for configuration values.
 
Method Summary
 void validate(java.io.File objectAsFile, java.lang.String format, int validationType, java.lang.String phase)
          Validates a digital object.
 void validate(java.io.InputStream objectAsStream, java.lang.String format, int validationType, java.lang.String phase)
          Validates a digital object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected static boolean debug

VALIDATE_ALL

public static final int VALIDATE_ALL
See Also:
Constant Field Values

VALIDATE_XML_SCHEMA

public static final int VALIDATE_XML_SCHEMA
See Also:
Constant Field Values

VALIDATE_SCHEMATRON

public static final int VALIDATE_SCHEMATRON
See Also:
Constant Field Values

tempDir

protected static java.lang.String tempDir
Configuration variable: tempdir is a working area for validation


xmlSchemaPath

protected static java.lang.String xmlSchemaPath
Configuration variable: xmlSchemaPath is the location of the XML Schema.


schematronPreprocessorPath

protected static java.lang.String schematronPreprocessorPath
Configuration variable: schematronPreprocessorPath is the Schematron stylesheet that is used to transform a Schematron schema into a validating stylesheet based on the rules in the schema.


schematronSchemaPath

protected static java.lang.String schematronSchemaPath
Configuration variable: schematronSchemaPath is the Schematron schema that expresses Fedora-specific validation rules. It is transformed into a validating stylesheet by the Schematron preprocessing stylesheet.

Constructor Detail

DOValidatorImpl

public DOValidatorImpl(java.lang.String tempDir,
                       java.util.Map xmlSchemaMap,
                       java.lang.String schematronPreprocessorPath,
                       java.util.Map ruleSchemaMap)
                throws ServerException

Constructs a new DOValidatorImpl to support all forms of digital object validation, using specified values for configuration values.

Any parameter may be given as null, in which case the default value is assumed.

Parameters:
tempDir - Working area for validation, default is temp/
xmlSchemaMap - Location of XML Schemas (W3 Schema) configured with Fedora (see Fedora.fcfg). Current options are xsd/foxml1-0.xsd for FOXML or xsd/mets-fedora-ext.xsd for METS (Fedora extension)
schematronPreprocessorPath - Location of the Schematron pre-processing stylesheet configured with Fedora.
ruleSchemaMap - Location of rule schemas (Schematron), configured with Fedora (see Fedora.fcfg). Current options are schematron/foxmlRules1-0.xml for FOXML or schematron/metsExtRules1-0.xml for METS
Throws:
ServerException - If construction fails for any reason.
Method Detail

validate

public void validate(java.io.InputStream objectAsStream,
                     java.lang.String format,
                     int validationType,
                     java.lang.String phase)
              throws ObjectValidityException

Validates a digital object.

Specified by:
validate in interface DOValidator
Parameters:
objectAsStream - The digital object provided as a stream.
validationType - The level of validation to perform on the digital object. This is an integer from 0-2 with the following meanings: 0 = VALIDATE_ALL (do all validation levels) 1 = VALIDATE_XML_SCHEMA (perform only XML Schema validation) 2 = VALIDATE_SCHEMATRON (perform only Schematron Rules validation)
phase - The stage in the workflow for which the validation should be contextualized. "ingest" = the object is encoded for ingest into the repository "store" = the object is encoded with all final assignments so that it is appropriate for storage as the authoritative serialization of the object.
Throws:
ObjectValidityException - If validation fails for any reason.
GeneralException - If validation fails for any reason.

validate

public void validate(java.io.File objectAsFile,
                     java.lang.String format,
                     int validationType,
                     java.lang.String phase)
              throws ObjectValidityException,
                     GeneralException

Validates a digital object.

Specified by:
validate in interface DOValidator
Parameters:
objectAsFile - The digital object provided as a file.
validationType - The level of validation to perform on the digital object. This is an integer from 0-2 with the following meanings: 0 = VALIDATE_ALL (do all validation levels) 1 = VALIDATE_XML_SCHEMA (perform only XML Schema validation) 2 = VALIDATE_SCHEMATRON (perform only Schematron Rules validation)
phase - The stage in the work flow for which the validation should be contextualized. "ingest" = the object is in the submission format for the ingest phase "store" = the object is in the authoritative format for the final storage phase
Throws:
ObjectValidityException - If validation fails for any reason.
GeneralException - If validation fails for any reason.