org.globus.ogsa.impl.base.db.xindice
Class XindiceDriver

java.lang.Object
  extended byorg.globus.ogsa.impl.base.db.xindice.XindiceDriver

public class XindiceDriver
extends java.lang.Object

Class wrapper for common Xindice operations using XML:DB API. Essentially just a refactoring of the Xindice command-line tool functions into a single class for simplified runtime access.


Field Summary
static int XINDICE_DOCTYPE_DOM
           
static int XINDICE_DOCTYPE_SAX
           
static int XINDICE_DOCTYPE_STRING
           
static java.lang.String XINDICE_NAME_INDEXER
           
static java.lang.String XINDICE_VAL_INDEXER
           
static java.lang.String XINDICELOCALURI
           
static java.lang.String XINDICEURI
           
static java.lang.String XMLDBAPIVERSION
           
static java.lang.String XMLDBURI
           
 
Constructor Summary
XindiceDriver()
          Creates a new instance of XindiceDriver
XindiceDriver(boolean isLocal)
          Creates a new instance of XindiceDriver
 
Method Summary
 java.lang.String addDocumentDOM(java.lang.String parentCol, org.w3c.dom.Document doc, java.lang.String docName)
          Adds a document file to a collection.
 java.lang.String addDocumentFile(java.lang.String parentCol, java.lang.String fileName, java.lang.String docName)
          Adds a document file to a collection.
 java.lang.String addDocumentString(java.lang.String parentCol, java.lang.String docstr, java.lang.String docName)
          Adds a Document to a collection, where the input Document is in String form.
 void addIndexer(java.lang.String parentCol, java.lang.String name, java.lang.String type, java.lang.String pattern)
           
 void checkInitialized()
           
 void createCollection(java.lang.String parentCol, java.lang.String colName)
          Creates a new Xindice collection.
 java.lang.String createUniqueID(java.lang.String parentCol)
           
 void deleteDocument(java.lang.String parentCol, java.lang.String docID)
          Deletes a document from a collection.
 void dropAllCollections(java.lang.String parentCol)
           
 void dropCollection(java.lang.String parentCol, java.lang.String colName)
          Drops a collection from Xindice.
 void dropIndexer(java.lang.String parentCol, java.lang.String indexName)
           
 boolean findCollection(java.lang.String parentCol, java.lang.String collectionName)
           
 boolean findDocument(java.lang.String parentCol, java.lang.String documentName)
           
 org.w3c.dom.Node getDocumentAsDOM(java.lang.String parentCol, java.lang.String docID)
          Gets a Document from a collection, reutrns the result in Node representation.
 java.lang.String getDocumentAsString(java.lang.String parentCol, java.lang.String docID)
          Gets a Document from a collection, reutrns the result in String representation.
 void init()
          This method is invoked by the default constructor of a new instance of this class or may be used to explicity reactivate an instance of this class that has had the #shutdown method invoked on it.
 java.lang.String[] listChildCollections(java.lang.String parentCol)
          Gets a list of the collections beneath a parent collection.
 java.lang.String[] listCollectionDocuments(java.lang.String collection)
          Gets a list of the documents in a collection.
 java.lang.String[] listIndexers(java.lang.String parentCol)
          Gets a list of document indexers from a collection.
static void main(java.lang.String[] args)
           
protected  java.lang.String normalizeCollectionURI(java.lang.String uri, boolean local)
           
 void scalabilityTest()
           
 void selfTest()
           
 void setProfiling(boolean isProfiling)
           
 void setVerbose(boolean isVerbose)
           
 void shutdown(java.lang.String collection)
          Use this method to explicitly checkpoint the database and free open memory and file resources held by Xindice.
 java.lang.Object[] XPathQuery(java.lang.String parentCol, java.lang.String query, java.lang.String namespaces, int returnType)
           
 void XUpdate(java.lang.String parentCol, java.lang.String xupdate, java.lang.String namespaces)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XINDICEURI

