|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.ucsb.nceas.metacat.DocumentImpl
A class that represents an XML document. It can be created with a simple document identifier from a database connection. It also will write an XML text document to a database connection using SAX.
Constructor Summary | |
DocumentImpl(DBConnection conn,
long rootNodeId,
java.lang.String docName,
java.lang.String docType,
java.lang.String docId,
java.lang.String newRevision,
java.lang.String action,
java.lang.String user,
java.lang.String pub,
java.lang.String catalogId,
int serverCode)
Construct a new document instance, writing the contents to the database. |
|
DocumentImpl(java.lang.String docid)
Constructor, creates document from database connection, used for reading the document |
|
DocumentImpl(java.lang.String docid,
boolean readNodes)
Constructor used to create a document and read the document information from the database. |
Method Summary | |
static void |
delete(java.lang.String accnum,
java.lang.String user,
java.lang.String[] groups)
Delete an XML file from the database (actually, just make it a revision in the xml_revisions table) |
java.lang.String |
getCreateDate()
get the creation date |
static boolean |
getDataFileLockGrant(java.lang.String accnum)
|
static boolean |
getDataFileLockGrant(java.lang.String accnum,
int serverCode)
The method will check if metacat can get data file lock grant If server code is 1, it get. |
java.lang.String |
getDocHomeServer()
|
java.lang.String |
getDocID()
Get the document identifier (docid) |
java.lang.String |
getDocname()
get the document name |
java.lang.String |
getDoctype()
get the document type (which is the PublicID) |
java.lang.String |
getPublicaccess()
|
int |
getRev()
|
long |
getRootNodeID()
get the root node identifier |
int |
getServerlocation()
|
java.lang.String |
getSystemID()
get the system identifier |
java.lang.String |
getUpdateDate()
get the update date |
java.lang.String |
getUserowner()
|
java.lang.String |
getUserupdated()
|
static boolean |
hasReadPermission(java.lang.String user,
java.lang.String[] groups,
java.lang.String docId)
Check for "READ" permission base on docid, user and group |
static void |
main(java.lang.String[] args)
the main routine used to test the DBWriter utility. |
java.lang.String |
readUsingSlowAlgorithm()
Get a text representation of the XML document as a string This older algorithm uses a recursive tree of Objects to represent the nodes of the tree. |
static void |
registerDocument(java.lang.String docname,
java.lang.String doctype,
java.lang.String accnum,
java.lang.String user)
This method will be call in handleUploadRequest in MetacatServlet class |
static void |
registerDocument(java.lang.String docname,
java.lang.String doctype,
java.lang.String accnum,
java.lang.String user,
int serverCode)
Register a document that resides on the filesystem with the database. |
static void |
registerDocumentInReplication(java.lang.String docname,
java.lang.String doctype,
java.lang.String accnum,
java.lang.String user,
int serverCode)
Register a document that resides on the filesystem with the database. |
java.lang.String |
toString()
Print a string representation of the XML document |
void |
toXml(java.io.Writer pw)
Print a text representation of the XML document to a Writer |
static java.lang.String |
write(DBConnection conn,
java.io.Reader xml,
java.lang.String pub,
java.io.Reader dtd,
java.lang.String action,
java.lang.String docid,
java.lang.String user,
java.lang.String[] groups,
boolean validate)
|
static java.lang.String |
write(DBConnection conn,
java.io.Reader xml,
java.lang.String pub,
java.io.Reader dtd,
java.lang.String action,
java.lang.String accnum,
java.lang.String user,
java.lang.String[] groups,
int serverCode,
boolean override,
boolean validate)
Write an XML file to the database, given a Reader |
static java.lang.String |
write(DBConnection conn,
java.io.Reader xml,
java.lang.String action,
java.lang.String docid,
java.lang.String user,
java.lang.String[] groups,
int serverCode)
|
static java.lang.String |
write(DBConnection conn,
java.io.Reader xml,
java.lang.String pub,
java.lang.String action,
java.lang.String docid,
java.lang.String user,
java.lang.String[] groups)
|
static java.lang.String |
write(DBConnection conn,
java.io.Reader xml,
java.lang.String pub,
java.lang.String action,
java.lang.String docid,
java.lang.String user,
java.lang.String[] groups,
int serverCode)
|
static java.lang.String |
write(DBConnection conn,
java.io.Reader xml,
java.lang.String pub,
java.lang.String action,
java.lang.String docid,
java.lang.String user,
java.lang.String[] groups,
int serverCode,
boolean override)
|
static java.lang.String |
write(DBConnection conn,
java.lang.String filename,
java.lang.String pub,
java.lang.String dtdfilename,
java.lang.String action,
java.lang.String docid,
java.lang.String user,
java.lang.String[] groups)
Write an XML file to the database, given a filename |
static void |
writeDataFileInReplication(java.io.InputStream input,
java.lang.String filePath,
java.lang.String docname,
java.lang.String doctype,
java.lang.String accnum,
java.lang.String user,
java.lang.String docHomeServer,
java.lang.String notificationServer)
This method will register a data file entry in xml_documents and save a data file input Stream into file system.. |
static java.lang.String |
writeReplication(DBConnection conn,
java.io.Reader xml,
java.lang.String pub,
java.io.Reader dtd,
java.lang.String action,
java.lang.String accnum,
java.lang.String user,
java.lang.String[] groups,
java.lang.String homeServer,
boolean validate,
java.lang.String notifyServer)
Write an XML file to the database during replication |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DocumentImpl(java.lang.String docid, boolean readNodes) throws McdbException
conn
- the database connection from which to read the documentdocid
- the identifier of the document to be createdreadNodes
- flag indicating whether the xmlnodes should be readpublic DocumentImpl(java.lang.String docid) throws McdbException
conn
- the database connection from which to read the documentdocid
- the identifier of the document to be createdpublic DocumentImpl(DBConnection conn, long rootNodeId, java.lang.String docName, java.lang.String docType, java.lang.String docId, java.lang.String newRevision, java.lang.String action, java.lang.String user, java.lang.String pub, java.lang.String catalogId, int serverCode) throws java.sql.SQLException, java.lang.Exception
conn
- the JDBC Connection to which all information is writtenrootnodeid
- - sequence id of the root node in the documentdocname
- - the name of DTD, i.e. the name immediately following
the DOCTYPE keyword ( should be the root element name ) or
the root element name if no DOCTYPE declaration provided
(Oracle's and IBM parsers are not aware if it is not the
root element name)doctype
- - Public ID of the DTD, i.e. the name immediately
following the PUBLIC keyword in DOCTYPE declaration or
the docname if no Public ID provided or
null if no DOCTYPE declaration provideddocid
- the docid to use for the UPDATE, no version numberversion,
- need to be updateaction
- the action to be performed (INSERT OR UPDATE)user
- the user that owns the documentpub
- flag for public "read" access on documentserverCode
- the serverid from xml_replication on which this document
resides.Method Detail |
public static void registerDocument(java.lang.String docname, java.lang.String doctype, java.lang.String accnum, java.lang.String user) throws java.sql.SQLException, AccessionNumberException, java.lang.Exception
public static void registerDocument(java.lang.String docname, java.lang.String doctype, java.lang.String accnum, java.lang.String user, int serverCode) throws java.sql.SQLException, AccessionNumberException, java.lang.Exception
conn
- the JDBC Connection to which all information is writtendocname
- - the name of DTD, i.e. the name immediately following
the DOCTYPE keyword ( should be the root element name ) or
the root element name if no DOCTYPE declaration provided
(Oracle's and IBM parsers are not aware if it is not the
root element name)doctype
- - Public ID of the DTD, i.e. the name immediately
following the PUBLIC keyword in DOCTYPE declaration or
the docname if no Public ID provided or
null if no DOCTYPE declaration providedaccnum
- the accession number to use for the INSERT OR UPDATE, which
includes a revision number for this revision of the document
(e.g., knb.1.1)user
- the user that owns the documentserverCode
- the serverid from xml_replication on which this document
resides.public static void registerDocumentInReplication(java.lang.String docname, java.lang.String doctype, java.lang.String accnum, java.lang.String user, int serverCode) throws java.sql.SQLException, AccessionNumberException, java.lang.Exception
conn
- the JDBC Connection to which all information is writtendocname
- - the name of DTD, i.e. the name immediately following
the DOCTYPE keyword ( should be the root element name ) or
the root element name if no DOCTYPE declaration provided
(Oracle's and IBM parsers are not aware if it is not the
root element name)doctype
- - Public ID of the DTD, i.e. the name immediately
following the PUBLIC keyword in DOCTYPE declaration or
the docname if no Public ID provided or
null if no DOCTYPE declaration providedaccnum
- the accession number to use for the INSERT OR UPDATE, which
includes a revision number for this revision of the document
(e.g., knb.1.1)user
- the user that owns the documentserverCode
- the serverid from xml_replication on which this document
resides.public static void writeDataFileInReplication(java.io.InputStream input, java.lang.String filePath, java.lang.String docname, java.lang.String doctype, java.lang.String accnum, java.lang.String user, java.lang.String docHomeServer, java.lang.String notificationServer) throws java.sql.SQLException, AccessionNumberException, java.lang.Exception
input,
- the input stream which contain the file content.,
- the input stream which contain the file contentdocname
- - the name of DTD, for data file, it is a docid number.doctype
- - "BIN" for data fileaccnum
- the accession number to use for the INSERT OR UPDATE, which
includes a revision number for this revision of the document
(e.g., knb.1.1)user
- the user that owns the documentdocHomeServer,
- the home server of the docidnotificationServer,
- the server to notify force replication info to
local metacatpublic static boolean getDataFileLockGrant(java.lang.String accnum) throws java.lang.Exception
public static boolean getDataFileLockGrant(java.lang.String accnum, int serverCode) throws java.lang.Exception
accnum,
- the ID of the documentaction,
- the action to the documentserverCode,
- the server location codepublic java.lang.String getDocname()
public java.lang.String getDoctype()
public java.lang.String getSystemID()
public long getRootNodeID()
public java.lang.String getCreateDate()
public java.lang.String getUpdateDate()
public java.lang.String getDocID()
public java.lang.String getUserowner()
public java.lang.String getUserupdated()
public int getServerlocation()
public java.lang.String getDocHomeServer()
public java.lang.String getPublicaccess()
public int getRev()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String readUsingSlowAlgorithm() throws McdbException
public void toXml(java.io.Writer pw) throws McdbException
pw
- the Writer to which we print the documentpublic static java.lang.String write(DBConnection conn, java.lang.String filename, java.lang.String pub, java.lang.String dtdfilename, java.lang.String action, java.lang.String docid, java.lang.String user, java.lang.String[] groups) throws java.lang.Exception
conn
- the JDBC connection to the databasefilename
- the filename to be loaded into the databasepub
- flag for public "read" access on documentdtdfilename
- the dtd to be uploaded on server's file systemaction
- the action to be performed (INSERT OR UPDATE)docid
- the docid to use for the INSERT OR UPDATEuser
- the user that owns the documentgroups
- the groups to which user belongspublic static java.lang.String write(DBConnection conn, java.io.Reader xml, java.lang.String pub, java.io.Reader dtd, java.lang.String action, java.lang.String docid, java.lang.String user, java.lang.String[] groups, boolean validate) throws java.lang.Exception
public static java.lang.String write(DBConnection conn, java.io.Reader xml, java.lang.String pub, java.lang.String action, java.lang.String docid, java.lang.String user, java.lang.String[] groups) throws java.lang.Exception
public static java.lang.String write(DBConnection conn, java.io.Reader xml, java.lang.String action, java.lang.String docid, java.lang.String user, java.lang.String[] groups, int serverCode) throws java.lang.Exception
public static java.lang.String write(DBConnection conn, java.io.Reader xml, java.lang.String pub, java.lang.String action, java.lang.String docid, java.lang.String user, java.lang.String[] groups, int serverCode) throws java.lang.Exception
public static java.lang.String write(DBConnection conn, java.io.Reader xml, java.lang.String pub, java.lang.String action, java.lang.String docid, java.lang.String user, java.lang.String[] groups, int serverCode, boolean override) throws java.lang.Exception
public static java.lang.String write(DBConnection conn, java.io.Reader xml, java.lang.String pub, java.io.Reader dtd, java.lang.String action, java.lang.String accnum, java.lang.String user, java.lang.String[] groups, int serverCode, boolean override, boolean validate) throws java.lang.Exception
conn
- the JDBC connection to the databasexml
- the xml stream to be loaded into the databasepub
- flag for public "read" access on xml documentdtd
- the dtd to be uploaded on server's file systemaction
- the action to be performed (INSERT or UPDATE)accnum
- the docid + rev# to use on INSERT or UPDATEuser
- the user that owns the documentgroups
- the groups to which user belongsserverCode
- the serverid from xml_replication on which this document
resides.override
- flag to stop insert replication checking.
if override = true then a document not belonging to the local server
will not be checked upon update for a file lock.
if override = false then a document not from this server, upon
update will be locked and version checked.public static java.lang.String writeReplication(DBConnection conn, java.io.Reader xml, java.lang.String pub, java.io.Reader dtd, java.lang.String action, java.lang.String accnum, java.lang.String user, java.lang.String[] groups, java.lang.String homeServer, boolean validate, java.lang.String notifyServer) throws java.lang.Exception
conn
- the JDBC connection to the databasexml
- the xml stream to be loaded into the databasepub
- flag for public "read" access on xml documentdtd
- the dtd to be uploaded on server's file systemaction
- the action to be performed (INSERT or UPDATE)accnum
- the docid + rev# to use on INSERT or UPDATEuser
- the user that owns the documentgroups
- the groups to which user belongshomeServer
- the name of server which the document origanlly createvalidate,
- if the xml document is valid or notnotifyServer,
- the server which notify local server the force
replication commandpublic static void delete(java.lang.String accnum, java.lang.String user, java.lang.String[] groups) throws java.lang.Exception
docid
- the ID of the document to be deleted from the databasepublic static boolean hasReadPermission(java.lang.String user, java.lang.String[] groups, java.lang.String docId) throws java.sql.SQLException, java.lang.Exception
public static void main(java.lang.String[] args)
Usage: java DocumentImpl <-f filename -a action -d docid>
filename
- the filename to be loaded into the databaseaction
- the action to perform (READ, INSERT, UPDATE, DELETE)docid
- the id of the document to process
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |