kevinoneill    2003/08/03 20:01:57

  Modified:    java/src/org/apache/xindice/client/xmldb/xmlrpc
                        CollectionImpl.java
               java/src/org/apache/xindice/client/xmldb/embed
                        CollectionImpl.java
               java/tests/src/org/apache/xindice/integration/client/services
                        XPathQueryTest.java
               java/tests/src/org/apache/xindice/integration
                        IntegrationTests.java
               java/tests/src/org/apache/xindice/integration/client/basic
                        CollectionTest.java
               java/src/org/apache/xindice/client/xmldb DatabaseImpl.java
                        ResourceSetImpl.java
               java/tests/src/org/apache/xindice
                        IntegrationXmlRpcTests.java
               java/src/org/apache/xindice/server/rpc/messages
                        RemoveCollection.java
               java/src/org/apache/xindice/tools XMLTools.java
  Log:
  PR: 22009, 22011.
  The xml-rpc driver now works within test-all (boot the server first though).
  
  Revision  Changes    Path
  1.27      +686 -666  
xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java
  
  Index: CollectionImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- CollectionImpl.java       1 Aug 2003 19:40:16 -0000       1.26
  +++ CollectionImpl.java       4 Aug 2003 03:01:57 -0000       1.27
  @@ -59,6 +59,13 @@
    * $Id$
    */
   
  +import java.io.StringReader;
  +import java.net.MalformedURLException;
  +import java.util.Hashtable;
  +import java.util.Vector;
  +
  +import javax.xml.parsers.DocumentBuilderFactory;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.xindice.client.xmldb.ResourceSetImpl;
  @@ -73,11 +80,7 @@
   import org.apache.xindice.xml.dom.DOMParser;
   import org.apache.xmlrpc.XmlRpc;
   import org.apache.xmlrpc.XmlRpcClient;
  -
   import org.w3c.dom.Document;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
   import org.xml.sax.InputSource;
   import org.xmldb.api.base.Collection;
   import org.xmldb.api.base.ErrorCodes;
  @@ -86,12 +89,6 @@
   import org.xmldb.api.base.XMLDBException;
   import org.xmldb.api.modules.XMLResource;
   
  -import javax.xml.parsers.DocumentBuilderFactory;
  -import java.io.StringReader;
  -import java.net.MalformedURLException;
  -import java.util.Hashtable;
  -import java.util.Vector;
  -
   /**
    * Implementation of XML:DB's <code>Collection</code> interface using
    * XML-RPC to interact with database server
  @@ -100,660 +97,683 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Kimbro Staken</a>
    */
   public class CollectionImpl extends XindiceCollection {
  -
  -    private static Log log = 
LogFactory.getLog("org.apache.xindice.client.xmldb.xmlrpc");
  -
  -    /* path to XML-RPC service on database */
  -    private static String XINDICE_SERVICE_LOCATION = "/Xindice/";
  -
  -    /* host and port number of server */
  -    private String hostPort;
  -
  -    /* location of the XML-RPC service in the web server */
  -    private String serviceLocation;
  -
  -    /* SAX parser the XML-RPC service will use */
  -    private String xmlrpcDriver;
  -
  -    /* the XML-RPC client stub, connected to server */
  -    private XmlRpcClient client = null;
  -
  -    /**
  -     * Creates new <code>CollectionImpl</code> instance representing 
connection
  -     * to server collection.
  -     *
  -     * @param hostPort hostname and port number in <code>host:port</code> 
format.
  -     *        Port no is optional, in which case HTTP default is assumed.
  -     * @param serviceLocation is the path in the web server's namespace where
  -     *        the XML-RPC service is mounted.  It is <code>null</code> unless
  -     *        the <code>service-location</code> property of
  -     *        <code>org.apache.xindice.client.xmlrpc.DatabaseImpl</code>
  -     *        is set.
  -     * @param collPath is the name of the collection to open.
  -     * @exception XMLDBException thrown if a connection could not be 
established,
  -     *            because of URL syntax errors, or connection failure, or if 
no
  -     *            collection with path <code>collPath</code> could be 
located.
  -     */
  -    public CollectionImpl(String hostPort, String serviceLocation, String 
xmlrpcDriver, String collPath) throws XMLDBException {
  -        super(collPath);
  -        this.hostPort = hostPort;
  -        this.serviceLocation = serviceLocation;
  -        this.xmlrpcDriver = xmlrpcDriver;
  -        this.collPath = collPath;
  -
  -        XmlRpc.setEncoding("UTF8");
  -
  -        /*
  -         * Determine the SAXparser the xmlrpc client will use.
  -         * In priority order:
  -         *   DatabaseImpl xmlrpc-driver property
  -         *      (passed in the xmlrpcDriver parameter)
  -         *   System property "xindice.xmlrpc.driver"
  -         *   Default value "xerces"
  -         */
  -        if (xmlrpcDriver == null) {
  -            xmlrpcDriver = System.getProperty("xindice.xmlrpc.driver");
  -        }
  -        if (xmlrpcDriver == null) {
  -            xmlrpcDriver = "xerces";
  -        }
  -        XmlRpc.setKeepAlive(true);
  -        try {
  -            XmlRpc.setDriver(xmlrpcDriver);
  -        } catch (Exception e) {
  -            throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Xerces 
needed", e);
  -        }
  -
  -        /*
  -         * Determine the path in the web server to the XML-RPC service.
  -         * In priority order:
  -         *   DatabaseImpl service-location property
  -         *      (passed in the serviceLocation parameter)
  -         *   System property "xindice.xmlrpc.service-location"
  -         *   Default value "/Xindice/"
  -         */
  -        if (serviceLocation == null) {
  -            serviceLocation = 
System.getProperty("xindice.xmlrpc.service-location");
  -        }
  -        if (serviceLocation == null) {
  -            serviceLocation = XINDICE_SERVICE_LOCATION;
  -        }
  -
  -        if (!serviceLocation.startsWith("/")) {
  -            serviceLocation = "/" + serviceLocation;
  -        }
  -        if (!serviceLocation.endsWith("/")) {
  -            serviceLocation = serviceLocation + "/";
  -        }
  -
  -        log.debug("serviceLocation=<" + serviceLocation + ">");
  -        String xmlrpcURI = "http://"; + hostPort + serviceLocation;
  -
  -        try {
  -            client = new XmlRpcClient(xmlrpcURI);
  -
  -            /* Just check the collection does actually exist */
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            String exists = (String) 
runRemoteCommand("GetCollectionConfiguration", params);
  -            if (!"yes".equals(exists)) {
  -
  -                throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION, 
"Collection not found: " + collPath);
  -            }
  -        } catch (MalformedURLException e) {
  -            client = null;
  -            throw new XMLDBException(ErrorCodes.INVALID_URI, e);
  -        } catch (XMLDBException x) {
  -
  -            throw x;  // propagate any xmldb exception.
  -        } catch (Exception e) {
  -            client = null;
  -            throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION, 
"Collection not found: " + collPath, e);
  -        }
  -    }
  -
  -    /**
  -     * Submits a command for RPC to database server
  -     *
  -     * @param cmdName command name
  -     * @param params hashtable containing named parameters to send to server
  -     * @return the return value from the server. Type of return value 
depends on
  -     *         command.
  -     *
  -     * @exception Exception thrown if XML-RPC reports an exception.
  -     */
  -    private Object runRemoteCommand(String cmdName, Hashtable params) throws 
Exception {
  -
  -        params.put(RPCMessageInterface.MESSAGE_PARAM, cmdName);
  -
  -        Vector v = new Vector();
  -        v.add(params);
  -        return ((Hashtable) client.execute("run", 
v)).get(RPCDefaultMessage.RESULT);
  -    }
  -
  -    /**
  -     * Retrieves a <code>Resource</code> from the database. If the
  -     * <code>Resource</code> could not be
  -     * located a null value will be returned.
  -     *
  -     * @param id the unique id for the requested resource.
  -     * @return The retrieved <code>Resource</code> instance.
  -     * @exception XMLDBException with expected error codes.<br />
  -     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -     *  specific errors that occur.<br />
  -     *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -     *  method has been called on the <code>Collection</code><br />
  -     */
  -    public Resource getResource(String id) throws XMLDBException {
  -
  -        checkOpen();
  -        try {
  -
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            params.put(RPCDefaultMessage.NAME, id);
  -            params.put(RPCDefaultMessage.COMPRESSED, "true");
  -
  -            Object result = runRemoteCommand("GetDocument", params);
  -            /*
  -             * If we get a Hashtable back then the result is compressed.
  -             */
  -            if (result instanceof Hashtable) {
  -                Hashtable compressed = (Hashtable) result;
  -                SymbolDeserializer symbolDeserial = new SymbolDeserializer();
  -                return new XMLResourceImpl(id, id, this, 
symbolDeserial.getSymbols(compressed), (byte[]) compressed.get("document"));
  -            } else {
  -                return new XMLResourceImpl(id, (String) result, this);
  -            }
  -
  -        } catch (Exception e) {
  -            return null;
  -        }
  -    }
  -
  -    /**
  -     * Returns the number of resources currently stored in this collection 
or 0
  -     * if the collection is empty.
  -     *
  -     * @return the number of resource in the collection.
  -     * @exception XMLDBException with expected error codes.<br />
  -     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -     *  specific errors that occur.<br />
  -     *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -     *  method has been called on the <code>Collection</code><br />
  -     */
  -    public int getResourceCount() throws XMLDBException {
  -
  -        checkOpen();
  -        try {
  -
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            return ((Integer) runRemoteCommand("GetDocumentCount", 
params)).intValue();
  -        } catch (XMLDBException x) {
  -
  -            throw x;  // propagate any xmldb exception.
  -        } catch (Exception e) {
  -
  -            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  -        }
  -    }
  -
  -    /**
  -     * Stores the provided resource into the database. If the resource does 
not
  -     * already exist it will be created. If it does already exist it will be
  -     * updated.
  -     *
  -     * @param res the resource to store in the database.
  -     * @exception XMLDBException with expected error codes.<br />
  -     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -     *  specific errors that occur.<br />
  -     *  <code>ErrorCodes.INVALID_RESOURCE</code> if the 
<code>Resource</code> is
  -     *   not valid.
  -     *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -     *  method has been called on the <code>Collection</code><br />
  -     */
  -    public void storeResource(Resource res) throws XMLDBException {
  -
  -        if (!(res instanceof XMLResource)) {
  -
  -            throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "Only XML 
resources supported");
  -        }
  -
  -        if (res.getContent() == null) {
  -
  -            throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "no 
resource data");
  -        }
  -        checkOpen();
  -        try {
  -
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            params.put(RPCDefaultMessage.NAME, res.getId());
  -            params.put(RPCDefaultMessage.DOCUMENT, res.getContent());
  -
  -            String name = (String) runRemoteCommand("InsertDocument", 
params);
  -            ((XMLResourceImpl) res).setId(name);
  -
  -        } catch (XMLDBException x) {
  -
  -            throw x;  // propagate any xmldb exception.
  -        } catch (Exception e) {
  -
  -            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  -        }
  -    }
  -
  -    /* see superclass for documentation */
  -    public boolean isOpen() {
  -
  -        return (client != null);
  -    }
  -
  -    /* see superclass for documentation */
  -    public String getURI() {
  -
  -        return "xmldb:" + DatabaseImpl.DRIVER_NAME + "://" + hostPort + 
collPath;
  -    }
  -
  -    /**
  -     * Returns a <code>Collection</code> instance for the requested child 
collection
  -     * if it exists.
  -     *
  -     * @param name the name of the child collection to retrieve.
  -     * @return the requested child collection or null if it couldn't be 
found.
  -     * @exception XMLDBException with expected error codes.<br />
  -     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -     *  specific errors that occur.<br />
  -     *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -     *  method has been called on the <code>Collection</code><br />
  -     */
  -    public Collection getChildCollection(String name) throws XMLDBException {
  -
  -        if (name.indexOf('/') != -1) {
  -
  -            throw new XMLDBException(ErrorCodes.INVALID_COLLECTION);
  -        }
  -
  -        try {
  -            return new CollectionImpl(hostPort, serviceLocation, 
xmlrpcDriver, collPath + "/" + name);
  -        } catch (XMLDBException e) {
  -
  -            if (e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
  -                // per getChildCollection contract, return null if not found
  -                return null;
  -            }
  -
  -            throw e;
  -        }
  -    }
  -
  -    /**
  -     * Creates a new unique ID within the context of the 
<code>Collection</code>
  -     *
  -     * @return the created id as a string.
  -     * @exception XMLDBException with expected error codes.<br />
  -     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -     *  specific errors that occur.<br />
  -     *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -     *  method has been called on the <code>Collection</code><br />
  -     */
  -    public String createId() throws XMLDBException {
  -
  -        checkOpen();
  -        try {
  -
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            return (String) runRemoteCommand("CreateNewOID", params);
  -        } catch (XMLDBException x) {
  -
  -            throw x;  // propagate any xmldb exception.
  -        } catch (Exception e) {
  -
  -            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  -        }
  -    }
  -
  -    /**
  -     * Releases all resources consumed by the <code>Collection</code>.
  -     * The <code>close</code> method must
  -     * always be called when use of a <code>Collection</code> is complete. 
It is
  -     * not safe to use a  <code>Collection</code> after the 
<code>close</code>
  -     * method has been called.
  -     *
  -     * @exception XMLDBException with expected error codes.<br />
  -     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -     *  specific errors that occur.<br />
  -     */
  -    public void close() throws org.xmldb.api.base.XMLDBException {
  -
  -        client = null;
  -    }
  -
  -    /**
  -     * Returns the parent collection for this collection or null if no parent
  -     * collection exists.
  -     *
  -     * @return the parent <code>Collection</code> instance.
  -     * @exception XMLDBException with expected error codes.<br />
  -     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -     *  specific errors that occur.<br />
  -     *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -     *  method has been called on the <code>Collection</code><br />
  -     */
  -    public Collection getParentCollection() throws XMLDBException {
  -
  -        // If there's only one slash then it's the root.
  -        if (collPath.lastIndexOf("/") == 0) {
  -            return null;
  -        }
  -
  -        try {
  -            return new CollectionImpl(hostPort, serviceLocation, 
xmlrpcDriver, collPath.substring(0, collPath.lastIndexOf('/')));
  -        } catch (XMLDBException e) {
  -            if (e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
  -                // per getParentCollection contract, return null if no parent
  -                return null;
  -            }
  -            throw e;
  -        }
  -    }
  -
  -    /**
  -     * Removes the <code>Resource</code> from the database.
  -     *
  -     * @param res the resource to remove.
  -     * @exception XMLDBException with expected error codes.<br />
  -     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -     *  specific errors that occur.<br />
  -     *  <code>ErrorCodes.INVALID_RESOURCE</code> if the 
<code>Resource</code> is
  -     *   not valid.<br />
  -     *  <code>ErrorCodes.NO_SUCH_RESOURCE</code> if the 
<code>Resource</code> is
  -     *   not known to this <code>Collection</code>.
  -     *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -     *  method has been called on the <code>Collection</code><br />
  -     */
  -    public void removeResource(Resource res) throws XMLDBException {
  -
  -        if (!(res instanceof XMLResource)) {
  -
  -            throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "Only XML 
resources supported");
  -        }
  -
  -        if (res.getId() == null) {
  -            throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "This resource 
is a query result and can " + "not be removed from the database.");
  -        }
  -
  -        checkOpen();
  -        try {
  -
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            params.put(RPCDefaultMessage.NAME, res.getId());
  -            runRemoteCommand("RemoveDocument", params);
  -        } catch (XMLDBException x) {
  -
  -            throw x;  // propagate any xmldb exception.
  -        } catch (Exception e) {
  -            throw new XMLDBException(ErrorCodes.NO_SUCH_RESOURCE, e);
  -        }
  -    }
  -
  -    /**
  -     * Returns a list of collection names naming all child collections
  -     * of the current collection. If no child collections exist an empty 
list is
  -     * returned.
  -     *
  -     * @return an array containing collection names for all child
  -     *      collections.
  -     * @exception XMLDBException with expected error codes.<br />
  -     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -     *  specific errors that occur.<br />
  -     *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -     *  method has been called on the <code>Collection</code><br />
  -     */
  -    public String[] listChildCollections() throws XMLDBException {
  -
  -        checkOpen();
  -        try {
  -
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            Vector list = (Vector) runRemoteCommand("ListCollections", 
params);
  -
  -            return (String[]) list.toArray(new String[list.size()]);
  -        } catch (XMLDBException x) {
  -
  -            throw x;  // propagate any xmldb exception.
  -        } catch (Exception e) {
  -
  -            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  -        }
  -    }
  -
  -    /**
  -     * Returns the number of child collections under this
  -     * <code>Collection</code> or 0 if no child collections exist.
  -     *
  -     * @return the number of child collections.
  -     * @exception XMLDBException with expected error codes.<br />
  -     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -     *  specific errors that occur.<br />
  -     *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -     *  method has been called on the <code>Collection</code><br />
  -     */
  -    public int getChildCollectionCount() throws XMLDBException {
  -
  -        checkOpen();
  -        try {
  -
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            Integer result = (Integer) 
runRemoteCommand("GetCollectionCount", params);
  -            return result.intValue();
  -
  -        } catch (XMLDBException x) {
  -
  -            throw x;  // propagate any xmldb exception.
  -        } catch (Exception e) {
  -            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  -        }
  -    }
  -
  -    /**
  -     * Returns a list of the ids for all resources stored in the collection.
  -     *
  -     * @return a string array containing the names for all
  -     *  <code>Resource</code>s in the collection.
  -     * @exception XMLDBException with expected error codes.<br />
  -     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -     *  specific errors that occur.<br />
  -     *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  -     *  method has been called on the <code>Collection</code><br />
  -     */
  -    public String[] listResources() throws XMLDBException {
  -
  -        checkOpen();
  -        try {
  -
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            Vector list = (Vector) runRemoteCommand("ListDocuments", params);
  -
  -            return (String[]) list.toArray(new String[list.size()]);
  -        } catch (XMLDBException x) {
  -
  -            throw x;  // propagate any xmldb exception.
  -        } catch (Exception e) {
  -
  -            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  -        }
  -    }
  -
  -    /* see superclass for documentation */
  -    public ResourceSet query(String name, String queryLang, String query, 
Hashtable nsMap) throws XMLDBException {
  -
  -        checkOpen();
  -        try {
  -
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            params.put(RPCDefaultMessage.TYPE, queryLang);
  -            params.put(RPCDefaultMessage.NAMESPACES, nsMap);
  -            params.put(RPCDefaultMessage.QUERY, query);
  -
  -            if (name != null) {
  -
  -                params.put(RPCDefaultMessage.NAME, name);
  -            }
  -
  -            String result = (String) runRemoteCommand("Query", params);
  -            DocumentBuilderFactory dbf = 
DocumentBuilderFactory.newInstance();
  -            dbf.setNamespaceAware(true);
  -            Document resultDoc = dbf.newDocumentBuilder().parse(new 
InputSource(new StringReader(result)));
  -
  -            NodeList nodes = resultDoc.getDocumentElement().getChildNodes();
  -            ResourceSetImpl rs = new ResourceSetImpl(this, null);
  -
  -            for (int i = 0; i < nodes.getLength(); i++) {
  -
  -                Node n = nodes.item(i);
  -
  -                String documentId = ((Element) n).getAttributeNS(QUERY_NS, 
"key");
  -                XMLResourceImpl resource = new XMLResourceImpl(null, 
documentId, this, TextWriter.toString(n));
  -                rs.addResource(resource);
  -            }
  -
  -            return rs;
  -        } catch (Exception e) {
  -
  -            throw 
FaultCodes.createXMLDBException(FaultCodes.QRY_PROCESSING_ERROR, "Query error", 
e);
  -        }
  -    }
  -
  -    /* see superclass for documentation */
  -    public Collection createCollection(String name) throws XMLDBException {
  -        return createCollection(name, null);
  -    }
  -
  -    /* see superclass for documentation */
  -    public Collection createCollection(String name, Document configuration) 