public static final java.lang.String XINDICEURI
See Also:
Constant Field Values

XINDICELOCALURI

public static final java.lang.String XINDICELOCALURI
See Also:
Constant Field Values

XMLDBURI

public static final java.lang.String XMLDBURI
See Also:
Constant Field Values

XMLDBAPIVERSION

public static final java.lang.String XMLDBAPIVERSION
See Also:
Constant Field Values

XINDICE_VAL_INDEXER

public static final java.lang.String XINDICE_VAL_INDEXER
See Also:
Constant Field Values

XINDICE_NAME_INDEXER

public static final java.lang.String XINDICE_NAME_INDEXER
See Also:
Constant Field Values

XINDICE_DOCTYPE_STRING

public static final int XINDICE_DOCTYPE_STRING
See Also:
Constant Field Values

XINDICE_DOCTYPE_DOM

public static final int XINDICE_DOCTYPE_DOM
See Also:
Constant Field Values

XINDICE_DOCTYPE_SAX

public static final int XINDICE_DOCTYPE_SAX
See Also:
Constant Field Values
Constructor Detail

XindiceDriver

public XindiceDriver()
              throws java.lang.Exception
Creates a new instance of XindiceDriver


XindiceDriver

public XindiceDriver(boolean isLocal)
              throws java.lang.Exception
Creates a new instance of XindiceDriver

Method Detail

main

public static void main(java.lang.String[] args)

init

public void init()
This method is invoked by the default constructor of a new instance of this class or may be used to explicity reactivate an instance of this class that has had the #shutdown method invoked on it. Note that any method calls to this class will fail if the Xindice database is not registered.


shutdown

public void shutdown(java.lang.String collection)
              throws java.lang.Exception
