uk.co.lakesidetech.springxmldb.dao
Interface IResourceManageXMLDBDao

All Known Implementing Classes:
BaseResourceManageXMLDBDao

public interface IResourceManageXMLDBDao

Defines a Dao for the management of XML and binary files within a XML document such as inserting, updating, removing and retrieving documents and files from the database

Author:
Stuart Eccles

Method Summary
 java.lang.String insertUpdateBinaryFile(byte[] docBytes, java.lang.String docID, java.lang.String collectionPath)
          Insert or update a binary byte array into a XML database.
 java.lang.String insertUpdateFile(java.io.File file, java.lang.String docID, java.lang.String collectionPath)
          Insert or update a file (either XML or binary) from a File object to the database.
 java.lang.String insertUpdateInputStream(java.io.InputStream stream, java.lang.String docID, java.lang.String collectionPath)
          Insert or update information in a inputstream into a XML database.
 java.lang.String insertUpdateXMLDocument(org.w3c.dom.Document xmlDocument, java.lang.String docID, java.lang.String collectionPath)
          Insert or update a XML document from a supplied DOM object to the database.
 java.lang.String insertUpdateXMLDocument(java.io.File xmlDocument, java.lang.String docID, java.lang.String collectionPath)
          Insert or update a XML document from a File object to the database.
 java.lang.String insertUpdateXMLDocument(java.lang.String xmlDocument, java.lang.String docID, java.lang.String collectionPath)
          Insert or update a XML document specfied in the String supplied in the parameters.
 boolean removeDocument(java.lang.String docID, java.lang.String collectionPath)
          Remove a document (XML or binary) from a collection
 org.w3c.dom.Document retrieveDocumentAsDOM(java.lang.String docID, java.lang.String collectionPath)
          Retrieve an XML document as a w3c DOM object from a collection in the XML database
 org.xmldb.api.base.Resource retrieveDocumentAsResource(java.lang.String docID, java.lang.String collectionPath)
          Retrieve a XML:DB Resource which can be either a binary or XML document from a collection in the XML database
 java.lang.String retrieveDocumentAsString(java.lang.String docID, java.lang.String collectionPath)
          Retrieve an XML document as a String from a collection in the XML database
 

Method Detail

insertUpdateXMLDocument

public java.lang.String insertUpdateXMLDocument(java.lang.String xmlDocument,
                                                java.lang.String docID,
                                                java.lang.String collectionPath)
                                         throws XMLDBDataAccessException
Insert or update a XML document specfied in the String supplied in the parameters. If the supplied docID is null the dao will attempt to insert with a null id relying on the database to supply a generated ID. If given a docID the dao will attempt to find an existing document in the given collection path, if a document exists it will update that document otherwise it will insert a new document with the supplied id.

Parameters:
xmlDocument - A String of the XML document to insert/update
docID - The document ID to use
collectionPath - The collection path to insert under
Returns:
The ID of the document in the collection
Throws:
XMLDBDataAccessException - if anything goes wrong in the data access

insertUpdateFile

public java.lang.String insertUpdateFile(java.io.File file,
                                         java.lang.String docID,
                                         java.lang.String collectionPath)
                                  throws XMLDBDataAccessException
Insert or update a file (either XML or binary) from a File object to the database. If the supplied docID is null the dao will attempt to insert with a null id relying on the database to supply a generated ID. If given a docID the dao will attempt to find an existing document in the given collection path, if a document exists it will update that document otherwise it will insert a new document with the supplied id.

Parameters:
file - The File to insert/update
docID - The document ID to use
collectionPath - The collection path to insert under
Returns:
The ID of the document in the collection
Throws:
XMLDBDataAccessException - if anything goes wrong in the data access

insertUpdateXMLDocument

public java.lang.String insertUpdateXMLDocument(java.io.File xmlDocument,
                                                java.lang.String docID,
                                                java.lang.String collectionPath)
                                         throws XMLDBDataAccessException
Insert or update a XML document from a File object to the database. If the supplied docID is null the dao will attempt to insert with a null id relying on the database to supply a generated ID. If given a docID the dao will attempt to find an existing document in the given collection path, if a document exists it will update that document otherwise it will insert a new document with the supplied id.

