fedora.server.validation
Class RelsExtValidator

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by fedora.server.validation.RelsExtValidator
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class RelsExtValidator
extends org.xml.sax.helpers.DefaultHandler

This class will validate relationship metadata that may exist in a digital object. The validator will SAX parse the content of the RELS-EXT datastream which must be an RDF stream that asserts relationships for a digital object. The validator will enforce the following restrictions on the RDF stream: 1. The RDF must follow a prescribed RDF/XML authoring style where there is ONE subject encoded as an RDF with an RDF 'about' attribute containing a digital object URI. The sub-elements are the relationship properties of the subject. Each relationship may refer to any resource (identified by URI) via an RDF 'resource' attribute, or a literal. Relationship assertions can be from the default Fedora relationship ontology, or from other namespaces. For example: Bob Smith 2. There must be only ONE RDF in the RELS-EXT datastream. 3. There must be NO nesting of assertions. In terms of XML depth, the RDF root element is considered depth of 0. Then, the RDF must be at depth of 1, and the relationship properties must exist at depth of 2. That's it. 4. The RDF 'about' attribute of the RDF must be the URI of the digital object in which the RELS-EXT datastream resides. This means that all relationships are FROM "this" object to other objects. 5. If the target of the statement is a resource (identified by a URI), the RDF 'resource' attribute must specify a syntactically valid, absolute URI. 6. The RDF 'resource' attribute of a relationship assertion must NOT be the URI of the digital object that is the subject of the relationships. In other words, NO SELF-REFERENTIAL relationships. 7. There must NOT be any assertion of properties from the DC namespace or from the Fedora object properties namespaces (model and view). This is because these assertions exist elsewhere in a Fedora digital object and we do not want duplication. The RELS-EXT datasream is reserved for relationship metadata.

Version:
$Id: RelsExtValidator.java 6425 2007-12-17 17:17:27Z pangloss $
Author:
payette@cs.cornell.edu

Constructor Summary
RelsExtValidator(java.lang.String characterEncoding, boolean validate)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void deserialize(java.io.InputStream relsDS, java.lang.String doURI)
           
 void endElement(java.lang.String nsURI, java.lang.String localName, java.lang.String qName)
           
static RelsExtValidator getInstance()
           
 void startElement(java.lang.String nsURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes a)
           
static void validate(PID pid, java.io.InputStream datastream)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RelsExtValidator

public RelsExtValidator(java.lang.String characterEncoding,
                        boolean validate)
                 throws javax.xml.parsers.ParserConfigurationException,
                        org.xml.sax.SAXException,
                        java.io.UnsupportedEncodingException
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.UnsupportedEncodingException
Method Detail

getInstance

public static RelsExtValidator getInstance()
                                    throws RepositoryConfigurationException
Throws:
RepositoryConfigurationException

deserialize

public void deserialize(java.io.InputStream relsDS,
                        java.lang.String doURI)
                 throws StreamIOException,
                        org.xml.sax.SAXException
Throws:
StreamIOException
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String nsURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes a)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

endElement

public void endElement(java.lang.String nsURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

validate

public static void validate(PID pid,
                            java.io.InputStream datastream)
                     throws ValidationException
Throws:
ValidationException