Use this method to explicitly checkpoint the database and free open memory and file resources held by Xindice. Note that any other method calls to this class (with the exception of #init) after this method is invoked will likely throw an Exception.

Parameters:
collection - - name of the parent collection.
Throws:
java.lang.Exception

checkInitialized

public void checkInitialized()
                      throws java.lang.Exception
Throws:
java.lang.Exception

setVerbose

public void setVerbose(boolean isVerbose)

setProfiling

public void setProfiling(boolean isProfiling)

createUniqueID

public java.lang.String createUniqueID(java.lang.String parentCol)
                                throws java.lang.Exception
Throws:
java.lang.Exception

createCollection

public void createCollection(java.lang.String parentCol,
                             java.lang.String colName)
                      throws java.lang.Exception
Creates a new Xindice collection.

Parameters:
parentCol - - name of the parent collection
colName - - name of the new collection
Throws:
java.lang.Exception - Description of Exception

dropCollection

public void dropCollection(java.lang.String parentCol,
                           java.lang.String colName)
                    throws java.lang.Exception
Drops a collection from Xindice.

Parameters:
parentCol - - name of the parent collection
colName - - name of the new collection
Throws:
java.lang.Exception - Description of Exception

listChildCollections

public java.lang.String[] listChildCollections(java.lang.String parentCol)
                                        throws java.lang.Exception
Gets a list of the collections beneath a parent collection.

Parameters:
parentCol - - name of the parent collection.
Returns:
String[] - array of child collection names.
Throws:
java.lang.Exception - Description of Exception

listCollectionDocuments

public java.lang.String[] listCollectionDocuments(java.lang.String collection)
                                           throws java.lang.Exception
Gets a list of the documents in a collection.

Parameters:
collection - - name of the collection
Returns:
String[] - array of document URI's
Throws:
java.lang.Exception - Description of Exception

findCollection

public boolean findCollection(java.lang.String parentCol,
                              java.lang.String collectionName)
                       throws java.lang.Exception
Throws:
java.lang.Exception

findDocument

public boolean findDocument(java.lang.String parentCol,
                            java.lang.String documentName)
                     throws java.lang.Exception
Throws:
java.lang.Exception

dropAllCollections

public void dropAllCollections(java.lang.String parentCol)
                        throws java.lang.Exception
Throws:
java.lang.Exception

listIndexers

public java.lang.String[] listIndexers(java.lang.String parentCol)
                                throws java.lang.Exception
Gets a list of document indexers from a collection.

Parameters:
parentCol - - name of the collection
Returns:
String[] - array of document indexers.
Throws:
java.lang.Exception - Description of Exception

addDocumentFile

public java.lang.String addDocumentFile(java.lang.String parentCol,
                                        java.lang.String fileName,
                                        java.lang.String docName)
                                 throws java.lang.Exception
Adds a document file to a collection.

Parameters:
parentCol - - name of the parent collection
fileName - - name of the file
docName - - name of the document
Returns:
String - the document ID.
Throws:
java.lang.Exception - - if the collection does not exist.

addDocumentDOM

public java.lang.String addDocumentDOM(java.lang.String parentCol,
                                       org.w3c.dom.Document doc,
                                       java.lang.String docName)
                                throws java.lang.Exception
Adds a document file to a collection.

Parameters:
parentCol - - name of the parent collection
doc - - the document to add
docName - - name of the document
Returns:
String - the document ID.
Throws:
java.lang.Exception - - if the collection does not exist.

addDocumentString

public java.lang.String addDocumentString(java.lang.String parentCol,
                                          java.lang.String docstr,
                                          java.lang.String docName)
                                   throws java.lang.Exception
Adds a Document to a collection, where the input Document is in String form.

Parameters:
parentCol - - name of the parent collection
docstr - - String representation of the Document to add
docName - - name of the document
Returns:
String - the document ID.
Throws:
java.lang.Exception

deleteDocument

public void deleteDocument(java.lang.String parentCol,
                           java.lang.String docID)
                    throws java.lang.Exception
Deletes a document from a collection.

Parameters:
parentCol - - name of the parent collection
docID - - id of the document to delete
Throws:
java.lang.Exception - -

getDocumentAsString

public java.lang.String getDocumentAsString(java.lang.String parentCol,
                                            java.lang.String docID)
                                     throws java.lang.Exception
Gets a Document from a collection, reutrns the result in String representation.

Parameters:
parentCol - - name of the parent collection
docID - - id of the document
Returns:
String - the document represented as a String.
Throws:
java.lang.Exception - - if docId is null, collection not found, or document not found

getDocumentAsDOM

public org.w3c.dom.Node getDocumentAsDOM(java.lang.String parentCol,
                                         java.lang.String docID)
                                  throws java.lang.Exception
Gets a Document from a collection, reutrns the result in Node representation.

Parameters:
parentCol - - name of the parent collection
docID - - id of the document
Returns:
Node - the document represented as a Node
Throws:
java.lang.Exception - - if docId is null, collection not found, or document not found

addIndexer

public void addIndexer(java.lang.String parentCol,
                       java.lang.String name,
                       java.lang.String type,
                       java.lang.String pattern)
                throws java.lang.Exception
Throws:
java.lang.Exception

dropIndexer

public void dropIndexer(java.lang.String parentCol,
                        java.lang.String indexName)
                 throws java.lang.Exception
Throws:
java.lang.Exception

XPathQuery

public java.lang.Object[] XPathQuery(java.lang.String parentCol,
                                     java.lang.String query,
                                     java.lang.String namespaces,
                                     int returnType)
                              throws java.lang.Exception
Throws:
java.lang.Exception

XUpdate

public void XUpdate(java.lang.String parentCol,
                    java.lang.String xupdate,
                    java.lang.String namespaces)
             throws java.lang.Exception
Throws:
java.lang.Exception

selfTest

public void selfTest()
              throws java.lang.Exception
Throws:
java.lang.Exception

scalabilityTest

public void scalabilityTest()
                     throws java.lang.Exception
Throws:
java.lang.Exception

normalizeCollectionURI

protected java.lang.String normalizeCollectionURI(java.lang.String uri,
                                                  boolean local)