throws XMLDBException {
  -        checkOpen();
  -        try {
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            params.put(RPCDefaultMessage.NAME, name);
  -            if (configuration != null) {
  -                params.put(RPCDefaultMessage.CONFIGURATION, 
TextWriter.toString(configuration));
  -            }
  -
  -            runRemoteCommand("CreateCollection", params);
  -
  -            return getChildCollection(name);
  -        } catch (XMLDBException x) {
  -
  -            throw x;  // propagate any xmldb exception.
  -        } catch (Exception e) {
  -            throw new XMLDBException(ErrorCodes.INVALID_COLLECTION, "Cannot 
create child collection", e);
  -        }
  -    }
  -
  -    /* see superclass for documentation */
  -    public void removeCollection(String childName) throws XMLDBException {
  -
  -        checkOpen();
  -        try {
  -
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            params.put(RPCDefaultMessage.NAME, childName);
  -            String result = (String) runRemoteCommand("RemoveCollection", 
params);
  -
  -            if (!result.equals("yes")) {
  -
  -                throw new XMLDBException(ErrorCodes.INVALID_COLLECTION, 
"Cannot remove child collection[" + childName + "]");
  -            }
  -        } catch (XMLDBException x) {
  -
  -            throw x;  // propagate any xmldb exception.
  -        } catch (Exception e) {
  -
  -            throw new XMLDBException(ErrorCodes.INVALID_COLLECTION, "Cannot 
remove child collection[" + childName + "]", e);
  -        }
  -    }
  -
  -    /* see superclass for documentation */
  -    public String[] listIndexers() throws XMLDBException {
  -        checkOpen();
  -        try {
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            Vector list = (Vector) runRemoteCommand("ListIndexers", params);
  -
  -            return (String[]) list.toArray(new String[list.size()]);
  -        } catch (Exception e) {
  -            throw FaultCodes.createXMLDBException(e);
  -        }
  -    }
  -
  -    /* see superclass for documentation */
  -    public void createIndexer(Document configuration) throws XMLDBException {
  -        checkOpen();
  -        try {
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            params.put(RPCDefaultMessage.CONFIGURATION, 
TextWriter.toString(configuration));
  -
  -            runRemoteCommand("CreateIndexer", params);
  -        } catch (Exception e) {
  -            throw FaultCodes.createXMLDBException(e);
  -        }
  -    }
  -
  -    /* see superclass for documentation */
  -    public void dropIndexer(String name) throws XMLDBException {
  -        checkOpen();
  -        try {
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            params.put(RPCDefaultMessage.NAME, name);
  -
  -            runRemoteCommand("RemoveIndexer", params);
  -        } catch (Exception e) {
  -            throw FaultCodes.createXMLDBException(e);
  -        }
  -    }
  -
  -    /* see superclass for documentation */
  -    public void shutdown() throws XMLDBException {
  -        checkOpen();
  -        try {
  -            Hashtable params = new Hashtable();
  -
  -            runRemoteCommand("Shutdown", params);
  -        } catch (Exception e) {
  -            throw FaultCodes.createXMLDBException(e);
  -        }
  -    }
  -
  -    public MetaData getMetaData(String id) throws XMLDBException {
  -        checkOpen();
  -        try {
  -            Hashtable params = new Hashtable();
  -            params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            if (id != null) {
  -                params.put(RPCDefaultMessage.NAME, id);
  -            }
  -            params.put(RPCDefaultMessage.COMPRESSED, "true");
  -
  -            Object result = runRemoteCommand(id == null ? 
"GetCollectionMeta" : "GetDocumentMeta", params);
  -            Document metaDoc = DOMParser.toDocument(result.toString());
  -            MetaData meta = new MetaData(id);
  -            meta.streamFromXML(metaDoc.getDocumentElement(), true);
  -            return meta;
  -        } catch (Exception e) {
  -            throw FaultCodes.createXMLDBException(e);
  -        }
  -    }
  +     
  +     private static Log log = 
LogFactory.getLog("org.apache.xindice.client.xmldb.xmlrpc");
  +             
  +     /* path to XML-RPC service on database */
  +     private static String XINDICE_SERVICE_LOCATION = "/xindice/";
  +
  +     /* host and port number of server */
  +     private String hostPort;
  +
  +     /* location of the XML-RPC service in the web server */
  +     private String serviceLocation;
  +
  +     /* SAX parser the XML-RPC service will use */
  +     private String xmlrpcDriver;
  +
  +     /* the XML-RPC client stub, connected to server */
  +     private XmlRpcClient client = null;
  +
  +     /**
  +      * Creates new <code>CollectionImpl</code> instance representing 
connection
  +      * to server collection.
  +      *
  +      * @param hostPort hostname and port number in <code>host:port</code> 
format.
  +      *        Port no is optional, in which case HTTP default is assumed.
  +      * @param serviceLocation is the path in the web server's namespace 
where
  +      *        the XML-RPC service is mounted.  It is <code>null</code> 
unless
  +      *        the <code>service-location</code> property of
  +      *        <code>org.apache.xindice.client.xmlrpc.DatabaseImpl</code>
  +      *        is set.
  +      * @param collPath is the name of the collection to open.
  +      * @exception XMLDBException thrown if a connection could not be 
established,
  +      *            because of URL syntax errors, or connection failure, or 
if no
  +      *            collection with path <code>collPath</code> could be 
located.
  +      */
  +     public CollectionImpl(String hostPort, String serviceLocation, String 
xmlrpcDriver, String collPath) throws XMLDBException {
  +             super(collPath);
  +             this.hostPort = hostPort;
  +             this.serviceLocation = serviceLocation;
  +             this.xmlrpcDriver = xmlrpcDriver;
  +
  +             XmlRpc.setEncoding("UTF8");
  +
  +             /*
  +              * Determine the SAXparser the xmlrpc client will use.
  +              * In priority order:
  +              *   DatabaseImpl xmlrpc-driver property
  +              *      (passed in the xmlrpcDriver parameter)
  +              *   System property "xindice.xmlrpc.driver"
  +              *   Default value "xerces"
  +              */
  +             if (xmlrpcDriver == null) {
  +                     xmlrpcDriver = 
System.getProperty("xindice.xmlrpc.driver");
  +             }
  +             if (xmlrpcDriver == null) {
  +                     xmlrpcDriver = "xerces";
  +             }
  +             XmlRpc.setKeepAlive(true);
  +             try {
  +                     XmlRpc.setDriver(xmlrpcDriver);
  +             }
  +             catch (Exception e) {
  +                     throw new XMLDBException(ErrorCodes.VENDOR_ERROR, 
"Xerces needed", e);
  +             }
  +
  +             /*
  +              * Determine the path in the web server to the XML-RPC service.
  +              * In priority order:
  +              *   DatabaseImpl service-location property
  +              *      (passed in the serviceLocation parameter)
  +              *   System property "xindice.xmlrpc.service-location"
  +              *   Default value "/xindice/"
  +              */
  +             if (serviceLocation == null) {
  +                     serviceLocation = 
System.getProperty("xindice.xmlrpc.service-location");
  +             }
  +             if (serviceLocation == null) {
  +                     serviceLocation = XINDICE_SERVICE_LOCATION;
  +             }
  +
  +             if (!serviceLocation.startsWith("/")) {
  +                     serviceLocation = "/" + serviceLocation;
  +             }
  +             if (!serviceLocation.endsWith("/")) {
  +                     serviceLocation = serviceLocation + "/";
  +             }
  +             
  +             log.debug("serviceLocation=<" + serviceLocation + ">");
  +             String xmlrpcURI = "http://"; + hostPort + serviceLocation;
  +
  +             try {
  +                     client = new XmlRpcClient(xmlrpcURI);
  +
  +                     /* Just check the collection does actually exist */
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     String exists = (String) 
runRemoteCommand("GetCollectionConfiguration", params);
  +                     if (!"yes".equals(exists)) {
  +
  +                             throw new 
XMLDBException(ErrorCodes.NO_SUCH_COLLECTION, "Collection not found: " + 
collPath);
  +                     }
  +             }
  +             catch (MalformedURLException e) {
  +                     client = null;
  +                     throw new XMLDBException(ErrorCodes.INVALID_URI, e);
  +             }
  +             catch(XMLDBException x){
  +             
  +                     throw x;  // propagate any xmldb exception.     
  +             }               
  +             catch (Exception e) {
  +                     client = null;
  +                     throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION, 
"Collection not found: " + collPath, e);
  +             }
  +     }
  +
  +     /**
  +      * Submits a command for RPC to database server
  +      *
  +      * @param cmdName command name
  +      * @param params hashtable containing named parameters to send to server
  +      * @return the return value from the server. Type of return value 
depends on
  +      *         command.
  +      *
  +      * @exception Exception thrown if XML-RPC reports an exception.
  +      */
  +     private Object runRemoteCommand(String cmdName, Hashtable params) 
throws Exception {
  +
  +             params.put(RPCMessageInterface.MESSAGE_PARAM, cmdName);
  +
  +             Vector v = new Vector();
  +             v.add(params);
  +             return ((Hashtable) client.execute("run", 
v)).get(RPCDefaultMessage.RESULT);
  +     }
  +
  +     /**
  +      * Retrieves a <code>Resource</code> from the database. If the
  +      * <code>Resource</code> could not be
  +      * located a null value will be returned.
  +      *
  +      * @param id the unique id for the requested resource.
  +      * @return The retrieved <code>Resource</code> instance.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public Resource getResource(String id) throws XMLDBException {
  +
  +             checkOpen();
  +             try {
  +
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     params.put(RPCDefaultMessage.NAME, id);
  +                     params.put(RPCDefaultMessage.COMPRESSED, "true");
  +
  +                     Object result = runRemoteCommand("GetDocument", params);
  +                     /*
  +                      * If we get a Hashtable back then the result is 
compressed.
  +                      */
  +                     if (result instanceof Hashtable) {
  +                             Hashtable compressed = (Hashtable) result;
  +                             SymbolDeserializer symbolDeserial = new 
SymbolDeserializer();
  +                             return new XMLResourceImpl(id, id, this, 
symbolDeserial.getSymbols(compressed), (byte[]) compressed.get("document"));
  +                     }
  +                     else {
  +                             return new XMLResourceImpl(id, (String) result, 
this);
  +                     }
  +
  +             }
  +             catch (Exception e) {
  +                     return null;
  +             }
  +     }
  +
  +     /**
  +      * Returns the number of resources currently stored in this collection 
or 0
  +      * if the collection is empty.
  +      *
  +      * @return the number of resource in the collection.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public int getResourceCount() throws XMLDBException {
  +
  +             checkOpen();
  +             try {
  +
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     return ((Integer) runRemoteCommand("GetDocumentCount", 
params)).intValue();
  +             }
  +             catch(XMLDBException x){
  +             
  +                     throw x;  // propagate any xmldb exception.     
  +             }               
  +             catch (Exception e) {
  +
  +                     throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  +             }
  +     }
  +
  +     /**
  +      * Stores the provided resource into the database. If the resource does 
not
  +      * already exist it will be created. If it does already exist it will be
  +      * updated.
  +      *
  +      * @param res the resource to store in the database.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.INVALID_RESOURCE</code> if the 
<code>Resource</code> is
  +      *   not valid.
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public void storeResource(Resource res) throws XMLDBException {
  +
  +             if (!(res instanceof XMLResource)) {
  +
  +                     throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, 
"Only XML resources supported");
  +             }
  +
  +             if (res.getContent() == null) {
  +
  +                     throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, 
"no resource data");
  +             }
  +             checkOpen();
  +             try {
  +
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     params.put(RPCDefaultMessage.NAME, res.getId());
  +                     params.put(RPCDefaultMessage.DOCUMENT, 
res.getContent());
  +
  +                     String name = (String) 
runRemoteCommand("InsertDocument", params);
  +                     ((XMLResourceImpl) res).setId(name);
  +
  +             }
  +             catch(XMLDBException x){
  +             
  +                     throw x;  // propagate any xmldb exception.     
  +             }               
  +             catch (Exception e) {
  +
  +                     throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  +             }
  +     }
  +
  +     /* see superclass for documentation */
  +     public boolean isOpen() {
  +
  +             return (client != null);
  +     }
  +
  +     /* see superclass for documentation */
  +     public String getURI() {
  +
  +             return "xmldb:" + DatabaseImpl.DRIVER_NAME + "://" + hostPort + 
collPath;
  +     }
  +
  +     /**
  +      * Returns a <code>Collection</code> instance for the requested child 
collection
  +      * if it exists.
  +      *
  +      * @param name the name of the child collection to retrieve.
  +      * @return the requested child collection or null if it couldn't be 
found.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public Collection getChildCollection(String name) throws XMLDBException 
{
  +
  +             if (name.indexOf('/') != -1) {
  +
  +                     throw new XMLDBException(ErrorCodes.INVALID_COLLECTION);
  +             }
  +
  +             try {
  +                     return new CollectionImpl(hostPort, serviceLocation, 
xmlrpcDriver, collPath + "/" + name);
  +             }
  +             catch (XMLDBException e) {
  +                     
  +                     if (e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
  +                             // per getChildCollection contract, return null 
if not found
  +                             return null;
  +                     }
  +                     
  +                     throw e;
  +             }
  +     }
  +
  +     /**
  +      * Creates a new unique ID within the context of the 
<code>Collection</code>
  +      *
  +      * @return the created id as a string.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public String createId() throws XMLDBException {
  +
  +             checkOpen();
  +             try {
  +
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     return (String) runRemoteCommand("CreateNewOID", 
params);
  +             }
  +             catch(XMLDBException x){
  +             
  +                     throw x;  // propagate any xmldb exception.     
  +             }               
  +             catch (Exception e) {
  +
  +                     throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  +             }
  +     }
  +
  +     /**
  +      * Releases all resources consumed by the <code>Collection</code>.
  +      * The <code>close</code> method must
  +      * always be called when use of a <code>Collection</code> is complete. 
It is
  +      * not safe to use a  <code>Collection</code> after the 
<code>close</code>
  +      * method has been called.
  +      *
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      */
  +     public void close() throws org.xmldb.api.base.XMLDBException {
  +
  +             client = null;
  +     }
  +
  +     /**
  +      * Returns the parent collection for this collection or null if no 
parent
  +      * collection exists.
  +      *
  +      * @return the parent <code>Collection</code> instance.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public Collection getParentCollection() throws XMLDBException {
  +
  +             // If there's only one slash then it's the root.
  +             if (collPath.lastIndexOf("/") == 0) {
  +                     return null;
  +             }
  +
  +             try {
  +                     return new CollectionImpl(hostPort, serviceLocation, 
xmlrpcDriver, collPath.substring(0, collPath.lastIndexOf('/')));
  +             }
  +             catch (XMLDBException e) {
  +                     if (e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
  +                             // per getParentCollection contract, return 
null if no parent
  +                             return null;
  +                     }
  +                     throw e;
  +             }
  +     }
  +
  +     /**
  +      * Removes the <code>Resource</code> from the database.
  +      *
  +      * @param res the resource to remove.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.INVALID_RESOURCE</code> if the 
<code>Resource</code> is
  +      *   not valid.<br />
  +      *  <code>ErrorCodes.NO_SUCH_RESOURCE</code> if the 
<code>Resource</code> is
  +      *   not known to this <code>Collection</code>.
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public void removeResource(Resource res) throws XMLDBException {
  +
  +             if (!(res instanceof XMLResource)) {
  +
  +                     throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, 
"Only XML resources supported");
  +             }
  +
  +             if (res.getId() == null) {
  +                     throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "This 
resource is a query result and can " + "not be removed from the database.");
  +             }
  +
  +             checkOpen();
  +             try {
  +
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     params.put(RPCDefaultMessage.NAME, res.getId());
  +                     runRemoteCommand("RemoveDocument", params);
  +             }
  +             catch(XMLDBException x){
  +             
  +                     throw x;  // propagate any xmldb exception.     
  +             }               
  +             catch (Exception e) {
  +                     throw new XMLDBException(ErrorCodes.NO_SUCH_RESOURCE, 
e);
  +             }
  +     }
  +
  +     /**
  +      * Returns a list of collection names naming all child collections
  +      * of the current collection. If no child collections exist an empty 
list is
  +      * returned.
  +      *
  +      * @return an array containing collection names for all child
  +      *      collections.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public String[] listChildCollections() throws XMLDBException {
  +
  +             checkOpen();
  +             try {
  +
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     Vector list = (Vector) 
runRemoteCommand("ListCollections", params);
  +
  +                     return (String[]) list.toArray(new String[list.size()]);
  +             }
  +             catch(XMLDBException x){
  +             
  +                     throw x;  // propagate any xmldb exception.     
  +             }               
  +             catch (Exception e) {
  +
  +                     throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  +             }
  +     }
  +
  +     /**
  +      * Returns the number of child collections under this
  +      * <code>Collection</code> or 0 if no child collections exist.
  +      *
  +      * @return the number of child collections.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public int getChildCollectionCount() throws XMLDBException {
  +
  +             checkOpen();
  +             try {
  +
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     Integer result = (Integer) 
runRemoteCommand("GetCollectionCount", params);
  +                     return result.intValue();
  +
  +             }
  +             catch(XMLDBException x){
  +             
  +                     throw x;  // propagate any xmldb exception.     
  +             }               
  +             catch (Exception e) {
  +                     throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  +             }
  +     }
  +
  +     /**
  +      * Returns a list of the ids for all resources stored in the collection.
  +      *
  +      * @return a string array containing the names for all
  +      *  <code>Resource</code>s in the collection.
  +      * @exception XMLDBException with expected error codes.<br />
  +      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +      *  specific errors that occur.<br />
  +      *  <code>ErrorCodes.COLLECTION_CLOSED</code> if the <code>close</code>
  +      *  method has been called on the <code>Collection</code><br />
  +      */
  +     public String[] listResources() throws XMLDBException {
  +
  +             checkOpen();
  +             try {
  +
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     Vector list = (Vector) 
runRemoteCommand("ListDocuments", params);
  +
  +                     return (String[]) list.toArray(new String[list.size()]);
  +             }
  +             catch(XMLDBException x){
  +             
  +                     throw x;  // propagate any xmldb exception.     
  +             }               
  +             catch (Exception e) {
  +
  +                     throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  +             }
  +     }
  +
  +     /* see superclass for documentation */
  +     public ResourceSet query(String name, String queryLang, String query, 
Hashtable nsMap) throws XMLDBException {
  +
  +             checkOpen();
  +             try {
  +
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     params.put(RPCDefaultMessage.TYPE, queryLang);
  +                     params.put(RPCDefaultMessage.NAMESPACES, nsMap);
  +                     params.put(RPCDefaultMessage.QUERY, query);
  +
  +                     if (name != null) {
  +
  +                             params.put(RPCDefaultMessage.NAME, name);
  +                     }
  +
  +                     String result = (String) runRemoteCommand("Query", 
params);
  +                     DocumentBuilderFactory dbf = 
DocumentBuilderFactory.newInstance();
  +                     dbf.setNamespaceAware(true);
  +                     Document resultDoc = dbf.newDocumentBuilder().parse(new 
InputSource(new StringReader(result)));
  +
  +                     ResourceSetImpl rs = new ResourceSetImpl(this, 
resultDoc);
  +
  +                     return rs;
  +             }
  +             catch (Exception e) {
  +
  +                     throw 
FaultCodes.createXMLDBException(FaultCodes.QRY_PROCESSING_ERROR, "Query error", 
e);
  +             }
  +     }
  +
  +     /* see superclass for documentation */
  +     public Collection createCollection(String name) throws XMLDBException {
  +             return createCollection(name, null);
  +     }
  +
  +     /* see superclass for documentation */
  +     public Collection createCollection(String name, Document configuration) 
