edu.ucsb.nceas.metacat
Class Eml200SAXHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
edu.ucsb.nceas.metacat.DBSAXHandler
edu.ucsb.nceas.metacat.Eml200SAXHandler
- All Implemented Interfaces:
- AccessControlInterface, org.xml.sax.ContentHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler, java.lang.Runnable
- public class Eml200SAXHandler
- extends DBSAXHandler
- implements AccessControlInterface
A database aware Class implementing callback bethods for the SAX parser to
call when processing the XML stream and generating events
Here is the rules for user which has write permission in top level access
rules(he can update metadata but can't update access module) try to update
a document:
1. Checking access part (both in top level and addtional level, node by node)
If something was modified, reject the document. Note: for additional part
The access subtree startnode starts at "" rather than .
This is because make sure ids wouldn't be mess up by user.
2. Checking ids in additional access part, if they points a distribution
module with online or inline. If some ids don't, reject the documents.
3. For inline distribution:
If user can't read the inline data, the empty string in inline element
will be send to user if he read this eml document(user has read access
at top level - metadata, but user couldn't read inline data).
Here is some intrested senario: If user does have read and write
permission in top level access rules(for metadata)
but 1) user doesn't have read and write permission in inline data block,
so if user update the document with some inline data rather than
empty string in same inline data block(same distribution inline id),
this means user updated the inline data. So the document should be
rejected.
2) user doesn't have read permssion, but has write premission in
inline data block. If user send back inline data block with empty
string, we will think user doesn't update inline data and we will
copy old inline data back to the new one. If user send something
else, we will overwrite the old inline data by new one.
4. For online distribution:
It is easy than inline distribution. When the user try to change a external
document id, we will checking if the user have "all" permission to it.
If don't have, reject the document. If have, delete the old rules and apply
The new rules.
Here is some info about addtional access rules ( data object rules):
The data access rules format looks like:
100
300
rulesone
200
rulesthree
Because eml additionalMetadata is (describes+, any) and any ocurrence is 1.
So following xml will be rejected by xerces.
100
300
....
rulesone
Fields inherited from class edu.ucsb.nceas.metacat.DBSAXHandler |
action, atFirstElement, connection, currentDocument, docid, docname, doctype, ECOGRID, endNodeId, groups, hitTextNode, INDEXDELAY, MAXDATACHARS, namespaces, nodeIndex, nodeStack, processingDTD, pub, revision, rootNode, serverCode, systemid, textBuffer, textBufferStack, user, xmlIndex |
Fields inherited from interface edu.ucsb.nceas.metacat.AccessControlInterface |
ACCESS, ACLID, ALL, ALLOW, ALLOWFIRST, ALLSTRING, CHMOD, CHMODSTRING, DENY, DENYFIRST, PERMISSION, PRINCIPAL, PUBLIC, READ, READSTRING, WRITE, WRITESTRING |
Constructor Summary |
Eml200SAXHandler(DBConnection conn,
java.lang.String action,
java.lang.String docid,
java.lang.String revision,
java.lang.String user,
java.lang.String[] groups,
java.lang.String pub,
int serverCode)
Construct an instance of the handler class In this constructor, user can
specify the version need to upadate |
Method Summary |
void |
characters(char[] cbuf,
int start,
int len)
SAX Handler that is called for each XML text node |
void |
comment(char[] ch,
int start,
int length)
SAX Handler that receives notification of comments in the DTD |
boolean |
compareInlineDataFiles(java.lang.String oldFileName,
java.lang.String newFileName)
|
void |
copyInlineFile(java.lang.String inlineDistributionId,
java.lang.String newFileName)
|
void |
deleteInlineFiles()
|
void |
endDocument()
SAX Handler that receives notification of end of the document |
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
SAX Handler that is called at the end of each XML element |
void |
ignorableWhitespace(char[] cbuf,
int start,
int len)
SAX Handler that is called for each XML text node that is Ignorable
white space |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
SAX Handler called once for each processing instruction found: node that
PI may occur before or after the root element. |
static java.io.Reader |
readInlineDataFromFileSystem(java.lang.String fileName)
|
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
SAX Handler that is called at the start of each XML element |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
SAX Handler that is called at the start of Namespace |
Methods inherited from class edu.ucsb.nceas.metacat.DBSAXHandler |
attributeDecl, elementDecl, endCDATA, endDTD, endEntity, error, externalEntityDecl, fatalError, getDocname, internalEntityDecl, processingDTD, run, startCDATA, startDocument, startDTD, startEntity, warning, writeTextForDBSAXNode |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
endPrefixMapping, notationDecl, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INLINE
public static final java.lang.String INLINE
- See Also:
- Constant Field Values
TOPLEVEL
public static final java.lang.String TOPLEVEL
- See Also:
- Constant Field Values
DATAACCESSLEVEL
public static final java.lang.String DATAACCESSLEVEL
- See Also:
- Constant Field Values
Eml200SAXHandler
public Eml200SAXHandler(DBConnection conn,
java.lang.String action,
java.lang.String docid,
java.lang.String revision,
java.lang.String user,
java.lang.String[] groups,
java.lang.String pub,
int serverCode)
throws org.xml.sax.SAXException
- Construct an instance of the handler class In this constructor, user can
specify the version need to upadate
- Parameters:
conn
- the JDBC connection to which information is writtenaction
- - "INSERT" or "UPDATE"docid
- to be inserted or updated into JDBC connectionuser
- the user connected to MetaCat servlet and owns the documentgroups
- the groups to which user belongspub
- flag for public "read" access on documentserverCode
- the serverid from xml_replication on which this
document resides.
startElement
public void startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
throws org.xml.sax.SAXException
- SAX Handler that is called at the start of each XML element
- Specified by:
startElement
in interface org.xml.sax.ContentHandler
- Overrides:
startElement
in class DBSAXHandler
- Throws:
org.xml.sax.SAXException
characters
public void characters(char[] cbuf,
int start,
int len)
throws org.xml.sax.SAXException
- SAX Handler that is called for each XML text node
- Specified by:
characters
in interface org.xml.sax.ContentHandler
- Overrides:
characters
in class DBSAXHandler
- Throws:
org.xml.sax.SAXException
endElement
public void endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
throws org.xml.sax.SAXException
- SAX Handler that is called at the end of each XML element
- Specified by:
endElement
in interface org.xml.sax.ContentHandler
- Overrides:
endElement
in class DBSAXHandler
- Throws:
org.xml.sax.SAXException
comment
public void comment(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
- SAX Handler that receives notification of comments in the DTD
- Specified by:
comment
in interface org.xml.sax.ext.LexicalHandler
- Overrides:
comment
in class DBSAXHandler
- Throws:
org.xml.sax.SAXException
processingInstruction
public void processingInstruction(java.lang.String target,
java.lang.String data)
throws org.xml.sax.SAXException
- SAX Handler called once for each processing instruction found: node that
PI may occur before or after the root element.
- Specified by:
processingInstruction
in interface org.xml.sax.ContentHandler
- Overrides:
processingInstruction
in class DBSAXHandler
- Throws:
org.xml.sax.SAXException
startPrefixMapping
public void startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
throws org.xml.sax.SAXException
- SAX Handler that is called at the start of Namespace
- Specified by:
startPrefixMapping
in interface org.xml.sax.ContentHandler
- Overrides:
startPrefixMapping
in class DBSAXHandler
- Throws:
org.xml.sax.SAXException
ignorableWhitespace
public void ignorableWhitespace(char[] cbuf,
int start,
int len)
throws org.xml.sax.SAXException
- SAX Handler that is called for each XML text node that is Ignorable
white space
- Specified by:
ignorableWhitespace
in interface org.xml.sax.ContentHandler
- Overrides:
ignorableWhitespace
in class DBSAXHandler
- Throws:
org.xml.sax.SAXException
endDocument
public void endDocument()
throws org.xml.sax.SAXException
- SAX Handler that receives notification of end of the document
- Specified by:
endDocument
in interface org.xml.sax.ContentHandler
- Overrides:
endDocument
in class DBSAXHandler
- Throws:
org.xml.sax.SAXException
compareInlineDataFiles
public boolean compareInlineDataFiles(java.lang.String oldFileName,
java.lang.String newFileName)
throws McdbException
- Throws:
McdbException
copyInlineFile
public void copyInlineFile(java.lang.String inlineDistributionId,
java.lang.String newFileName)
throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
deleteInlineFiles
public void deleteInlineFiles()
readInlineDataFromFileSystem
public static java.io.Reader readInlineDataFromFileSystem(java.lang.String fileName)
throws McdbException
- Throws:
McdbException
Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.