Parameters:
xmlDocument - The File containing a XML document
docID - The document ID to use
collectionPath - The collection path to insert under
Returns:
The ID of the document in the collection
Throws:
XMLDBDataAccessException - if anything goes wrong in the data access

insertUpdateXMLDocument

public java.lang.String insertUpdateXMLDocument(org.w3c.dom.Document xmlDocument,
                                                java.lang.String docID,
                                                java.lang.String collectionPath)
                                         throws XMLDBDataAccessException
Insert or update a XML document from a supplied DOM object to the database. If the supplied docID is null the dao will attempt to insert with a null id relying on the database to supply a generated ID. If given a docID the dao will attempt to find an existing document in the given collection path, if a document exists it will update that document otherwise it will insert a new document with the supplied id.

Parameters:
docID - The document ID to use
collectionPath - The collection path to insert under
Returns:
The ID of the document in the collection
Throws:
XMLDBDataAccessException - if anything goes wrong in the data access

removeDocument

public boolean removeDocument(java.lang.String docID,
                              java.lang.String collectionPath)
                       throws XMLDBDataAccessException
Remove a document (XML or binary) from a collection

Parameters:
docID - The document ID to remove
collectionPath - The collection path to find the document
Returns:
true if resource removed
Throws:
XMLDBDataAccessException - if anything goes wrong in the data access

retrieveDocumentAsDOM

public org.w3c.dom.Document retrieveDocumentAsDOM(java.lang.String docID,
                                                  java.lang.String collectionPath)
                                           throws XMLDBDataAccessException
Retrieve an XML document as a w3c DOM object from a collection in the XML database

Parameters:
docID - The document ID to retrieve
collectionPath - The collection path to find the document
Returns:
A W3C DOM document
Throws:
XMLDBDataAccessException - if anything goes wrong in the data access

retrieveDocumentAsString

public java.lang.String retrieveDocumentAsString(java.lang.String docID,
                                                 java.lang.String collectionPath)
                                          throws XMLDBDataAccessException
Retrieve an XML document as a String from a collection in the XML database

Parameters:
docID - The document ID to retrieve
collectionPath - The collection path to find the document
Returns:
A String with the XML content
Throws:
XMLDBDataAccessException - if anything goes wrong in the data access

retrieveDocumentAsResource

public org.xmldb.api.base.Resource retrieveDocumentAsResource(java.lang.String docID,
                                                              java.lang.String collectionPath)
                                                       throws XMLDBDataAccessException
Retrieve a XML:DB Resource which can be either a binary or XML document from a collection in the XML database

Parameters:
docID - The document ID to retrieve
collectionPath - The collection path to find the document
Returns:
A XML:DB Resource with either the String or byte[] binary content of the file
Throws:
XMLDBDataAccessException - if anything goes wrong in the data access

insertUpdateBinaryFile

public java.lang.String insertUpdateBinaryFile(byte[] docBytes,
                                               java.lang.String docID,
                                               java.lang.String collectionPath)
                                        throws XMLDBDataAccessException
Insert or update a binary byte array into a XML database. If the byte[] is a true XML resource insert/update it as a XMLResource otherwise as a binary resource to the database. If the supplied docID is null the dao will attempt to insert with a null id relying on the database to supply a generated ID. If given a docID the dao will attempt to find an existing document in the given collection path, if a document exists it will update that document otherwise it will insert a new document with the supplied id.

Parameters:
docBytes - The byte array to insert or update
docID - The document ID to use
collectionPath - The collection path to insert under
Returns:
The ID of the document in the collection
Throws:
XMLDBDataAccessException - if anything goes wrong in the data access

insertUpdateInputStream

public java.lang.String insertUpdateInputStream(java.io.InputStream stream,
                                                java.lang.String docID,
                                                java.lang.String collectionPath)
                                         throws XMLDBDataAccessException
Insert or update information in a inputstream into a XML database. If the strem result is a true XML resource insert/update it as a XMLResource otherwise as a binary resource to the database. If the supplied docID is null the dao will attempt to insert with a null id relying on the database to supply a generated ID. If given a docID the dao will attempt to find an existing document in the given collection path, if a document exists it will update that document otherwise it will insert a new document with the supplied id.

Parameters:
stream - The input stream to insert or update
docID - The document ID to use
collectionPath - The collection path to insert under
Returns:
The ID of the document in the collection
Throws:
XMLDBDataAccessException - if anything goes wrong in the data access