throws XMLDBException {
  +             checkOpen();
  +             try {
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     params.put(RPCDefaultMessage.NAME, name);
  +                     if (configuration != null) {
  +                             params.put(RPCDefaultMessage.CONFIGURATION, 
TextWriter.toString(configuration));
  +                     }
  +
  +                     runRemoteCommand("CreateCollection", params);
  +
  +                     return getChildCollection(name);
  +             }
  +             catch(XMLDBException x){
  +             
  +                     throw x;  // propagate any xmldb exception.     
  +             }               
  +             catch (Exception e) {
  +                     throw new XMLDBException(ErrorCodes.INVALID_COLLECTION, 
"Cannot create child collection", e);
  +             }
  +     }
  +
  +     /* see superclass for documentation */
  +     public void removeCollection(String childName) throws XMLDBException {
  +
  +        // todo: shortcut the call and fail immediatly if the collection 
name is null or empty
  +
  +             checkOpen();
  +             try {
  +
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     params.put(RPCDefaultMessage.NAME, childName);
  +                     String result = (String) 
runRemoteCommand("RemoveCollection", params);
  +
  +                     if (!result.equals("yes")) {
  +
  +                             throw new 
XMLDBException(ErrorCodes.INVALID_COLLECTION, "Cannot remove child collection[" 
+ childName + "]");
  +                     }
  +             }
  +             catch(XMLDBException x){
  +             
  +                     throw x;  // propagate any xmldb exception.     
  +             }
  +             catch (Exception e) {
  +
  +                     throw new XMLDBException(ErrorCodes.INVALID_COLLECTION, 
"Cannot remove child collection[" + childName + "]", e);
  +             }
  +     }
  +
  +     /* see superclass for documentation */
  +     public String[] listIndexers() throws XMLDBException {
  +             checkOpen();
  +             try {
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     Vector list = (Vector) runRemoteCommand("ListIndexers", 
params);
  +
  +                     return (String[]) list.toArray(new String[list.size()]);
  +             }
  +             catch (Exception e) {
  +                     throw FaultCodes.createXMLDBException(e);
  +             }
  +     }
  +
  +     /* see superclass for documentation */
  +     public void createIndexer(Document configuration) throws XMLDBException 
{
  +             checkOpen();
  +             try {
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     params.put(RPCDefaultMessage.CONFIGURATION, 
TextWriter.toString(configuration));
  +
  +                     runRemoteCommand("CreateIndexer", params);
  +             }
  +             catch (Exception e) {
  +                     throw FaultCodes.createXMLDBException(e);
  +             }
  +     }
  +
  +     /* see superclass for documentation */
  +     public void dropIndexer(String name) throws XMLDBException {
  +             checkOpen();
  +             try {
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     params.put(RPCDefaultMessage.NAME, name);
  +
  +                     runRemoteCommand("RemoveIndexer", params);
  +             }
  +             catch (Exception e) {
  +                     throw FaultCodes.createXMLDBException(e);
  +             }
  +     }
  +
  +     /* see superclass for documentation */
  +     public void shutdown() throws XMLDBException {
  +             checkOpen();
  +             try {
  +                     Hashtable params = new Hashtable();
  +
  +                     runRemoteCommand("Shutdown", params);
  +             }
  +             catch (Exception e) {
  +                     throw FaultCodes.createXMLDBException(e);
  +             }
  +     }
  +
  +     public MetaData getMetaData(String id) throws XMLDBException {
  +             checkOpen();
  +             try {
  +                     Hashtable params = new Hashtable();
  +                     params.put(RPCDefaultMessage.COLLECTION, collPath);
  +                     if (id != null) {
  +                             params.put(RPCDefaultMessage.NAME, id);
  +                     }
  +                     params.put(RPCDefaultMessage.COMPRESSED, "true");
  +
  +                     Object result = runRemoteCommand(id == null? 
"GetCollectionMeta" : "GetDocumentMeta", params);
  +                     Document metaDoc = 
DOMParser.toDocument(result.toString());
  +                     MetaData meta = new MetaData(id);
  +                     meta.streamFromXML(metaDoc.getDocumentElement(), true);
  +                     return meta;
  +             }
  +             catch (Exception e) {
  +                     throw FaultCodes.createXMLDBException(e);
  +             }
  +     }
   }
  
  
  
  1.16      +74 -37    
xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java
  
  Index: CollectionImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- CollectionImpl.java       1 Aug 2003 19:35:51 -0000       1.15
  +++ CollectionImpl.java       4 Aug 2003 03:01:57 -0000       1.16
  @@ -1,3 +1,5 @@
  +package org.apache.xindice.client.xmldb.embed;
  +
   /*
    * The Apache Software License, Version 1.1
    *
  @@ -56,7 +58,8 @@
    *
    * $Id$
    */
  -package org.apache.xindice.client.xmldb.embed;
  +import java.util.Enumeration;
  +import java.util.Hashtable;
   
   import org.apache.xindice.client.xmldb.ResourceSetImpl;
   import org.apache.xindice.client.xmldb.XindiceCollection;
  @@ -70,10 +73,8 @@
   import org.apache.xindice.core.meta.MetaData;
   import org.apache.xindice.util.Configuration;
   import org.apache.xindice.xml.NamespaceMap;
  -import org.apache.xindice.xml.TextWriter;
   import org.apache.xindice.xml.dom.DBNode;
   import org.apache.xindice.xml.dom.DocumentImpl;
  -
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
   import org.w3c.dom.Node;
  @@ -84,9 +85,6 @@
   import org.xmldb.api.modules.BinaryResource;
   import org.xmldb.api.modules.XMLResource;
   
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -
   /**
    * Implementation of XML:DB's <code>Collection</code> interface using
    * direct access to interact with database server
  @@ -134,6 +132,7 @@
        *  method has been called on the <code>Collection</code><br />
        */
       public Resource getResource(String id) throws XMLDBException {
  +
           checkOpen();
           try {
               Object entry = col.getEntry(id);
  @@ -147,9 +146,11 @@
                   return new XMLResourceImpl(id, id, this, ((DocumentImpl) 
doc).getSymbols(), ((DocumentImpl) doc).getDataBytes());
   
               } else if (entry instanceof byte[]) {
  -                return new BinaryResourceImpl(id, entry);
  +                return new BinaryResourceImpl(id, (byte[]) entry);
               } else {
  -                throw new XMLDBException(ErrorCodes.UNKNOWN_RESOURCE_TYPE, 
"Internal error: unexpected type " + entry.getClass().getName());
  +                throw new XMLDBException(
  +                    ErrorCodes.UNKNOWN_RESOURCE_TYPE,
  +                    "Internal error: unexpected type " + 
entry.getClass().getName());
               }
           } catch (Exception e) {
               throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, "Message: " + 
e.getMessage(), e);
  @@ -168,6 +169,7 @@
        *  method has been called on the <code>Collection</code><br />
        */
       public int getResourceCount() throws XMLDBException {
  +
           checkOpen();
           try {
               return (int) col.getDocumentCount();
  @@ -191,6 +193,7 @@
        *  method has been called on the <code>Collection</code><br />
        */
       public void storeResource(Resource res) throws XMLDBException {
  +
           if (res.getContent() == null) {
               throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "no 
resource data");
           }
  @@ -263,6 +266,7 @@
        *  method has been called on the <code>Collection</code><br />
        */
       public org.xmldb.api.base.Collection getChildCollection(String name) 
throws XMLDBException {
  +
           if (name.indexOf('/') != -1) {
               throw new XMLDBException(ErrorCodes.INVALID_COLLECTION);
           }
  @@ -289,6 +293,7 @@
        *  method has been called on the <code>Collection</code><br />
        */
       public String createId() throws XMLDBException {
  +
           checkOpen();
           try {
               return col.createNewOID().toString();
  @@ -357,12 +362,15 @@
        *  method has been called on the <code>Collection</code><br />
        */
       public void removeResource(Resource res) throws XMLDBException {
  +
           if (!(res instanceof XMLResource)) {
               throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "Only XML 
resources supported");
           }
   
           if (res.getId() == null) {
  -            throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "This resource 
is a query result and can " + "not be removed from the database.");
  +            throw new XMLDBException(
  +                ErrorCodes.VENDOR_ERROR,
  +                "This resource is a query result and can " + "not be removed 
from the database.");
           }
   
           checkOpen();
  @@ -387,6 +395,7 @@
        *  method has been called on the <code>Collection</code><br />
        */
       public String[] listChildCollections() throws XMLDBException {
  +
           checkOpen();
           try {
               return col.listCollections();
  @@ -407,6 +416,7 @@
        *  method has been called on the <code>Collection</code><br />
        */
       public int getChildCollectionCount() throws XMLDBException {
  +
           checkOpen();
           try {
               return (int) col.countCollections();
  @@ -427,6 +437,7 @@
        *  method has been called on the <code>Collection</code><br />
        */
       public String[] listResources() throws XMLDBException {
  +
           checkOpen();
           try {
               return col.listDocuments();
  @@ -437,46 +448,26 @@
   
       /* see superclass for documentation */
       public ResourceSet query(String name, String queryLang, String query, 
Hashtable nsMap) throws XMLDBException {
  +
           checkOpen();
  -        try {
  -            // Copy the namespaces into a NamespaceMap.
  -            NamespaceMap namespaces = new NamespaceMap();
  -            Enumeration keys = nsMap.keys();
  -            while (keys.hasMoreElements()) {
  -                String key = (String) keys.nextElement();
  -                namespaces.put(key, nsMap.get(key));
  -            }
   
  +        try {
               NodeSet result;
               if (name != null) {
  -                result = col.queryDocument(queryLang, query, namespaces, 
name);
  +                result = col.queryDocument(queryLang, query, 
createNamespaceMap(nsMap), name);
               } else {
  -                result = col.queryCollection(queryLang, query, namespaces);
  +                result = col.queryCollection(queryLang, query, 
createNamespaceMap(nsMap));
               }
   
  -            ResourceSetImpl rs = new ResourceSetImpl(this, null);
  -
  -            while (result.hasMoreNodes()) {
  -
  -                Node n = result.getNextNode();
  -                if (n instanceof DBNode) {
  -                    ((DBNode) n).expandSource();
  -                }
  -
  -                String documentId = ((Element) n).getAttributeNS(QUERY_NS, 
"key");
  -
  -                XMLResourceImpl resource = new XMLResourceImpl(null, 
documentId, this, TextWriter.toString(n));
  -                rs.addResource(resource);
  -            }
  -
  -            return rs;
  +            return new ResourceSetImpl(this, nodesetToDocument(result));
           } catch (Exception e) {
  -            throw 
FaultCodes.createXMLDBException(FaultCodes.QRY_PROCESSING_ERROR, "Query error", 
e);
  +            throw 
FaultCodes.createXMLDBException(FaultCodes.QRY_PROCESSING_ERROR, "Query error: 
" + e.getLocalizedMessage(), e);
           }
       }
   
       /* see superclass for documentation */
       public org.xmldb.api.base.Collection createCollection(String name) 
throws XMLDBException {
  +
           checkOpen();
           try {
               Document doc = new DocumentImpl();
  @@ -511,6 +502,7 @@
   
       /* see superclass for documentation */
       public void removeCollection(String childName) throws XMLDBException {
  +
           checkOpen();
           try {
               col.dropCollection(col.getCollection(childName));
  @@ -556,6 +548,51 @@
           } catch (Exception e) {
               throw FaultCodes.createXMLDBException(e);
           }
  +    }
  +
  +    // search result handling
  +
  +    private Document nodesetToDocument(NodeSet ns) {
  +        // Turn the NodeSet into a document.
  +        DocumentImpl doc = new DocumentImpl();
  +
  +        Element root = doc.createElement("result");
  +        doc.appendChild(root);
  +        int count = 0;
  +        while (ns != null && ns.hasMoreNodes()) {
  +            Node n = ns.getNextNode();
  +
  +            if (n.getNodeType() == Node.DOCUMENT_NODE) {
  +                n = ((Document) n).getDocumentElement();
  +            }
  +
  +            if (n instanceof DBNode) {
  +                ((DBNode) n).expandSource();
  +            }
  +
  +            root.appendChild(doc.importNode(n, true));
  +            count++;
  +        }
  +
  +        root.setAttribute("count", Integer.toString(count));
  +
  +        return doc;
  +    }
  +
  +    private NamespaceMap createNamespaceMap(Hashtable namespaces) {
  +        NamespaceMap nsMap = null;
  +
  +        if (namespaces.size() > 0) {
  +            nsMap = new NamespaceMap();
  +
  +            Enumeration keys = namespaces.keys();
  +            while (keys.hasMoreElements()) {
  +                String key = (String) keys.nextElement();
  +                nsMap.setNamespace(key, (String) namespaces.get(key));
  +            }
  +        }
  +
  +        return nsMap;
       }
   
       public MetaData getMetaData(String id) throws XMLDBException {
  
  
  
  1.4       +74 -3     
xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/XPathQueryTest.java
  
  Index: XPathQueryTest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/XPathQueryTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XPathQueryTest.java       10 Apr 2003 18:33:41 -0000      1.3
  +++ XPathQueryTest.java       4 Aug 2003 03:01:57 -0000       1.4
  @@ -60,10 +60,14 @@
   package org.apache.xindice.integration.client.services;
   
   import org.apache.xindice.integration.client.AbstractXmlDbClientTest;
  +import org.apache.xindice.xml.TextWriter;
  +import org.custommonkey.xmlunit.XMLAssert;
   
  +import org.w3c.dom.Node;
   import org.xmldb.api.base.Collection;
   import org.xmldb.api.base.ResourceIterator;
   import org.xmldb.api.base.ResourceSet;
  +import org.xmldb.api.modules.XMLResource;
   import org.xmldb.api.modules.XPathQueryService;
   
   import java.util.ArrayList;
  @@ -241,7 +245,73 @@
           List res = asList(results);
           assertEquals(1, res.size());
       }
  +   
  +   public void testGetSingleTextNode() throws Exception
  +   {
  +             String query = "//person[first='John' and 
last='Smith']/first/text()";
  +
  +             Collection col = 
this.client.getCollection(TEST_COLLECTION_PATH);
  +             XPathQueryService xpathservice = (XPathQueryService) 
col.getService("XPathQueryService", "1.0");
  +             ResourceSet resultSet = xpathservice.query(query);
  +
  +             ResourceIterator results = resultSet.getIterator();
  +
  +             List res = asList(results);
  +             assertEquals(1, res.size());
  +   }
       
  +     public void testGetMultipleTextNodes() throws Exception
  +     {
  +             String query = "//person/first/text()";
  +
  +             Collection col = 
this.client.getCollection(TEST_COLLECTION_PATH);
  +             XPathQueryService xpathservice = (XPathQueryService) 
col.getService("XPathQueryService", "1.0");
  +             ResourceSet resultSet = xpathservice.query(query);
  +
  +             ResourceIterator results = resultSet.getIterator();
  +
  +             List res = asList(results);
  +             assertEquals(2, res.size());
  +     }
  +     
  +     public void testNamespaceDOM() throws Exception
  +     {
  +             String document3 = "<?xml version=\"1.0\"?>" +
  +                               "<p:person 
xmlns:p='http://example.net/person' >" +
  +                               "<p:first>Sally</p:first>" +
  +                               "<p:last>Smith</p:last>" +
  +                               "<p:phone 
type=\"work\">555-345-6789</p:phone>" +
  +                               "</p:person>";
  +             this.client.insertDocument(TEST_COLLECTION_PATH, "doc3", 
document3);
  +
  +             String query = "//h:person[h:first='Sally' and 
h:last='Smith']/h:first";
  +       
  +             Collection col = 
this.client.getCollection(TEST_COLLECTION_PATH);
  +             XPathQueryService xpathservice = (XPathQueryService) 
col.getService("XPathQueryService", "1.0");
  +             xpathservice.setNamespace("h", "http://example.net/person";);
  +             
  +             ResourceSet resultSet = xpathservice.query(query);
  +
  +             ResourceIterator results = resultSet.getIterator();
  +             List res = asList(results);
  +             assertEquals(1, res.size());
  +
  +             XMLResource resource = (XMLResource) resultSet.getResource(0);
  +             
  +             // ensure that the resource has the correct doc id.
  +             assertEquals("doc3", resource.getDocumentId());
  +
  +             Node node = resource.getContentAsDOM();
  +
  +             // add source node information to the compared xml as it's 
added by
  +             // the query processor.
  +             XMLAssert.assertXMLEqual("<first 
xmlns:src='http://xml.apache.org/xindice/Query' src:col='/db/testing/current' 
src:key='doc3' xmlns='http://example.net/person'>Sally</first>", 
TextWriter.toString(node));             
  +             
  +             this.client.removeDocument(TEST_COLLECTION_PATH, "doc3");
  +     }
  +     
  +     
  +
       public static List asList(ResourceIterator iter)
               throws Exception {
           if (iter == null) {
  @@ -255,6 +325,7 @@
           }
           return result;
       }
  -
  +     
  +     
   }
   
  
  
  
  1.2       +4 -2      
xml-xindice/java/tests/src/org/apache/xindice/integration/IntegrationTests.java
  
  Index: IntegrationTests.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/IntegrationTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IntegrationTests.java     28 Nov 2002 08:12:26 -0000      1.1
  +++ IntegrationTests.java     4 Aug 2003 03:01:57 -0000       1.2
  @@ -62,6 +62,7 @@
   import org.apache.xindice.integration.client.basic.CollectionTest;
   import org.apache.xindice.integration.client.basic.DocumentTest;
   import org.apache.xindice.integration.client.basic.IndexTest;
  +import org.apache.xindice.integration.client.services.XPathQueryTest;
   import org.apache.xindice.integration.client.services.XUpdateQueryTest;
   
   import junit.framework.TestSuite;
  @@ -78,6 +79,7 @@
           suite.addTestSuite(IndexTest.class);
           suite.addTestSuite(DocumentTest.class);
           suite.addTestSuite(XUpdateQueryTest.class);
  +        suite.addTestSuite(XPathQueryTest.class);
   
           return suite;
       }
  
  
  
  1.7       +7 -3      
xml-xindice/java/tests/src/org/apache/xindice/integration/client/basic/CollectionTest.java
  
  Index: CollectionTest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/client/basic/CollectionTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CollectionTest.java       14 Jul 2003 21:26:11 -0000      1.6
  +++ CollectionTest.java       4 Aug 2003 03:01:57 -0000       1.7
  @@ -227,11 +227,15 @@
           assertEquals("testing", parent.getName());
   
           parent = parent.getParentCollection();
  +        
  +        // is this assertion correct? The xml rpc driver exposes the "db" 
collection
  +        // the embeded doesn't. I think the xmlrpc driver is correct, and 
the test
  +        // is wrong, just looking for someone to confirm this.
           assertNull(parent);
   
           this.client.dropCollection(TEST_COLLECTION_PATH, "childcol");
       }
  -
  +    
       public void testGetCollectionUnknown() throws Exception {
           assertNull(this.client.getCollection(TEST_COLLECTION_PATH + 
"/unknown"));
       }
  
  
  
  1.17      +21 -18    
xml-xindice/java/src/org/apache/xindice/client/xmldb/DatabaseImpl.java
  
  Index: DatabaseImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/DatabaseImpl.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DatabaseImpl.java 1 Aug 2003 19:40:16 -0000       1.16
  +++ DatabaseImpl.java 4 Aug 2003 03:01:57 -0000       1.17
  @@ -58,11 +58,9 @@
    *
    * $Id$
    */
  -
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.xindice.client.xmldb.managed.ManagedDatabaseImpl;
  -
   import org.xmldb.api.base.Database;
   import org.xmldb.api.base.ErrorCodes;
   import org.xmldb.api.base.XMLDBException;
  @@ -101,7 +99,7 @@
       public static String INSTANCE_NAME = "xindice, xindice-embed, 
xindice-managed";
   
       /**
  -     * The XML:DB API Core Level Conformance of this implementation.
  +       * The XML:DB API Core Level Conformance of this implementation.
        */
       public static String CONFORMANCE_LEVEL = "0";
   
  @@ -186,22 +184,19 @@
        * @see #getCollection for a description of the URI's format
        */
       public boolean acceptsURI(String uri) throws XMLDBException {
  -        if (uri == null || uri.equals("")) {
  -            return false;
  -        }
  -
  -        createDriver(uri);
  -        if (driver == null) {
  -            return false;
  -        } else {
  +        if (uri != null && uri.length() > 0 && knownPrefix(uri)) {
  +            // ensure the driver is initialised
  +            createDriver(uri);
               return driver.acceptsURI(uri);
           }
  +
  +        return false;
       }
   
       protected void createDriver(String uri) throws XMLDBException {
           // Determine which driver was requested.
  -        try {
  -            if (driver == null) {
  +        if (driver == null) {
  +            try {
                   if (uri.startsWith(XMLRPC_URI)) {
                       /*
                        * The only way that a particular instance of 
xmlrpc.DatabaseImpl
  @@ -216,13 +211,21 @@
                       driver = new 
org.apache.xindice.client.xmldb.embed.DatabaseImpl();
                   } else if (uri.startsWith(MANAGED_URI)) {
                       driver = new ManagedDatabaseImpl();
  -                } else {
  -                    throw new XMLDBException(ErrorCodes.INVALID_URI, uri);
                   }
  +            } catch (Exception e) {
  +                log.error("Exception during creation of the Database", e);
  +                throw new XMLDBException(ErrorCodes.INVALID_URI, uri, e);
  +            }
  +
  +            // moved to avoid double catching a creation exception
  +            if (null == driver) {
  +                log.warn("The uri '" + uri + "' is not handled be xindice");
  +                throw new XMLDBException(ErrorCodes.INVALID_URI, uri);
               }
  -        } catch (Exception e) {
  -            log.info("Exception during creation of the Database", e);
  -            throw new XMLDBException(ErrorCodes.INVALID_URI, uri, e);
           }
  +    }
  +
  +    protected boolean knownPrefix(String uri) {
  +        return (uri.startsWith(XMLRPC_URI) || (uri.startsWith(EMBED_URI)) || 
uri.startsWith(MANAGED_URI));
       }
   }
  
  
  
  1.9       +171 -165  
xml-xindice/java/src/org/apache/xindice/client/xmldb/ResourceSetImpl.java
  
  Index: ResourceSetImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/ResourceSetImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ResourceSetImpl.java      1 Aug 2003 19:40:16 -0000       1.8
  +++ ResourceSetImpl.java      4 Aug 2003 03:01:57 -0000       1.9
  @@ -66,10 +66,7 @@
   import org.apache.xindice.xml.dom.DOMCompressor;
   import org.apache.xindice.xml.dom.DocumentImpl;
   
  -import org.w3c.dom.Document;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  +import org.w3c.dom.*;
   import org.xmldb.api.base.ErrorCodes;
   import org.xmldb.api.base.Resource;
   import org.xmldb.api.base.ResourceIterator;
  @@ -86,171 +83,180 @@
    * or other operation.
    */
   public class ResourceSetImpl implements ResourceSet {
  -    public static final String RESOURCE_SET_NS =
  -            "http://www.xmldb.org/xapi/ResourceSet";;
  -    protected List resources = null;
  -    protected org.xmldb.api.base.Collection collection = null;
  -
  -    private SymbolTable symbols = null;
  -    private byte[] bytes = null;
  -
  -    public ResourceSetImpl(org.xmldb.api.base.Collection collection,
  -                           Document doc) throws XMLDBException {
  -        this.collection = collection;
  -
  -        if (doc != null) {
  -            initResources(doc);
  -        } else {
  -            resources = Collections.synchronizedList(new ArrayList());
  -        }
  -    }
  -
  -    public ResourceSetImpl(org.xmldb.api.base.Collection collection,
  -                           SymbolTable symbols, byte[] bytes) throws 
XMLDBException {
  -        this.collection = collection;
  -        this.symbols = symbols;
  -        this.bytes = bytes;
  -
  -        initResources(new DocumentImpl(bytes, symbols, null));
  -    }
  -
  -    protected void initResources(Document document) throws XMLDBException {
  -        NodeList nodes = document.getDocumentElement().getChildNodes();
  -        this.resources =
  -                Collections.synchronizedList(new 
ArrayList(nodes.getLength()));
  -
  -        int i = 0;
  -        while (i < nodes.getLength()) {
  -            try {
  -                XMLResource resource;
  -                Node n = nodes.item(i);
  -                String documentId = ((Element) n).getAttributeNS(
  -                        NodeSource.SOURCE_NS, "key");
  -
  -                if (bytes != null) {
  -                    DocumentImpl doc = new DocumentImpl();
  -                    doc.setSymbols(symbols);
  -                    doc.importNode(n, true);
  -                    doc.appendChild(n);
  -                    byte[] b = DOMCompressor.Compress(doc, symbols);
  -                    resource = new XMLResourceImpl(null, documentId, 
collection,
  -                                                   symbols, b);
  -                } else {
  -                    resource = new XMLResourceImpl(null, documentId, 
collection,
  -                                                   TextWriter.toString(n));
  -                }
  -
  -                i++;
  -                resources.add(resource);
  -            } catch (Exception e) {
  -                throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  +   public static final String RESOURCE_SET_NS =
  +      "http://www.xmldb.org/xapi/ResourceSet";;
  +   protected List resources = null;
  +   protected org.xmldb.api.base.Collection collection = null;
  +
  +   private SymbolTable symbols = null;
  +   private byte[] bytes = null;
  +
  +   public ResourceSetImpl(org.xmldb.api.base.Collection collection,
  +         Document doc) throws XMLDBException {
  +      this.collection = collection;
  +
  +      if ( doc != null ) {
  +         initResources(doc);
  +      }
  +      else {
  +         resources = Collections.synchronizedList(new ArrayList());
  +      }
  +   }
  +
  +   public ResourceSetImpl(org.xmldb.api.base.Collection collection,
  +         SymbolTable symbols, byte[] bytes) throws XMLDBException {
  +      this.collection = collection;
  +      this.symbols = symbols;
  +      this.bytes = bytes;
  +
  +      initResources(new DocumentImpl(bytes, symbols, null));
  +   }
  +
  +   protected void initResources(Document document) throws XMLDBException {
  +      NodeList nodes = document.getDocumentElement().getChildNodes();
  +      this.resources =
  +         Collections.synchronizedList(new ArrayList(nodes.getLength()));
  +
  +      int i = 0;
  +      while ( i < nodes.getLength() ) {
  +        try {
  +            XMLResource resource;
  +            Node n = nodes.item(i);
  +            
  +                     String documentId = null;
  +            
  +            if (n instanceof Element)
  +            {
  +                 documentId = ((Element) n).getAttributeNS(
  +                    NodeSource.SOURCE_NS, "key");
  +            }
  +            
  +            if ( bytes != null ) {
  +               DocumentImpl doc = new DocumentImpl();
  +               doc.setSymbols(symbols);
  +               doc.importNode(n, true);
  +               doc.appendChild(n);
  +               byte[] b = DOMCompressor.Compress(doc, symbols);
  +               resource = new XMLResourceImpl(null, documentId, collection,
  +                  symbols, b);
  +            }
  +            else {
  +               resource = new XMLResourceImpl(null, documentId, collection,
  +                  TextWriter.toString(n));
               }
  -        }
  -    }
  -
  -    /**
  -     * Returns an iterator over all <code>Resource</code> instances stored in
  -     * the set.
  -     *
  -     * @return a ResourceIterator over all <code>Resource</code> instances 
in the
  -     *  set.
  -     * @exception XMLDBException
  -     */
  -    public ResourceIterator getIterator() throws XMLDBException {
  -        return new ResourceIteratorImpl(resources);
  -    }
  -
  -    /**
  -     * Returns the <code>Resource</code> instance stored at the index 
specified
  -     * by <code>index</code>.
  -     *
  -     * @param index the index of the resource to retrieve.
  -     * @return the <code>Resource</code> instance.
  -     * @exception XMLDBException
  -     */
  -    public Resource getResource(long index) throws XMLDBException {
  -        return (XMLResource) resources.get((int) index);
  -    }
  -
  -    /**
  -     * Returns the number of resources contained in the set.
  -     *
  -     * @return the number of <code>Resource</code> instances in the set.
  -     * @exception XMLDBException
  -     */
  -    public long getSize() throws XMLDBException {
  -        return resources.size();
  -    }
  -
  -    /**
  -     * Adds a <code>Resource</code> instance to the set.
  -     *
  -     * @exception XMLDBException
  -     */
  -    public void addResource(Resource res) throws XMLDBException {
  -        resources.add(res);
  -    }
  -
  -    /**
  -     * Removes all <code>Resource</code> instances from the set.
  -     *
  -     * @exception XMLDBException
  -     */
  -    public void clear() throws XMLDBException {
  -        resources.clear();
  -    }
  -
  -    /**
  -     * Removes the <code>Resource</code> located at <code>index</code> from 
the
  -     * set.
  -     *
  -     * @param index The index of the <code>Resource</code> instance to 
remove.
  -     * @exception XMLDBException
  -     */
  -    public void removeResource(long index) throws XMLDBException {
  -        resources.remove((int) index);
  -    }
  -
  -    /**
  -     * Returns a <code>Resource</code> containing an XML representation of 
all
  -     * resources stored in the set.
  -     *
  -     * @return A <code>Resource</code> instance containing an XML 
representation
  -     *  of all set members.
  -     * @exception XMLDBException
  -     */
  -    public Resource getMembersAsResource() throws XMLDBException {
  -        // This impl works but it would be nice if we just got the result 
set from
  -        // the server in this format instead of having to build it. Right 
now it's
  -        // pretty innefficient
  -        Document doc = new DocumentImpl();
  -
  -        Element set = doc.createElementNS(RESOURCE_SET_NS, 
"xapi:resourceSet");
  -        set.setAttributeNS(RESOURCE_SET_NS, "xapi:collectionURI",
  -                           "xmldb:xindice://" + ((XindiceCollection) 
collection).getCanonicalName());
  -        set.setAttribute("xmlns:xapi", RESOURCE_SET_NS);
  -        doc.appendChild(set);
  -
  -        int i = 0;
  -        while (i < resources.size()) {
  -            XMLResource res = (XMLResource) resources.get(i);
  -            Element resource = doc.createElementNS(RESOURCE_SET_NS,
  -                                                   "xapi:resource");
  -            resource.setAttributeNS(RESOURCE_SET_NS, "xapi:documentID",
  -                                    res.getDocumentId());
  -
  -            resource.appendChild(doc.importNode(
  -                    ((Document) res.getContentAsDOM()).getDocumentElement(), 
true));
  -
  -            set.appendChild(resource);
   
               i++;
  -        }
  +            resources.add(resource);
  +         }
  +         catch (Exception e) {
  +            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
  +         }
  +      }
  +   }
  +
  +   /**
  +    * Returns an iterator over all <code>Resource</code> instances stored in
  +    * the set.
  +    *
  +    * @return a ResourceIterator over all <code>Resource</code> instances in 
the
  +    *  set.
  +    * @exception XMLDBException
  +    */
  +   public ResourceIterator getIterator() throws XMLDBException {
  +      return new ResourceIteratorImpl(resources);
  +   }
  +
  +   /**
  +    * Returns the <code>Resource</code> instance stored at the index 
specified
  +    * by <code>index</code>.
  +    *
  +    * @param index the index of the resource to retrieve.
  +    * @return the <code>Resource</code> instance.
  +    * @exception XMLDBException
  +    */
  +   public Resource getResource(long index) throws XMLDBException {
  +      return (XMLResource) resources.get((int) index);
  +   }
  +
  +   /**
  +    * Returns the number of resources contained in the set.
  +    *
  +    * @return the number of <code>Resource</code> instances in the set.
  +    * @exception XMLDBException
  +    */
  +   public long getSize() throws XMLDBException {
  +      return resources.size();
  +   }
  +
  +   /**
  +    * Adds a <code>Resource</code> instance to the set.
  +    *
  +    * @exception XMLDBException
  +    */
  +   public void addResource(Resource res) throws XMLDBException {
  +      resources.add(res);
  +   }
  +
  +   /**
  +    * Removes all <code>Resource</code> instances from the set.
  +    *
  +    * @exception XMLDBException
  +    */
  +   public void clear() throws XMLDBException {
  +      resources.clear();
  +   }
  +
  +   /**
  +    * Removes the <code>Resource</code> located at <code>index</code> from 
the
  +    * set.
  +    *
  +    * @param index The index of the <code>Resource</code> instance to remove.
  +    * @exception XMLDBException
  +    */
  +   public void removeResource(long index) throws XMLDBException {
  +      resources.remove((int) index);
  +   }
  +
  +   /**
  +    * Returns a <code>Resource</code> containing an XML representation of all
  +    * resources stored in the set.
  +    *
  +    * @return A <code>Resource</code> instance containing an XML 
representation
  +    *  of all set members.
  +    * @exception XMLDBException
  +    */
  +   public Resource getMembersAsResource() throws XMLDBException {
  +      // This impl works but it would be nice if we just got the result set 
from
  +      // the server in this format instead of having to build it. Right now 
it's
  +      // pretty innefficient
  +      Document doc = new DocumentImpl();
  +
  +      Element set = doc.createElementNS(RESOURCE_SET_NS, "xapi:resourceSet");
  +      set.setAttributeNS(RESOURCE_SET_NS, "xapi:collectionURI",
  +         "xmldb:xindice://" + ((XindiceCollection) 
collection).getCanonicalName());
  +      set.setAttribute("xmlns:xapi", RESOURCE_SET_NS);
  +      doc.appendChild(set);
  +
  +      int i = 0;
  +      while ( i < resources.size() ) {
  +         XMLResource res = (XMLResource) resources.get(i);
  +         Element resource = doc.createElementNS(RESOURCE_SET_NS,
  +            "xapi:resource");
  +         resource.setAttributeNS(RESOURCE_SET_NS, "xapi:documentID",
  +            res.getDocumentId());
  +
  +         resource.appendChild(doc.importNode(
  +            ((Document) res.getContentAsDOM()).getDocumentElement(), true));
  +
  +         set.appendChild(resource);
  +
  +         i++;
  +      }
   
  -        XMLResource result = new XMLResourceImpl(null, null,
  -                                                 collection, 
TextWriter.toString(doc));
  +      XMLResource result = new XMLResourceImpl(null, null,
  +         collection, TextWriter.toString(doc));
   
  -        return result;
  -    }
  +      return result;
  +   }
   }
   
  
  
  
  1.6       +6 -4      
xml-xindice/java/tests/src/org/apache/xindice/IntegrationXmlRpcTests.java
  
  Index: IntegrationXmlRpcTests.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/IntegrationXmlRpcTests.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- IntegrationXmlRpcTests.java       14 Jul 2003 21:25:46 -0000      1.5
  +++ IntegrationXmlRpcTests.java       4 Aug 2003 03:01:57 -0000       1.6
  @@ -92,7 +92,7 @@
       public static Test suite() throws Exception {
   
           String url = "xmldb:xindice://";
  -        String hostport = System.getProperty("test.xmlrpc.hostport");
  +        String hostport = System.getProperty("test.xmlrpc.hostport", 
"localhost:8888");
           if (hostport != null) {
               url = url + hostport;
           }
  @@ -101,7 +101,8 @@
               private Database database;
   
               public void setUp() throws Exception {
  -                String driver = 
"org.apache.xindice.client.xmldb.DatabaseImpl";
  +                String driver = 
"org.apache.xindice.client.xmldb.xmlrpc.DatabaseImpl";
  +                //String driver = 
"org.apache.xindice.client.xmldb.DatabaseImpl";
                   Class cls = Class.forName(driver);
   
                   database = (Database) cls.newInstance();
  @@ -113,6 +114,7 @@
                   if (xmlrpcDriver != null) {
                       database.setProperty("xmlrpc-driver", xmlrpcDriver);
                   }
  +                
                   DatabaseManager.registerDatabase(database);
               }
   
  
  
  
  1.5       +5 -4      
xml-xindice/java/src/org/apache/xindice/server/rpc/messages/RemoveCollection.java
  
  Index: RemoveCollection.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/rpc/messages/RemoveCollection.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RemoveCollection.java     1 Aug 2003 19:40:20 -0000       1.4
  +++ RemoveCollection.java     4 Aug 2003 03:01:57 -0000       1.5
  @@ -76,15 +76,16 @@
               throw new Exception(MISSING_COLLECTION_PARAM);
           }
   
  -        if (!message.containsKey(NAME)) {
  +        final String childName= (String) message.get(NAME);
  +        if (null == childName || childName.length() == 0)
  +        {
               throw new Exception(MISSING_NAME_PARAM);
           }
   
           Hashtable result = new Hashtable();
           try {
  -
  -            Collection col = getCollection((String) message.get(COLLECTION)
  -                                           + "/" + (String) 
message.get(NAME));
  +                        
  +            Collection col = getCollection((String) message.get(COLLECTION) 
+ "/" + childName);
               col.dropCollection(col);
               result.put(RESULT, "yes");
   
  
  
  
  1.19      +540 -539  
xml-xindice/java/src/org/apache/xindice/tools/XMLTools.java
  
  Index: XMLTools.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/XMLTools.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- XMLTools.java     1 Aug 2003 19:40:20 -0000       1.18
  +++ XMLTools.java     4 Aug 2003 03:01:57 -0000       1.19
  @@ -59,6 +59,12 @@
    * $Id$
    */
   
  +import java.io.File;
  +import java.io.FileInputStream;
  +import java.io.FileNotFoundException;
  +import java.util.Hashtable;
  +import java.util.NoSuchElementException;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.xindice.client.xmldb.DatabaseImpl;
  @@ -71,16 +77,11 @@
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
   import org.w3c.dom.NodeList;
  +
   import org.xmldb.api.DatabaseManager;
   import org.xmldb.api.base.Database;
   import org.xmldb.api.base.XMLDBException;
   
  -import java.io.File;
  -import java.io.FileInputStream;
  -import java.io.FileNotFoundException;
  -import java.util.Hashtable;
  -import java.util.NoSuchElementException;
  -
   
   /**
    * XMLAdmin is designed to take command line arguments and give
  @@ -110,519 +111,519 @@
       public static final String NAMESPACES = "namespaces";
       public static final String IMPL_CLASS = "implClass";
   
  -    private static Log log = 
LogFactory.getLog("org.apache.xindice.XMLTools");
  -
  -    private Hashtable table;
  -    protected String location = null;
  -    private boolean initialized = false;
  -    private static boolean verbose = false;
  -
  -    public static void main(String[] args) {
  -        try {
  -            new XMLTools().process(args);
  -        } catch (Exception e) {
  -            System.out.println(e.getMessage());
  -            if (verbose == true) {
  -                e.printStackTrace(System.err);
  -            }
  -        }
  -    }
  -
  -    /** Constructor for XMLTools, includes default variables for the command 
line
  -     */
  -    public XMLTools() {
  -        table = new Hashtable();
  -        // defaults for command switches
  -        table.put(FILE_PATH, "");
  -        table.put(EXTENSION, "");
  -        table.put(QUERY, "");
  -        table.put(AUTO_KEY, "");
  -        table.put(VERBOSE, "false");
  -    }
  -
  -    protected void initCommandsList() {
  -        // Get all user elements
  -        NodeList list = getCommandsDocument().getElementsByTagName("user");
  -
  -        if (list.getLength() > 0) {
  -            // Retrieve the index of the first element (<user>)
  -            Element node = (Element) list.item(0);
  -            // get all command children from the user element
  -            list = node.getElementsByTagName("command");
  -        }
  +   private static Log log = LogFactory.getLog("org.apache.xindice.XMLTools");
   
  -        // Return the list generated
  -        commandsList = list;
  -    }
  -
  -    /** Return true if this class has admin access
  -     */
  -    public boolean isAdmin() {
  -        return false;
  -    }
  -
  -    /**
  +   private Hashtable table;
  +   protected String location = null;
  +   private boolean initialized = false;
  +   private static boolean verbose = false;
  +
  +   public static void main(String[] args) {
  +       try {
  +          new XMLTools().process(args);
  +       }
  +       catch (Exception e) {
  +           System.out.println(e.getMessage());
  +           if (verbose == true) {
  +               e.printStackTrace(System.err);
  +           }
  +       }
  +   }
  +
  +   /** Constructor for XMLTools, includes default variables for the command 
line
  +     */
  +   public XMLTools() {
  +      table = new Hashtable();
  +      // defaults for command switches
  +      table.put( FILE_PATH, "" );
  +      table.put( EXTENSION, "" );
  +      table.put( QUERY, "" );
  +      table.put( AUTO_KEY, "" );
  +      table.put( VERBOSE, "false" );
  +   }
  +
  +   protected void initCommandsList() {
  +       // Get all user elements
  +       NodeList list = getCommandsDocument().getElementsByTagName("user");
  +
  +       if ( list.getLength() > 0 ) {
  +           // Retrieve the index of the first element (<user>)
  +           Element node = (Element) list.item(0);
  +           // get all command children from the user element
  +           list = node.getElementsByTagName( "command" );
  +       }
  +
  +       // Return the list generated
  +       commandsList = list;
  +   }
  +
  +   /** Return true if this class has admin access
  +       */
  +   public boolean isAdmin() {
  +       return false;
  +   }
  +   
  +   /**
        * Carries out necessary initialization of this class.
        **/
       public void init() throws XindiceException, FileNotFoundException {
  -        if (!initialized) {
  -            initCommandsDocument();
  -            initCommandsList();
  -            initialized = true;
  -        }
  +       if ( !initialized ) {
  +           initCommandsDocument();
  +           initCommandsList();
  +           initialized = true;
  +       }
       }
  -
       /**
        * Carries out the initialization of the Commands Document.
        **/
       protected void initCommandsDocument() throws XindiceException, 
FileNotFoundException {
  -        // Absolute path to the commands.xml file, relative to $XINDICE_HOME
  -        File xindiceHome = new 
File(System.getProperty(Xindice.PROP_XINDICE_HOME));
  -        File commandsFile = new File(xindiceHome, "config/commands.xml");
  +       // Absolute path to the commands.xml file, relative to $XINDICE_HOME
  +       File xindiceHome =  new File( System.getProperty( 
Xindice.PROP_XINDICE_HOME, "." ) );
  +       File commandsFile = new File( xindiceHome, "config/commands.xml" );
   
  -        commandsDocument = DOMParser.toDocument(new 
FileInputStream(commandsFile));
  +       commandsDocument = DOMParser.toDocument( new FileInputStream( 
commandsFile ) );
       }
   
       private Document commandsDocument = null;
  -
       /**
        * Returns the Commands Document use for configuration.
        **/
       protected Document getCommandsDocument() {
  -        return commandsDocument;
  +       return commandsDocument;
       }
   
   
       protected NodeList commandsList = null;
  -
       /**
        * Returns the <command> elements from the Commands Document this
        * tool can execute.
        **/
       protected NodeList getCommands() {
  -        return commandsList;
  +       return commandsList;
       }
   
  -    /**
  -     * The Process function is designed for the implementation of the
  -     * command line tools, as well as, making the command line easier
  -     * to use.
  -     **/
  -    public void process(String[] args) throws XindiceException, Exception {
  -        try {
  -            init();
  -            parseArguments(args);
  +   /**
  +    * The Process function is designed for the implementation of the
  +    * command line tools, as well as, making the command line easier
  +    * to use.
  +    **/
  +   public void process(String[] args) throws XindiceException, Exception {
  +      try {
  +         init();
  +         parseArguments(args);
   
  -            if (!execute()) {
  -                printHelp();
  -            }
  -        } catch (IllegalArgumentException e) {
  +         if ( !execute() ) {
               printHelp();
  -            throw new XindiceException("ERROR : " + e.getMessage(), e);
  -        } catch (NoSuchElementException e) {
  -            throw new NoSuchElementException("ERROR : " + e + " Switch 
found. Parameter missing.");
  -        } catch (NullPointerException e) {
  -            e.printStackTrace(System.err);
  -            throw new NullPointerException("ERROR : " + e);
  -        } catch (Exception e) {
  -            e.printStackTrace(System.err);
  -            throw new XindiceException("ERROR : " + e.getMessage(), e);
  -        }
  -    }
  -
  -    /**
  -     * Parses and validated the arguments of the command line. The arguments 
are
  -     * stored into the <tt>table</tt> array.
  -     *
  -     * @exception IllegalArgumentException if an error is found
  -     */
  -    protected void parseArguments(String[] args)
  -            throws IllegalArgumentException {
  -        // parsing arguments for the command tools
  -        ArgTokenizer at = new ArgTokenizer(args);
  -
  -        if (!at.hasMoreTokens()) {
  -            throw new IllegalArgumentException("No argument found");
  -        }
  -
  -        // Action should always be the second token, if not there show help
  -        table.put(ACTION, at.nextToken());
  -
  -        // Loop over remaining command line arguments, populating hashtable
  -        while (at.hasMoreTokens()) {
  -            String token = at.nextToken();
  -
  -            if (token.equalsIgnoreCase("-c") || 
token.equalsIgnoreCase("--collection")) {
  -                String colname = at.nextSwitchToken();
  -                if (!colname.startsWith("/") &&
  -                        !colname.startsWith("xmldb:xindice")) {
  -                    throw new IllegalArgumentException("The name of a 
collection must start with '/'");
  -                }
  -                table.put(COLLECTION, colname);
  -            } else if (token.equalsIgnoreCase("-e") || 
token.equalsIgnoreCase("--extension")) {
  -                table.put(EXTENSION, at.nextSwitchToken());
  -            } else if (token.equalsIgnoreCase("-f") || 
token.equalsIgnoreCase("--filepath")) {
  -                table.put(FILE_PATH, at.nextSwitchToken());
  -            } else if (token.equalsIgnoreCase("-h") || 
token.equalsIgnoreCase("--help")) {
  -                table.put(ACTION, "help");
  -            } else if (token.equalsIgnoreCase("-n") || 
token.equalsIgnoreCase("--nameOf")) {
  -                table.put(NAME_OF, at.nextSwitchToken());
  -            } else if (token.equalsIgnoreCase("-p") || 
token.equalsIgnoreCase("--pattern")) {
  -                table.put(PATTERN, at.nextSwitchToken());
  -            } else if (token.equalsIgnoreCase("-q") || 
token.equalsIgnoreCase("--query")) {
  -                table.put(QUERY, at.nextSwitchToken());
  -            } else if (token.equalsIgnoreCase("-u") || 
token.equalsIgnoreCase("--uri")) {
  -                table.put(URI, at.nextSwitchToken());
  -            } else if (token.equalsIgnoreCase("-v") || 
token.equalsIgnoreCase("--verbose")) {
  -                table.put(VERBOSE, "true");
  -            } else if (token.equalsIgnoreCase("-l") || 
token.equalsIgnoreCase("--localdb")) {
  -                table.put(LOCAL, "true");
  -            } else if (token.equalsIgnoreCase("-d") || 
token.equalsIgnoreCase("--dbconfig")) {
  -                String configFile = at.nextSwitchToken();
  -                if (!new File(configFile).isAbsolute()) {
  -                    configFile = new File(System.getProperty("user.dir"), 
configFile).getAbsolutePath();
  -                }
  -                System.setProperty(Xindice.PROP_XINDICE_CONFIGURATION, 
configFile);
  -                table.put(DB_CONFIG, configFile);
  -            } else if (token.equalsIgnoreCase("-s") || 
token.equalsIgnoreCase("--namespaces")) {
  -                table.put(NAMESPACES, at.nextSwitchToken());
  -                // Index specific options
  -            } else if (token.equalsIgnoreCase("-t") || 
token.equalsIgnoreCase("--type")) {
  -                table.put(TYPE, at.nextSwitchToken());
  -            } else if (token.equalsIgnoreCase("+trim")) {
  -                if (!table.containsKey(TYPE)) {
  -                    table.put(TYPE, "trimmed");
  -                }
  -            } else if (token.equalsIgnoreCase("-trim")) {
  -                if (!table.containsKey(TYPE)) {
  -                    table.put(TYPE, "string");
  -                }
  -            } else if (token.equalsIgnoreCase("--pagesize")) {
  -                table.put(PAGE_SIZE, at.nextSwitchToken());
  -            } else if (token.equalsIgnoreCase("--maxkeysize")) {
  -                table.put(MAX_KEY_SIZE, at.nextSwitchToken());
  +         }
  +      } catch (IllegalArgumentException e) {
  +         printHelp();
  +         throw new XindiceException("ERROR : " + e.getMessage(), e);
  +      } catch (NoSuchElementException e) {
  +         throw new NoSuchElementException("ERROR : " + e + " Switch found. 
Parameter missing.");
  +      } catch (NullPointerException e) {
  +         e.printStackTrace(System.err);
  +         throw new NullPointerException("ERROR : " + e);
  +      } catch (Exception e) {
  +         e.printStackTrace(System.err);
  +         throw new XindiceException("ERROR : " + e.getMessage(), e);
  +      }
  +   }
  +
  +   /**
  +    * Parses and validated the arguments of the command line. The arguments 
are
  +    * stored into the <tt>table</tt> array.
  +    *
  +    * @exception IllegalArgumentException if an error is found
  +    */
  +   protected void parseArguments(String[] args)
  +         throws IllegalArgumentException {
  +      // parsing arguments for the command tools
  +      ArgTokenizer at = new ArgTokenizer(args);
  +
  +      if ( !at.hasMoreTokens() ) {
  +         throw new IllegalArgumentException("No argument found");
  +      }
  +
  +      // Action should always be the second token, if not there show help
  +      table.put( ACTION , at.nextToken() );
  +
  +      // Loop over remaining command line arguments, populating hashtable
  +      while ( at.hasMoreTokens() ) {
  +         String token = at.nextToken();
  +
  +         if ( token.equalsIgnoreCase( "-c" ) || token.equalsIgnoreCase( 
"--collection" ) ) {
  +            String colname = at.nextSwitchToken();
  +            if ( !colname.startsWith( "/" ) &&
  +                  !colname.startsWith( "xmldb:xindice" ) ) {
  +               throw new IllegalArgumentException( "The name of a collection 
must start with '/'" );
               }
  -        } // End of while loop
  -    }
  +            table.put( COLLECTION, colname );
  +         } else if ( token.equalsIgnoreCase("-e") || 
token.equalsIgnoreCase("--extension") ) {
  +            table.put( EXTENSION, at.nextSwitchToken());
  +         } else if ( token.equalsIgnoreCase("-f") || 
token.equalsIgnoreCase("--filepath") ) {
  +            table.put( FILE_PATH, at.nextSwitchToken());
  +         } else if ( token.equalsIgnoreCase("-h") || 
token.equalsIgnoreCase("--help") ) {
  +            table.put( ACTION, "help");
  +         } else if ( token.equalsIgnoreCase("-n") || 
token.equalsIgnoreCase("--nameOf") ) {
  +            table.put( NAME_OF, at.nextSwitchToken());
  +         } else if ( token.equalsIgnoreCase("-p") || 
token.equalsIgnoreCase("--pattern") ) {
  +            table.put( PATTERN, at.nextSwitchToken());
  +         } else if ( token.equalsIgnoreCase("-q") || 
token.equalsIgnoreCase("--query") ) {
  +             table.put( QUERY, at.nextSwitchToken());
  +         } else if ( token.equalsIgnoreCase("-u") || 
token.equalsIgnoreCase("--uri") ) {
  +             table.put( URI, at.nextSwitchToken());
  +         } else if ( token.equalsIgnoreCase("-v") || 
token.equalsIgnoreCase("--verbose") ) {
  +            table.put( VERBOSE, "true");
  +         } else if ( token.equalsIgnoreCase("-l") || 
token.equalsIgnoreCase("--localdb") ) {
  +            table.put( LOCAL, "true");
  +         } else if ( token.equalsIgnoreCase("-d") || 
token.equalsIgnoreCase("--dbconfig") ) {
  +             String configFile = at.nextSwitchToken();
  +             if (!new File(configFile).isAbsolute()) {
  +                 configFile = new File(System.getProperty("user.dir"), 
configFile).getAbsolutePath();
  +             }
  +             System.setProperty(Xindice.PROP_XINDICE_CONFIGURATION, 
configFile);
  +             table.put(DB_CONFIG, configFile);
  +         } else if ( token.equalsIgnoreCase("-s") || 
token.equalsIgnoreCase("--namespaces") ) {
  +             table.put(NAMESPACES, at.nextSwitchToken());
  +            // Index specific options
  +         } else if ( token.equalsIgnoreCase("-t") || 
token.equalsIgnoreCase("--type") ) {
  +            table.put( TYPE, at.nextSwitchToken());
  +         } else if ( token.equalsIgnoreCase("+trim") ) {
  +            if ( !table.containsKey( TYPE ) ) {
  +                table.put( TYPE, "trimmed");
  +            }
  +         } else if ( token.equalsIgnoreCase("-trim") ) {
  +            if ( !table.containsKey( TYPE ) ) {
  +                table.put( TYPE, "string");
  +            }
  +         } else if ( token.equalsIgnoreCase("--pagesize") ) {
  +             table.put( PAGE_SIZE, at.nextSwitchToken());
  +         } else if ( token.equalsIgnoreCase("--maxkeysize") ) {
  +             table.put( MAX_KEY_SIZE, at.nextSwitchToken());
  +         }
  +      } // End of while loop
  +   }
   
   
  -    /**
  +   /**
        * This method is to carry out execution, after instance variables being 
setup by process( args )
        **/
       public boolean execute() throws ClassNotFoundException, 
InstantiationException, IllegalAccessException, Exception {
  -        init();
  -        String action = (String) table.get(ACTION);
  +       init();
  +       String action = (String) table.get( ACTION );
   
  -        // get command class name
  -        String commandClass = null;
  -        if (action != null) {
  -            // search for the tool Class associated with the given action
  -            NodeList commands = getCommands();
  -            for (int i = 0; i < commands.getLength(); i++) {
  -                Element e = (Element) commands.item(i);
  -                if (action.equals(e.getAttribute("switch")) ||
  -                        action.equals(e.getAttribute("name"))) {
  -                    commandClass = e.getAttribute("class");
  -                }
  -            }
  -        }
  -
  -        if (commandClass != null) {
  -            try {
  -                // register Xindice Database with xml:db
  -                Database db = new DatabaseImpl();
  -
  -                DatabaseManager.registerDatabase(db);
  -
  -                // execute command class
  -                Command command = (Command) 
Class.forName(commandClass).newInstance();
  -                command.execute(table);
  -                return true;
  -            } catch (XMLDBException e) {
  -                System.err.println("XMLDB Exception with code " + 
e.errorCode);
  -                if (table.get(VERBOSE).equals("true")) {
  -                    e.printStackTrace(System.err);
  -                }
  -                return false;
  -            } catch (Exception e) {
  -                System.err.println("ERROR : " + e.getMessage());
  -
  -                if (table.get(VERBOSE).equals("true")) {
  -                    e.printStackTrace(System.err);
  -                }
  -                return false;
  +       // get command class name
  +       String commandClass = null;
  +       if ( action != null ) {
  +           // search for the tool Class associated with the given action
  +           NodeList commands = getCommands();
  +           for ( int i = 0; i < commands.getLength(); i++ ) {
  +               Element e = (Element) commands.item( i );
  +               if ( action.equals( e.getAttribute( "switch" ) ) ||
  +                    action.equals( e.getAttribute( "name" ) ) ) {
  +                  commandClass = e.getAttribute( "class" );
  +               }
  +           }
  +       }
  +       
  +       if ( commandClass != null ) {       
  +          try {
  +            // register Xindice Database with xml:db
  +            Database db = new DatabaseImpl();
  +   
  +            DatabaseManager.registerDatabase( db );
  +       
  +             // execute command class
  +             Command command = (Command)Class.forName( commandClass 
).newInstance();
  +             command.execute( table );
  +             return true;
  +          } catch (XMLDBException e) {
  +             System.err.println( "XMLDB Exception with code " + e.errorCode 
);
  +             if (table.get(VERBOSE).equals("true")) {
  +                e.printStackTrace(System.err);
  +             }
  +             return false;
  +          } catch (Exception e) {
  +            System.err.println("ERROR : " + e.getMessage() );
  +   
  +            if (table.get(VERBOSE).equals("true")) {
  +               e.printStackTrace(System.err);
               }
  -        }
  -
  -        return false;
  -    }
  +            return false;   
  +         }
  +       }
  +
  +       return false;
  +    }
  +
  +
  +
  +   public boolean handleOption(String option, ArgTokenizer at) {
  +      return false;
  +   }
  +
  +   /**
  +    * setAction sets the action type that will be passed to the command line.
  +    *
  +    * @param actionType The action value
  +    */
  +   public void setAction(String actionType) {
  +      table.put(XMLTools.ACTION, actionType);
  +   }
  +
  +   /**
  +    * getAction returns the action type that will be passed to the command 
line
  +    * tool.
  +    *
  +    * @return The action value
  +    */
  +   public String getAction() {
  +      return (String)table.get(XMLTools.ACTION);
  +   }
  +
  +   /**
  +    * setCollectionName sets the collection name that will be passed
  +    * to the command line.
  +    *
  +    * @param collectionName The collection value
  +    */
  +   public void setCollectionName(String collectionName) {
  +      table.put(COLLECTION, collectionName);
  +   }
  +
  +   /**
  +    * getCollectionName returns the collection name that will be passed
  +    * to the command line tool.
  +    *
  +    * @return The collection value
  +    */
  +   public String getCollectionName() {
  +      return (String)table.get(COLLECTION);
  +   }
  +
  +   /**
  +    * setDocumentName sets the document that will be passed to the
  +    * command line tool.
  +    *
  +    * @param documentName The docName value
  +    */
  +   public void setDocumentName(String documentName) {
  +      table.put(XMLTools.NAME_OF, documentName);
  +   }
  +
  +   /**
  +    * getDocumentName returns the document that will be passed to the
  +    * command line tool.
  +    *
  +    * @return The docName value
  +    */
  +   public String getDocumentName() {
  +      return (String)table.get(XMLTools.NAME_OF);
  +   }
  +
  +   /**
  +    * setQuery sets the Query variable for Document Query from the command 
line.
  +    *
  +    * @param query - The query string
  +    */
  +   public void setQuery(String query ) {
  +      table.put(XMLTools.QUERY, query);
  +   }
  +
  +   /**
  +    * getQuery returns the Query for Document passed to the command line 
tool.
  +    */
  +   public String getQuery() {
  +      return (String)table.get(XMLTools.QUERY);
  +   }
  +
  +   /**
  +    * setName sets the name for XMLObjects passed to the command line tool.
  +    *
  +    * @param name The docName value
  +    */
  +   public void setName(String name) {
  +      table.put(XMLTools.NAME_OF, name);
  +   }
  +
  +   /**
  +    * getName returns the name for XMLObjects that will be passed to the
  +    * command line tool.
  +    *
  +    * @return The nameOf value
  +    */
  +   public String getName() {
  +      return (String)table.get(XMLTools.NAME_OF);
  +   }
  +
  +   /**
  +    * setDatabaseServer sets the Database server name that will be
  +    * passed to the command line tool.
  +    *
  +    * @param appName The dbServ value
  +    */
  +   public void setDatabaseServer(String appName) {
  +      table.put(XMLTools.DB_SERVER, appName);
  +   }
  +
  +   /**
  +    * getDatabaseServer returns the Database server that will be
  +    * passed to the command line tool.
  +    *
  +    * @return The dbServ value
  +    */
  +   public String getDatabaseServer() {
  +      return (String)table.get(XMLTools.DB_SERVER);
  +   }
  +
  +   /**
  +    * setPort sets the port that will passed to the command line tool.
  +    *
  +    * @param portName The port value
  +    */
  +   public void setPort(String portName) {
  +      table.put(XMLTools.PORT, portName);
  +   }
  +
  +   /**
  +    * getPort returns the port that will be passed to the command line tool.
  +    *
  +    * @return The port value
  +    */
  +   public String getPort() {
  +      return (String)table.get(XMLTools.PORT);
  +   }
  +
  +   /**
  +    * setHost sets the host that will passed to the command line tool.
  +    *
  +    * @param hostName The host value
  +    */
  +   public void setHost(String hostName) {
  +      table.put(HOST, hostName);
  +   }
  +
  +   /**
  +    * getPort returns the host that will be passed to the command line tool.
  +    *
  +    * @return The host value
  +    */
  +   public String getHost() {
  +      return (String)table.get(HOST);
  +   }
  +
  +   /**
  +    * setFilePath sets the file path that will passed to the command line 
tool.
  +    *
  +    * @param fPath The filePath value
  +    */
  +   public void setFilePath(String fPath) {
  +      table.put(XMLTools.FILE_PATH, fPath);
  +   }
  +
  +   /**
  +    * getFilePath returns the file path that will be passed to the command
  +    *
  +    * @return The filePath value
  +    */
  +   public String getFilePath() {
  +      return (String)table.get(XMLTools.FILE_PATH);
  +   }
  +
  +   /**
  +    * setURI sets the database URI (protocol://host:port/name) that
  +    * will be passed to the command line
  +    *
  +    * @param URI The URI for the database
  +    */
  +   public void setURI(String URI) {
  +      table.put(XMLTools.URI, URI);
  +   }
  +
  +   /**
  +    * getURI gets returns the database URI (protocol://host:port/name)
  +    * that will be passed to the command line tool
  +    *
  +    * @return The URI for the database
  +    */
  +   public String getURI() {
  +      return (String)table.get(XMLTools.URI);
  +   }
  +
  +   /**
  +    * setImplementClass sets the implemented class path that will be passed
  +    * to the command line tool.
  +    *
  +    * @param imClassName The implClass value
  +    */
  +   public void setImplementClass(String imClassName) {
  +      table.put(XMLTools.IMPL_CLASS, imClassName);
  +   }
  +
  +   /**
  +    * getImplementClass returns the implmented class path that will be passed
  +    * to the command line tool.
  +    *
  +    * @return The implClass value
  +    */
  +   public String getImplementClass() {
  +      return (String)table.get(XMLTools.IMPL_CLASS);
  +   }
  +
  +
  +   /**
  +    * The following Security methods are simply a starting point. User names 
and
  +    * their related passwords will not be this simple. Until Encryption for
  +    * Passwords are developed, and KeyStorage is set-up, this will do for 
now.
  +    * In the future, these methods will change as needed to be more efficient
  +    * for Xindice.
  +    */
  +
  +
  +   /**
  +    * setUser sets the user that will be passed to the command line tool and
  +    * will be used in Security issues.
  +    *
  +    * @param userName The user value
  +    */
  +   public void setUser(String userName) {
  +      table.put(XMLTools.USER, userName);
  +   }
  +
  +   /**
  +    * getUser returns the user that will be passed to the command line tool 
and
  +    * will be used in Security issues.
  +    *
  +    * @return The user value
  +    */
  +   public String getUser() {
  +      return (String)table.get(XMLTools.USER);
  +   }
  +
  +   /**
  +    * setPassword sets the password that will be passed to the command line 
tool
  +    * and will be used in conjunction with the userName value.
  +    *
  +    * @param pswd The passwrd value
  +    */
  +   public void setPassword(String pswd) {
  +      table.put(PASSWORD, pswd);
  +   }
  +
  +   /**
  +    * getPassword returns the password that will be passed to the command 
line
  +    * tool and will be used in conjunction with the userName value.
  +    *
  +    * @return The password value
  +    */
  +   public String getPassword() {
  +      return (String)table.get(PASSWORD);
  +   }
   
   
  -    public boolean handleOption(String option, ArgTokenizer at) {
  -        return false;
  -    }
  -
  -    /**
  -     * setAction sets the action type that will be passed to the command 
line.
  -     *
  -     * @param actionType The action value
  -     */
  -    public void setAction(String actionType) {
  -        table.put(XMLTools.ACTION, actionType);
  -    }
  -
  -    /**
  -     * getAction returns the action type that will be passed to the command 
line
  -     * tool.
  -     *
  -     * @return The action value
  -     */
  -    public String getAction() {
  -        return (String) table.get(XMLTools.ACTION);
  -    }
  -
  -    /**
  -     * setCollectionName sets the collection name that will be passed
  -     * to the command line.
  -     *
  -     * @param collectionName The collection value
  -     */
  -    public void setCollectionName(String collectionName) {
  -        table.put(COLLECTION, collectionName);
  -    }
  -
  -    /**
  -     * getCollectionName returns the collection name that will be passed
  -     * to the command line tool.
  -     *
  -     * @return The collection value
  -     */
  -    public String getCollectionName() {
  -        return (String) table.get(COLLECTION);
  -    }
  -
  -    /**
  -     * setDocumentName sets the document that will be passed to the
  -     * command line tool.
  -     *
  -     * @param documentName The docName value
  -     */
  -    public void setDocumentName(String documentName) {
  -        table.put(XMLTools.NAME_OF, documentName);
  -    }
  -
  -    /**
  -     * getDocumentName returns the document that will be passed to the
  -     * command line tool.
  -     *
  -     * @return The docName value
  -     */
  -    public String getDocumentName() {
  -        return (String) table.get(XMLTools.NAME_OF);
  -    }
  -
  -    /**
  -     * setQuery sets the Query variable for Document Query from the command 
line.
  -     *
  -     * @param query - The query string
  -     */
  -    public void setQuery(String query) {
  -        table.put(XMLTools.QUERY, query);
  -    }
  -
  -    /**
  -     * getQuery returns the Query for Document passed to the command line 
tool.
  -     */
  -    public String getQuery() {
  -        return (String) table.get(XMLTools.QUERY);
  -    }
  -
  -    /**
  -     * setName sets the name for XMLObjects passed to the command line tool.
  -     *
  -     * @param name The docName value
  -     */
  -    public void setName(String name) {
  -        table.put(XMLTools.NAME_OF, name);
  -    }
  -
  -    /**
  -     * getName returns the name for XMLObjects that will be passed to the
  -     * command line tool.
  -     *
  -     * @return The nameOf value
  -     */
  -    public String getName() {
  -        return (String) table.get(XMLTools.NAME_OF);
  -    }
  -
  -    /**
  -     * setDatabaseServer sets the Database server name that will be
  -     * passed to the command line tool.
  -     *
  -     * @param appName The dbServ value
  -     */
  -    public void setDatabaseServer(String appName) {
  -        table.put(XMLTools.DB_SERVER, appName);
  -    }
  -
  -    /**
  -     * getDatabaseServer returns the Database server that will be
  -     * passed to the command line tool.
  -     *
  -     * @return The dbServ value
  -     */
  -    public String getDatabaseServer() {
  -        return (String) table.get(XMLTools.DB_SERVER);
  -    }
  -
  -    /**
  -     * setPort sets the port that will passed to the command line tool.
  -     *
  -     * @param portName The port value
  -     */
  -    public void setPort(String portName) {
  -        table.put(XMLTools.PORT, portName);
  -    }
  -
  -    /**
  -     * getPort returns the port that will be passed to the command line tool.
  -     *
  -     * @return The port value
  -     */
  -    public String getPort() {
  -        return (String) table.get(XMLTools.PORT);
  -    }
  -
  -    /**
  -     * setHost sets the host that will passed to the command line tool.
  -     *
  -     * @param hostName The host value
  -     */
  -    public void setHost(String hostName) {
  -        table.put(HOST, hostName);
  -    }
  -
  -    /**
  -     * getPort returns the host that will be passed to the command line tool.
  -     *
  -     * @return The host value
  -     */
  -    public String getHost() {
  -        return (String) table.get(HOST);
  -    }
  -
  -    /**
  -     * setFilePath sets the file path that will passed to the command line 
tool.
  -     *
  -     * @param fPath The filePath value
  -     */
  -    public void setFilePath(String fPath) {
  -        table.put(XMLTools.FILE_PATH, fPath);
  -    }
  -
  -    /**
  -     * getFilePath returns the file path that will be passed to the command
  -     *
  -     * @return The filePath value
  -     */
  -    public String getFilePath() {
  -        return (String) table.get(XMLTools.FILE_PATH);
  -    }
  -
  -    /**
  -     * setURI sets the database URI (protocol://host:port/name) that
  -     * will be passed to the command line
  -     *
  -     * @param URI The URI for the database
  -     */
  -    public void setURI(String URI) {
  -        table.put(XMLTools.URI, URI);
  -    }
  -
  -    /**
  -     * getURI gets returns the database URI (protocol://host:port/name)
  -     * that will be passed to the command line tool
  -     *
  -     * @return The URI for the database
  -     */
  -    public String getURI() {
  -        return (String) table.get(XMLTools.URI);
  -    }
  -
  -    /**
  -     * setImplementClass sets the implemented class path that will be passed
  -     * to the command line tool.
  -     *
  -     * @param imClassName The implClass value
  -     */
  -    public void setImplementClass(String imClassName) {
  -        table.put(XMLTools.IMPL_CLASS, imClassName);
  -    }
  -
  -    /**
  -     * getImplementClass returns the implmented class path that will be 
passed
  -     * to the command line tool.
  -     *
  -     * @return The implClass value
  -     */
  -    public String getImplementClass() {
  -        return (String) table.get(XMLTools.IMPL_CLASS);
  -    }
  -
  -
  -    /**
  -     * The following Security methods are simply a starting point. User 
names and
  -     * their related passwords will not be this simple. Until Encryption for
  -     * Passwords are developed, and KeyStorage is set-up, this will do for 
now.
  -     * In the future, these methods will change as needed to be more 
efficient
  -     * for Xindice.
  -     */
  -
  -
  -    /**
  -     * setUser sets the user that will be passed to the command line tool and
  -     * will be used in Security issues.
  -     *
  -     * @param userName The user value
  -     */
  -    public void setUser(String userName) {
  -        table.put(XMLTools.USER, userName);
  -    }
  -
  -    /**
  -     * getUser returns the user that will be passed to the command line tool 
and
  -     * will be used in Security issues.
  -     *
  -     * @return The user value
  -     */
  -    public String getUser() {
  -        return (String) table.get(XMLTools.USER);
  -    }
  -
  -    /**
  -     * setPassword sets the password that will be passed to the command line 
tool
  -     * and will be used in conjunction with the userName value.
  -     *
  -     * @param pswd The passwrd value
  -     */
  -    public void setPassword(String pswd) {
  -        table.put(PASSWORD, pswd);
  -    }
  -
  -    /**
  -     * getPassword returns the password that will be passed to the command 
line
  -     * tool and will be used in conjunction with the userName value.
  -     *
  -     * @return The password value
  -     */
  -    public String getPassword() {
  -        return (String) table.get(PASSWORD);
  -    }
  -
   
       public void printHelp() {
  -        NodeList list = getCommands();
  +       NodeList list = getCommands();
   
           // This method relies on two things to format the output for help
           //    Method isAdmin() - Tells us if this is an admin instance, used 
to hide certain output
  @@ -635,66 +636,66 @@
   
   
           // Show the header and switch commands
  -        System.out.println();
  -        System.out.println("Xindice Command Tools v" + Xindice.Version);
  -        System.out.println();
  -        System.out.println("Format: xindice action [switch] [parameter]");
  -        System.out.println();
  -        System.out.println("Where:  [switch]  implements:");
  -        System.out.println("    -c           " + "Collection context (must 
always be specified)");
  -        System.out.println("    -e           " + "File extension for 
multiple documents");
  -        System.out.println("    -f           " + "File path for document 
retrieval and storage");
  -        System.out.println("    -n           " + "Name");
  -        System.out.println("    -p           " + "Index pattern");
  -        System.out.println("    -q           " + "Query string");
  -        System.out.println("    -s           " + "Semi-colon delimited list 
of namespaces for query in ");
  -        System.out.println("                 the form prefix=namespace-uri");
  -        System.out.println("    -l           " + "Use a local database 
rather then going over the network.");
  -        System.out.println("                 Should be combined with -d to 
specify the configuration to use.");
  -        System.out.println("    -d           " + "Path to the database 
configuration to use for the local ");
  -        System.out.println("                 database. Only applies if -l is 
specified.");
  -        System.out.println("    -t           " + "Specify the data type in 
collection index");
  -        System.out.println("    -v           " + "Verbose");
  -        System.out.println("    --pagesize   " + "Page size for file pages 
(default: 4096)");
  -        System.out.println("    --maxkeysize " + "The maximum size for file 
keys (default: 0=none)");
  -        System.out.println();
  -
  -        System.out.println("\nActions:\n");
  -        System.out.println("    xindice [parameter], etc...\n");
  -
  -        // Show all elements with helpclass=document
  -
  -        // Loop over the commands, printing test from description attribute
  -        for (int i = 0; i < list.getLength(); i++) {
  -            helpClass = ((Element) list.item(i)).getAttribute("helpclass");
  -
  -            if (helpClass.equals("document")) {
  -                desc = ((Element) list.item(i)).getAttribute("description");
  -                cmdswitch = ((Element) list.item(i)).getAttribute("switch");
  -                System.out.println("    " + 
StringUtilities.leftJustify(cmdswitch, 13) + desc);
  -            }
  -        }
  -
  -        // Loop over the commands, printing text from description attribute
  -        for (int i = 0; i < list.getLength(); i++) {
  -            helpClass = ((Element) list.item(i)).getAttribute("helpclass");
  -
  -            if (helpClass.equals("security")) {
  -                desc = ((Element) list.item(i)).getAttribute("description");
  -                cmdswitch = ((Element) list.item(i)).getAttribute("switch");
  -                System.out.println("    " + 
StringUtilities.leftJustify(cmdswitch, 13) + desc);
  -            }
  -        }
  -
  -        System.out.println("\nExamples:\n");
  -
  -        System.out.println("    xindice ad -c /db/test -f /tmp/xmldocument 
-n myxmldocument");
  -        System.out.println("    xindice dd -c /db/test -n myxmldocument");
  -        System.out.println("    xindice rd -c /db/test/ocs -f a:\\file.xml 
-n file.xml");
  -        System.out.println("    xindice xpath -c /db/test/ocs -q test");
  -        System.out.println("    xindice xpath -c /db/test -s 
a=http://somedomain.com/schema.xsd -q /a:foo");
  -        System.out.println();
  -        System.out.println("For more information, please read the Xindice - 
Tools Reference Guide");
  -        System.out.println();
  -    }
  +      System.out.println();
  +      System.out.println("Xindice Command Tools v" + Xindice.Version);
  +      System.out.println();
  +      System.out.println("Format: xindice action [switch] [parameter]");
  +      System.out.println();
  +      System.out.println("Where:  [switch]  implements:");
  +      System.out.println("    -c           " + "Collection context (must 
always be specified)");
  +      System.out.println("    -e           " + "File extension for multiple 
documents");
  +      System.out.println("    -f           " + "File path for document 
retrieval and storage");
  +      System.out.println("    -n           " + "Name");
  +      System.out.println("    -p           " + "Index pattern");
  +      System.out.println("    -q           " + "Query string");
  +      System.out.println("    -s           " + "Semi-colon delimited list of 
namespaces for query in ");
  +      System.out.println("                 the form prefix=namespace-uri");
  +      System.out.println("    -l           " + "Use a local database rather 
then going over the network.");
  +      System.out.println("                 Should be combined with -d to 
specify the configuration to use.");
  +      System.out.println("    -d           " + "Path to the database 
configuration to use for the local ");
  +      System.out.println("                 database. Only applies if -l is 
specified.");
  +      System.out.println("    -t           " + "Specify the data type in 
collection index");
  +      System.out.println("    -v           " + "Verbose");
  +      System.out.println("    --pagesize   " + "Page size for file pages 
(default: 4096)");
  +      System.out.println("    --maxkeysize " + "The maximum size for file 
keys (default: 0=none)");
  +      System.out.println();
  +
  +      System.out.println("\nActions:\n");
  +      System.out.println("    xindice [parameter], etc...\n");
  +
  +      // Show all elements with helpclass=document
  +
  +      // Loop over the commands, printing test from description attribute
  +      for (int i=0; i < list.getLength(); i++) {
  +         helpClass = ((Element)list.item(i)).getAttribute("helpclass") ;
  +
  +         if ( helpClass.equals("document") ) {
  +            desc = ((Element)list.item(i)).getAttribute("description");
  +            cmdswitch = ((Element)list.item(i)).getAttribute("switch");
  +            System.out.println("    " + 
StringUtilities.leftJustify(cmdswitch, 13) + desc );
  +         }
  +      }
  +
  +      // Loop over the commands, printing text from description attribute
  +      for (int i=0; i < list.getLength(); i++) {
  +         helpClass = ((Element)list.item(i)).getAttribute("helpclass") ;
  +
  +         if ( helpClass.equals("security") ) {
  +            desc = ((Element)list.item(i)).getAttribute("description");
  +            cmdswitch = ((Element)list.item(i)).getAttribute("switch");
  +            System.out.println("    " + 
StringUtilities.leftJustify(cmdswitch, 13) + desc );
  +         }
  +      }
  +
  +      System.out.println("\nExamples:\n");
  +
  +      System.out.println("    xindice ad -c /db/test -f /tmp/xmldocument -n 
myxmldocument");
  +      System.out.println("    xindice dd -c /db/test -n myxmldocument");
  +      System.out.println("    xindice rd -c /db/test/ocs -f a:\\file.xml -n 
file.xml");
  +      System.out.println("    xindice xpath -c /db/test/ocs -q test");
  +      System.out.println("    xindice xpath -c /db/test -s 
a=http://somedomain.com/schema.xsd -q /a:foo");
  +      System.out.println();
  +      System.out.println("For more information, please read the Xindice - 
Tools Reference Guide");
  +      System.out.println();
  +   }
   }
  
  
  

Reply via email to