kstaken     2002/07/10 20:17:07

  Modified:    java/src/org/apache/xindice/client/xmldb
                        CommonConfigurable.java DatabaseImpl.java
                        ResourceSetImpl.java
               java/src/org/apache/xindice/client/xmldb/services
                        CollectionManager.java DatabaseInstanceManager.java
                        XMLObjectService.java
  Added:       java/src/org/apache/xindice/client/xmldb/corba
                        CollectionImpl.java DatabaseImpl.java
                        ManagedObject.java
               java/src/org/apache/xindice/client/xmldb/corba/services
                        CollectionManagerImpl.java
                        DatabaseInstanceManagerImpl.java
                        XMLObjectServiceImpl.java
                        XPathQueryServiceImpl.java
                        XUpdateQueryServiceImpl.java package.html
  Removed:     java/src/org/apache/xindice/client/xmldb CollectionImpl.java
                        ManagedObject.java
               java/src/org/apache/xindice/client/xmldb/services
                        XPathQueryServiceImpl.java
                        XUpdateQueryServiceImpl.java
  Log:
  Refactoring the XML:DB API implementation to allow multiple impls behind a
  single DatabaseImpl. This will allow Corba, XML-RPC and embedded to coexist.
  Corba is still going to be removed though.
  
  Currently the XML:DB DriverManager does not work in this configuration so
  only CORBA can be accessed.
  
  Revision  Changes    Path
  1.2       +2 -2      
xml-xindice/java/src/org/apache/xindice/client/xmldb/CommonConfigurable.java
  
  Index: CommonConfigurable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/CommonConfigurable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CommonConfigurable.java   6 Dec 2001 19:33:53 -0000       1.1
  +++ CommonConfigurable.java   11 Jul 2002 03:17:07 -0000      1.2
  @@ -66,7 +66,7 @@
    * Base class to handle property managment within the API implementation.
    */
   public abstract class CommonConfigurable implements Configurable {
  -   Hashtable config = null;
  +   protected Hashtable config = null;
   
      /**
       * Constructor for the CommonConfigurable object
  
  
  
  1.2       +35 -241   
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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DatabaseImpl.java 6 Dec 2001 19:33:54 -0000       1.1
  +++ DatabaseImpl.java 11 Jul 2002 03:17:07 -0000      1.2
  @@ -68,9 +68,7 @@
   
   import org.xmldb.api.base.*;
   
  -import org.apache.xindice.core.FaultCodes;
  -import org.apache.xindice.client.corba.db.*;
  -import org.apache.xindice.client.corba.db.Database;
  +import org.apache.xindice.client.xmldb.corba.*;
   
   /**
    * DatabaseImpl is the XML:DB driver implementation for Xindice. It is the 
entry
  @@ -83,66 +81,36 @@
    * <a 
href="http://www.xmldb.org/xapi/index.html";>http://www.xmldb.org/xapi/index.html</a>
    * <p />
    *
  - * The location to find the NamingService ior can be specified by setting the
  - * property xindice.naming.ior using setProperty. By default the system is
  - * bootstrapped via HTTP and doesn't use a CORBA naming service.
  - *
  - * The CORBA ORB implementation can be switched by setting the properties
  - * org.omg.CORBA.ORBClass and org.omg.CORBA.ORBSingletonClass with the values
  - * provided by your orb vendor. The values are set using setProperty().
  + * This implementation simply acts as a proxy for the protocol specific API 
implementations.
  + * Currently Corba is supported and XML-RPC and embedded access will be 
added.
    */
   public class DatabaseImpl extends CommonConfigurable
  -   implements org.xmldb.api.base.Database {
  +   implements Database {
   
  -   protected Hashtable dbs = null;
  +   protected Database driver;
   
      /**
  -    * Name used in the uri for collections associated with this instance.
  +    * These are the URI prefixes this proxy impl understands.
       */
  -   public static String INSTANCE_NAME = "xindice";
  +   public static String CORBA_URI = "xindice://";
  +   public static String XMLRPC_URI = "xindice-rpc://";
  +   public static String EMBED_URI = "xindice-embed://";
  +
      /**
  -    * The characters expected to separate the INSTANCE_NAME from the database
  -    * name.
  +      * Name used in the uri for collections associated with this instance.
       */
  -   public static String SEP = "://";
  +   public static String INSTANCE_NAME = "xindice";
  +   
      /**
  -    * 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";
  -   /**
  -    * Default CORBA name service name for the Database instance.
  -    */
  -   public final static String DEFAULT_CORBA_NAME = "db";
  -   /**
  -    * Default location where the bootstrap IOR can be located.
  -    */
  -   public final static String DEFAULT_BOOTSTRAP_URI =
  -         "http://localhost:4080/db_bootstrap.ior";;
  -   /**
  -    * Property name to use to set the URI where a CORBA name service can be
  -    * located.
  -    */
  -   public final static String CORBA_NAMING_PROP = "xindice.naming.ior";
  -   /**
  -    * Property name to use to set the name of the ORB Class. This is used to
  -    * override the JDKs built in CORBA ORB.
  -    */
  -   public final static String ORB_CLASS_PROP = "org.omg.CORBA.ORBClass";
  -   /**
  -    * Property name to use to set the name of the ORB singleton Class. This 
is
  -    * used to override the JDKs built in CORBA ORB.
  -    */
  -   public final static String ORB_SINGLETON_CLASS_PROP = 
"org.omg.CORBA.ORBSingletonClass";
  -   
  -   // CORBA naming context root element.
  -   protected static String ROOT_CONTEXT = INSTANCE_NAME;
      
      /**
       * Constructor for the DatabaseImpl object
       */
      public DatabaseImpl() {
         super();
  -      dbs = new Hashtable();
      }
   
      /**
  @@ -181,52 +149,10 @@
       */
      public org.xmldb.api.base.Collection getCollection(String uri,
            String username, String password) throws XMLDBException {
  -             
  -      if (uri == null) {
  -         throw new XMLDBException(ErrorCodes.INVALID_URI);
  -      }
  -      
  -      // Get the name service name to use to locate the server
  -      String corbaName = getNamingNameFromURI(uri);
  -      if (corbaName == null) {
  -         corbaName = DEFAULT_CORBA_NAME;
  -      }
  -
  -      // Get the bootstrap URI to use to locate the server
  -      String corbaBootstrapURI = getNamingURI(uri, corbaName);
  -      if (corbaBootstrapURI == null) {
  -         corbaBootstrapURI = DEFAULT_BOOTSTRAP_URI;
  -      }
  -
  -      // Create a Database instance for this name if it doesn't already
  -      // exist.
  -      String dbKey = corbaBootstrapURI + " " +  corbaName;
  -      if (dbs.get(dbKey) == null) {
  -         init(corbaBootstrapURI, corbaName);
  -      }
   
  -      // xindice:///db-instance/collection-path
  -      String collectionName = getCollectionFromURI(uri);
  -      org.xmldb.api.base.Collection collection = null;
  -      try {
  -         Database db = (Database) dbs.get(dbKey);
  -
  -         collection =
  -            new CollectionImpl(db.getCollection(collectionName), db, this);
  -      }
  -      catch (APIException e) {
  -         if (e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND) {
  -            return null;
  -         }
  -         else {
  -            throw FaultCodes.createXMLDBException(e);
  -         }
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -
  -      return collection;
  +      createDriver(uri);
  +            
  +      return driver.getCollection(uri, username, password);
      }
   
      /**
  @@ -248,162 +174,30 @@
       * @return true if the URI can be handled, false otherwise.
       * @exception XMLDBException
       */
  -   public boolean acceptsURI(String uri) throws XMLDBException {
  -      if (uri.startsWith(INSTANCE_NAME)) {
  -         return true;
  -      }
  -
  -      return false;
  -   }
  -
  -   /**
  -    * Returns the Collection path portion of the URI.
  -    *
  -    * @param uri the URI to parse.
  -    * @return The collection path portion of the URI.
  -    * @exception XMLDBException
  -    */
  -   protected String getCollectionFromURI(String uri) throws XMLDBException {
  -      if ( ! uri.startsWith(INSTANCE_NAME) ) {
  -         throw new XMLDBException(ErrorCodes.INVALID_DATABASE);
  -      }
  -
  -      // Find the start of the collection path skipping over the database 
name.
  -      int start = uri.indexOf('/', INSTANCE_NAME.length() + SEP.length());
  -      start = uri.indexOf('/', start + 1);
  -      
  -      // Remove the protocol and database instance name
  -      String result = "/";
  -      if ( start != -1 ) {
  -          result = uri.substring(start, uri.length());
  -      }
  -
  -      return result;
  -   }
  -
  -   /**
  -    * Returns the CORBA name service name portion of the URI.
  -    * This is xindice:///[corba name]/
  -    *
  -    * @param uri the URI to parse.
  -    * @return The collection path portion of the URI.
  -    * @exception XMLDBException
  -    */
  -   protected String getNamingNameFromURI(String uri) throws XMLDBException {
  -      if ( ! uri.startsWith(INSTANCE_NAME) ) {
  -         throw new XMLDBException(ErrorCodes.INVALID_DATABASE);
  -      }
  -
  -      // Find the start of the collection path.
  -      int start = uri.indexOf('/', INSTANCE_NAME.length() + SEP.length());
  -      int end = uri.indexOf('/', start + 1);
  +   public boolean acceptsURI(String uri) throws XMLDBException {      
  +      createDriver(uri);
         
  -      // Remove the protocol and Database instance name
  -      String result = null;
  -      if ( end != -1 ) {
  -         result = uri.substring(start + 1, end);
  -      }
  -      else {
  -         result = uri.substring(start + 1, uri.length());
  -      }
  -
  -      return result;
  +      return driver.acceptsURI(uri);
      }
   
  -   /**
  -    * Returns the CORBA bootstrap name from the URI.
  -    * The XML:DB URI should contain xindice://[bootstrap host]/
  -    *
  -    * @param uri the URI to parse.
  -    * @return The collection path portion of the URI.
  -    * @exception XMLDBException
  -    */
  -   protected String getNamingURI(String uri, String instance) throws 
XMLDBException {
  -      if ( ! uri.startsWith(INSTANCE_NAME) ) {
  -         throw new XMLDBException(ErrorCodes.INVALID_DATABASE);
  -      }
  -
  -      String result = null;
  -      
  -      // Find the first double slashes.
  -      int first = uri.indexOf("//", INSTANCE_NAME.length());
  -
  -      // Find the next slash.c
  -      int end = uri.indexOf('/', first + 2);
  -      
  -      // If we don't have 3 consecutive slashes then there should be a host
  -      if ( first != (end - 2) ) {
  -         result = uri.substring(first + 2, end);
  -         result = "http://"; + result + "/" + instance + "_bootstrap.ior";
  -      }
  -          
  -      return result;
  -   }
  -   
  -   /**
  -    * Initializes the connection to Xindice via the CORBA API.
  -    */
  -   protected void init(String bootstrapURI, String corbaName) throws 
XMLDBException {
  -      Properties orbConfig = getOrbConfig();
  +   protected void createDriver(String uri) throws XMLDBException {
  +      // Determine which driver was requested.
         try {
  -         ORB orb = ORB.init(new String[0], orbConfig);
  -
  -         Database db = null;
  -         
  -         // If a naming service is specified we use that to bootstrap
  -         String namingURI = (String) config.get(CORBA_NAMING_PROP);
  -         if ( namingURI != null ) {
  -            Hashtable env = new Hashtable(5, 0.75f);
  -            
  -            env.put(Context.INITIAL_CONTEXT_FACTORY,
  -               "com.sun.jndi.cosnaming.CNCtxFactory");
  -            env.put("java.naming.provider.url", namingURI);
  -            env.put("java.naming.corba.orb", orb);
  -            Context ic = new InitialContext(env);
  -      
  -            db = (org.apache.xindice.client.corba.db.Database)
  -               DatabaseHelper.narrow((org.omg.CORBA.Object)
  -                  ic.lookup(ROOT_CONTEXT + "/" + corbaName));
  -         }
  -         // Otherwise we get the bootstrap IOR via HTTP
  -         else {
  -            URL url = new URL (bootstrapURI);
  -            BufferedReader in = new BufferedReader(new InputStreamReader(
  -               url.openStream()));
  -   
  -            String ior = in.readLine();
  +         if ( driver == null ) {
  +            if (uri.startsWith(CORBA_URI)) {
  +               driver = (Database) 
Class.forName("org.apache.xindice.client.xmldb.corba.DatabaseImpl").newInstance();
  +            }
  +            else if (uri.startsWith(XMLRPC_URI)) {
  +               driver = (Database) 
Class.forName("org.apache.xindice.client.rpc.base.DatabaseImpl").newInstance();
  +            }
  +            else if (uri.startsWith(EMBED_URI)) {
   
  -            in.close();
  -
  -            db = (org.apache.xindice.client.corba.db.Database)
  -               DatabaseHelper.narrow(orb.string_to_object(ior));
  -         }
  -         
  -         // Store the Database instance for this name.
  -         dbs.put(bootstrapURI + " " + corbaName, db);
  +            }
  +         }   
         }
         catch (Exception e) {
  -         throw new XMLDBException(ErrorCodes.VENDOR_ERROR, 1,
  -            "A connection to the Database instance '" + corbaName +
  -               "' could not be created. Error: " + e.getMessage());
  -      }
  -   }
  -   
  -   protected Properties getOrbConfig() {
  -      Properties orbConf = new Properties();
  -      
  -      // See if we're overriding the default ORB
  -      String orbClass = (String) config.get(ORB_CLASS_PROP);
  -      if (orbClass != null) {
  -         orbConf.put("org.omg.CORBA.ORBClass", orbClass);
  -      }
  -            
  -      String orbSingletonClass = (String) 
config.get(ORB_SINGLETON_CLASS_PROP);
  -      if (orbSingletonClass != null) {
  -         orbConf.put("org.omg.CORBA.ORBSingletonClass", orbSingletonClass);
  -      }
  -      
  -      return orbConf;
  +         throw new XMLDBException(ErrorCodes.INVALID_URI);
  +      }            
      }
   }
   
  
  
  
  1.2       +4 -1      
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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResourceSetImpl.java      6 Dec 2001 19:33:54 -0000       1.1
  +++ ResourceSetImpl.java      11 Jul 2002 03:17:07 -0000      1.2
  @@ -63,6 +63,9 @@
   
   import org.apache.xindice.client.xmldb.resources.*;
   
  +// TODO: This is shouldn't be here for this class to be generic.
  +import org.apache.xindice.client.xmldb.corba.CollectionImpl;
  +
   import org.xmldb.api.base.*;
   import org.xmldb.api.modules.*;
   
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/client/xmldb/corba/CollectionImpl.java
  
  Index: CollectionImpl.java
  ===================================================================
  package org.apache.xindice.client.xmldb.corba;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: CollectionImpl.java,v 1.1 2002/07/11 03:17:07 kstaken Exp $
   */
  
  import org.apache.xindice.client.xmldb.resources.*;
  import org.apache.xindice.client.xmldb.corba.services.*;
  import org.apache.xindice.client.xmldb.*;
  import org.apache.xindice.xml.*;
  import org.apache.xindice.xml.dom.*;
  import org.apache.xindice.core.FaultCodes;
  import org.apache.xindice.client.corba.*;
  import org.apache.xindice.client.corba.db.*;
  
  import org.w3c.dom.*;
  
  import java.util.*;
  
  import org.xmldb.api.base.*;
  import org.xmldb.api.modules.*;
  
  /**
   * Implements the XML:DB API Collection interface for encapsulating access to 
an
   * XML database collection. This allows you to store/retrieve/delete resources
   * within the database and provides access to other services for the database.
   * <p />
   *
   * This API is an implementation of the XML:DB API. More information on this 
API
   * can be found by looking at
   * <a 
href="http://www.xmldb.org/xapi/index.html";>http://www.xmldb.org/xapi/index.html</a>
   * <p />
   * The Xindice implemenation of Collection makes the following services
   * available to applications.
   * <ul>
   *    <li>XPathQueryService 1.0 for performing XPath queries against the 
server</li>
   *    <li>DatabaseInstanceManager 1.0 for managing the Xindice database 
instance</li>
   *    <li>CollectionManager 1.0 for managing Xindice collections</li>
   *    <li>XMLObjectService for invoking XMLObjects within Xindice</li>
   * </ul>
   *
   * @see org.apache.xindice.client.xmldb.services.XMLObjectService
   * @see org.apache.xindice.client.xmldb.services.DatabaseInstanceManager
   * @see org.apache.xindice.client.xmldb.services.CollectionManager
   */
  public class CollectionImpl extends CommonConfigurable
         implements org.xmldb.api.base.Collection, ManagedObject {
     private static final byte[] EmptyBytes = new byte[0];
  
     private SymbolDeserializer syms = new SymbolDeserializer();
  
     protected org.apache.xindice.client.corba.db.Collection collection = null;
     protected org.apache.xindice.client.corba.db.Database db = null;
     protected DatabaseImpl database = null;
  
     protected Hashtable services = null;
  
     // CORBA Servant management variables
     protected boolean isOpen = false;
     protected ArrayList objects = null;
  
     /**
      * Creates a new CollectionImpl for the XML:DB API Collection interface.
      *
      * @param collection the Xindice collection to wrap
      * @param db the Xindice Database instance that the collection is
      *        associated with.
      * @param database XML:DB Database instance for Xindice
      * @exception XMLDBException
      */
     public CollectionImpl(org.apache.xindice.client.corba.db.Collection 
collection,
                           org.apache.xindice.client.corba.db.Database db,
                           org.apache.xindice.client.xmldb.corba.DatabaseImpl 
database)
           throws XMLDBException {
        this.collection = collection;
        this.db = db;
        this.database = database;
        isOpen = true;
  
        services = new Hashtable();
  
        // Register all services supported by this collection implementation.
        XPathQueryServiceImpl xpath = new XPathQueryServiceImpl();
        xpath.setCollection(this);
        xpath.setSymbolDeserializer(syms);
        registerService(xpath);
  
        XUpdateQueryServiceImpl xupdate = new XUpdateQueryServiceImpl();
        xupdate.setCollection(this);
        registerService(xupdate);
  
        XMLObjectServiceImpl xobj = new XMLObjectServiceImpl();
        xobj.setCollection(this);
        registerService(xobj);
  
        try {
           CollectionManagerImpl manager =
              new CollectionManagerImpl(collection.getCollectionManager(),
                 db, database);
           manager.setCollection(this);
           registerService(manager);
  
           // CollectionManager provides both standard access as a
           // CollectionManagementService and Xindice specific access as a
           // CollectionManager. We need to register it explicitly a second time
           // to make it available as both.
           services.put("CollectionManagementService" + manager.getVersion(), 
manager);
           
           registerService(
                 new DatabaseInstanceManagerImpl(db.getDatabaseManager(),
                 db, database));
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Returns the name of the Collection
      *
      * @return The name of the collection.
      * @exception XMLDBException
      */
     public String getName() throws XMLDBException {
        try {
           return collection.getName();
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Returns the fully qualified name of the Collection
      *
      * @return The name of the collection.
      * @exception XMLDBException
      */
     public String getCanonicalName() throws XMLDBException {
        try {
           return collection.getCanonicalName();
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
     
     /**
      * Returns the list of Services supported by this Collection.
      *
      * @return A list of supported Services
      * @exception XMLDBException
      */
     public org.xmldb.api.base.Service[] getServices() throws XMLDBException {
        checkOpen();
        
        Enumeration e = services.elements();
        Service[] result = new Service[services.size()];
  
        int i = 0;
        while (e.hasMoreElements()) {
           result[i] = (Service) e.nextElement();
           i++;
        }
  
        return result;
     }
  
     /**
      * Get a Service instance based on the name and version.
      *
      * @param name The Service instance to retrieve
      * @param version The version of the service to retrieve.
      * @return The Service instance or null if no service was found.
      * @exception XMLDBException
      */
     public org.xmldb.api.base.Service getService(String name, String version)
            throws XMLDBException {
        checkOpen();
        
        Service result = (Service) services.get(name + version);
  
        return result;
     }
  
     /**
      * Gets the ParentCollection for this Collection if one exists.
      *
      * @return The ParentCollection instance or null if none exists
      * @exception XMLDBException
      */
     public org.xmldb.api.base.Collection getParentCollection()
            throws XMLDBException {
        checkOpen();
        
        try {
           org.apache.xindice.client.corba.db.Collection col = 
collection.getParentCollection();
           if (col != null) {
              return (org.xmldb.api.base.Collection)
                    new CollectionImpl(col, db, database);
           }
           else {
              return null;
           }
        }
        catch (APIException e) {
           if ( e.faultCode == FaultCodes.DBE_NO_PARENT) {
              return null;
           }
           
           throw FaultCodes.createXMLDBException(e);
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Returns the number of child Collections
      *
      * @return the number of child collections.
      * @exception XMLDBException
      */
     public int getChildCollectionCount() throws XMLDBException {
        checkOpen();
        
        try {
           String[] collections = collection.listCollections();
           return collections.length;
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(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
      */
     public String[] listChildCollections() throws XMLDBException {
        checkOpen();
        
        try {
            return(collection.listCollections());
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Returns a Collection 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
      */
     public org.xmldb.api.base.Collection getChildCollection(String name)
           throws XMLDBException {
        checkOpen();
        
        try {
            org.apache.xindice.client.corba.db.Collection col = 
collection.getCollection(name);
            if (col == null) {
               return null;
            }
  
            return(new CollectionImpl(col, db, database));
        }
        catch (APIException e) {
           if (e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND) {
              return null;
           }
           
           throw FaultCodes.createXMLDBException(e);
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Returns the number of resources stored by this Collection
      *
      * @return The ResourceCount value
      * @exception XMLDBException
      */
     public int getResourceCount() throws XMLDBException {
        checkOpen();
        
        try {
           return collection.getDocumentCount();
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Returns a list of the ids for all resources stored in the collection.
      *
      * @return a string array containing the names for all resources in the
      *         collection.
      * @exception XMLDBException
      */
     public String[] listResources() throws XMLDBException {
        checkOpen();
        
        try {
           return(collection.listDocuments());
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Retrieves the Resource identified by id from the repository.
      *
      * @param id The unique id for the resource
      * @return The requested resource.
      * @exception XMLDBException
      */
     public org.xmldb.api.base.Resource getResource(String id)
            throws XMLDBException {
        checkOpen();
        
        Resource resource = null;
        try {
           // TODO: Return null if no document is found.
           EncodedBuffer buffer = collection.getDocument(id, 
syms.getLastModified());
           if ( buffer.stamp != -1 ) {
              SymbolTable s = syms.getSymbols(buffer);
              resource = new XMLResourceImpl(id, this, s, buffer.buf);
           }
           else
              resource = new XMLResourceImpl(id, this, new String(buffer.buf));
        }
        catch (APIException e) {
           if (e.faultCode == FaultCodes.COL_DOCUMENT_NOT_FOUND) {
              return null;
           }
           else {
              throw FaultCodes.createXMLDBException(e);
           }
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
  
        return resource;
     }
  
     /**
      * Registers a new Service with this Collection.
      *
      * @param service Description of Parameter
      * @exception XMLDBException
      */
     public void registerService(org.xmldb.api.base.Service service)
            throws XMLDBException {
        checkOpen();
        
        /*if ((service == null) ||
              (service.getVersion() == null) || (service.getVersion().length() 
== 0) ||
              (service.getName() == null) || (service.getName().length() == 0)) 
{
  
           throw new XMLDBException(ErrorCodes.INVALID_SERVICE);
        }*/
  
        service.setCollection(this);
        services.put(service.getName() + service.getVersion(), service);
     }
  
     /**
      * Creates a new Resource instance for storing data in the repository.
      * <p />
      * The Xindice implementation only knows how to handle XMLResources.
      *
      * @param id The unique id to use for the created resource.
      * @return The newly created Resource.
      * @exception XMLDBException
      */
     public org.xmldb.api.base.Resource createResource(String id, String type)
            throws XMLDBException {
        checkOpen();
  
        if ( ! type.equals(XMLResource.RESOURCE_TYPE) ) {
           throw new XMLDBException(ErrorCodes.UNKNOWN_RESOURCE_TYPE);
        }
        
        if ( ( id == null ) || id.equals("") ) {
           id = createId();
        }
  
        return new XMLResourceImpl(id, this);
     }
  
     /**
      * Removes the provided resource from the repository.
      *
      * @param resource The resource to remove.
      * @exception XMLDBException
      */
     public void removeResource(org.xmldb.api.base.Resource resource)
            throws XMLDBException {
        checkOpen();
        
        try {
           collection.removeDocument(resource.getId());
        }
        catch (APIException e) {
           if (e.faultCode == FaultCodes.COL_DOCUMENT_NOT_FOUND) {
              throw new XMLDBException(ErrorCodes.NO_SUCH_RESOURCE);
           }
           else {
              throw FaultCodes.createXMLDBException(e);
           }
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Stores the Resource in the repository
      *
      * @param resource The resource to store.
      * @exception XMLDBException
      */
     public void storeResource(org.xmldb.api.base.Resource resource)
            throws XMLDBException {
        checkOpen();
        
        try {
           EncodedBuffer buffer = new EncodedBuffer();
           buffer.sym = EmptyBytes;
           
           String content = (String) resource.getContent();
           if ( content == null ) {
              throw new XMLDBException(ErrorCodes.INVALID_RESOURCE);
           }
           
           buffer.buf = content.getBytes();
           buffer.stamp = -1;
  
           String id = resource.getId();
           if ( ( id == null ) || ( id.length() == 0 ) ) {
              id = createId();
           }
  
           collection.insertDocument(id, buffer);
        }
        catch (XMLDBException e) {
           throw e;
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * @return Description of the Returned Value
      * @exception XMLDBException
      */
     public String createId() throws XMLDBException {
        checkOpen();
        
        try {
           return collection.createNewOID();
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * The close method must be called when access to a collection is complete.
      * It will release any resources allocated for use by the collection.
      *
      * @exception XMLDBException
      */
     public void close() throws XMLDBException {
        if ( isOpen ) {
           remove();
        }
     }
  
     /**
      * Returns true if the  <code>Collection</code> is open false otherwise.
      *
      * @return true if the <code>Collection</code> is open, false otherwise.
      * @exception XMLDBException
      */
     public boolean isOpen() throws XMLDBException {
        return isOpen;
     }
     
     /**
      * Frees any server side resources consumed by this collection and releases
      * the server side Servant.
      */
     public void remove() {
        try {
           ((DatabaseInstanceManagerImpl) getService("DatabaseInstanceManager", 
"1.0")).remove();
           ((CollectionManagerImpl) getService("CollectionManager", 
"1.0")).remove();
        }
        catch (Exception e) {
           e.printStackTrace();
        }
  
        collection.remove();
        isOpen = false;
     }
  
     /**
      * Returns the Xindice underlying collection implementation.
      *
      * @return The ServerObject value
      */
     public org.apache.xindice.client.corba.db.Collection getServerObject() {
        return collection;
     }
  
     /**
      * Adds a reference to a managable object to the managed objects list.
      *
      * @param ref The feature to be added to the ManagedObject attribute
      */
     void addManagedObject(ManagedObject ref) {
        objects.add(ref);
     }
     
     /**
      * Throws an exception if the collection is not open.
      */
     protected void checkOpen() throws XMLDBException {
        if ( isOpen == false ) {
           throw new XMLDBException(ErrorCodes.COLLECTION_CLOSED);
        }
     }
  }
  
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/client/xmldb/corba/DatabaseImpl.java
  
  Index: DatabaseImpl.java
  ===================================================================
  package org.apache.xindice.client.xmldb.corba;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: DatabaseImpl.java,v 1.1 2002/07/11 03:17:07 kstaken Exp $
   */
  
  import org.omg.CORBA.ORB;
  
  import java.util.*;
  import java.io.*;
  import java.net.*;
  import javax.naming.*;
  
  import org.xmldb.api.base.*;
  
  import org.apache.xindice.client.xmldb.CommonConfigurable;
  
  import org.apache.xindice.core.FaultCodes;
  import org.apache.xindice.client.corba.db.*;
  import org.apache.xindice.client.corba.db.Database;
  
  /**
   * DatabaseImpl is the XML:DB driver implementation for Xindice. It is the 
entry
   * point into the Xindice server but is not intended for direct use by users.
   * Users access it indirectly through the XML:DB DatabaseManager 
implementation.
   *
   *
   * This API is an implementation of the XML:DB API. More information on this 
API
   * can be found by looking at
   * <a 
href="http://www.xmldb.org/xapi/index.html";>http://www.xmldb.org/xapi/index.html</a>
   * <p />
   *
   * The location to find the NamingService ior can be specified by setting the
   * property xindice.naming.ior using setProperty. By default the system is
   * bootstrapped via HTTP and doesn't use a CORBA naming service.
   *
   * The CORBA ORB implementation can be switched by setting the properties
   * org.omg.CORBA.ORBClass and org.omg.CORBA.ORBSingletonClass with the values
   * provided by your orb vendor. The values are set using setProperty().
   */
  public class DatabaseImpl extends CommonConfigurable
     implements org.xmldb.api.base.Database {
  
     protected Hashtable dbs = null;
  
     /**
      * Name used in the uri for collections associated with this instance.
      */
     public static String INSTANCE_NAME = "xindice";
     /**
      * The characters expected to separate the INSTANCE_NAME from the database
      * name.
      */
     public static String SEP = "://";
     /**
      * The XML:DB API Core Level Conformance of this implementation.
      */
     public static String CONFORMANCE_LEVEL = "0";
     /**
      * Default CORBA name service name for the Database instance.
      */
     public final static String DEFAULT_CORBA_NAME = "db";
     /**
      * Default location where the bootstrap IOR can be located.
      */
     public final static String DEFAULT_BOOTSTRAP_URI =
           "http://localhost:4080/db_bootstrap.ior";;
     /**
      * Property name to use to set the URI where a CORBA name service can be
      * located.
      */
     public final static String CORBA_NAMING_PROP = "xindice.naming.ior";
     /**
      * Property name to use to set the name of the ORB Class. This is used to
      * override the JDKs built in CORBA ORB.
      */
     public final static String ORB_CLASS_PROP = "org.omg.CORBA.ORBClass";
     /**
      * Property name to use to set the name of the ORB singleton Class. This is
      * used to override the JDKs built in CORBA ORB.
      */
     public final static String ORB_SINGLETON_CLASS_PROP = 
"org.omg.CORBA.ORBSingletonClass";
     
     // CORBA naming context root element.
     protected static String ROOT_CONTEXT = INSTANCE_NAME;
     
     /**
      * Constructor for the DatabaseImpl object
      */
     public DatabaseImpl() {
        super();
        dbs = new Hashtable();
     }
  
     /**
      * Gets the instance Name
      *
      * @return The Name value
      * @exception XMLDBException
      */
     public String getName() throws XMLDBException {
        return INSTANCE_NAME;
     }
  
     /**
      * Creates a Collection instance using the URI to locate the collection in
      * the Xindice instance. Applications should not call this method directly.
      * Instead they should call 
org.xmldb.api.base.DatabaseManager.getCollection().
      * <p />
      * The URI format accepted by this method:
      * xindice:/[Nameservice host]//[Database Instance Name in the CORBA Name 
Service]/[collection path]
      * <p />
      * Nameservice host is optional.
      *
      * This usually looks something like this:
      * xindice:///db/root/ocs. or
      * xindice://some.host.com:8309/db/root/ocs
      * <p />
      * When you pass the URI to DatabaseManager.getCollection(uri) you must
      * prepend an xmldb: to the beginning to make it a valid XML:DB URI.
      * So to normal users of the API URIs will look like this:
      * xmldb:xindice:///db/root/ocs. DatabaseManager will strip the
      * xmldb: before handing the URI to this getCollection implementation.
      * <p />
      * @param uri The URI specifing the location of the collection.
      * @return The Collection value
      * @exception XMLDBException
      */
     public org.xmldb.api.base.Collection getCollection(String uri,
           String username, String password) throws XMLDBException {
               
        if (uri == null) {
           throw new XMLDBException(ErrorCodes.INVALID_URI);
        }
        
        // Get the name service name to use to locate the server
        String corbaName = getNamingNameFromURI(uri);
        if (corbaName == null) {
           corbaName = DEFAULT_CORBA_NAME;
        }
  
        // Get the bootstrap URI to use to locate the server
        String corbaBootstrapURI = getNamingURI(uri, corbaName);
        if (corbaBootstrapURI == null) {
           corbaBootstrapURI = DEFAULT_BOOTSTRAP_URI;
        }
  
        // Create a Database instance for this name if it doesn't already
        // exist.
        String dbKey = corbaBootstrapURI + " " +  corbaName;
        if (dbs.get(dbKey) == null) {
           init(corbaBootstrapURI, corbaName);
        }
  
        // xindice:///db-instance/collection-path
        String collectionName = getCollectionFromURI(uri);
        org.xmldb.api.base.Collection collection = null;
        try {
           Database db = (Database) dbs.get(dbKey);
  
           collection =
              new CollectionImpl(db.getCollection(collectionName), db, this);
        }
        catch (APIException e) {
           if (e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND) {
              return null;
           }
           else {
              throw FaultCodes.createXMLDBException(e);
           }
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
  
        return collection;
     }
  
     /**
      * Gets the ConformanceLevel attribute of the DatabaseImpl object
      *
      * @return The ConformanceLevel value
      * @exception XMLDBException Description of Exception
      */
     public String getConformanceLevel() throws XMLDBException {
        return CONFORMANCE_LEVEL;
     }
  
     /**
      * Used by org.xmldb.api.base.DatabaseManager to determine if this database
      * instance is the proper one to handle a request or not.
      *
      * @param uri The uri to test - see getCollection for a description of the
      *        format.
      * @return true if the URI can be handled, false otherwise.
      * @exception XMLDBException
      */
     public boolean acceptsURI(String uri) throws XMLDBException {
        if (uri.startsWith(INSTANCE_NAME)) {
           return true;
        }
  
        return false;
     }
  
     /**
      * Returns the Collection path portion of the URI.
      *
      * @param uri the URI to parse.
      * @return The collection path portion of the URI.
      * @exception XMLDBException
      */
     protected String getCollectionFromURI(String uri) throws XMLDBException {
        if ( ! uri.startsWith(INSTANCE_NAME) ) {
           throw new XMLDBException(ErrorCodes.INVALID_DATABASE);
        }
  
        // Find the start of the collection path skipping over the database 
name.
        int start = uri.indexOf('/', INSTANCE_NAME.length() + SEP.length());
        start = uri.indexOf('/', start + 1);
        
        // Remove the protocol and database instance name
        String result = "/";
        if ( start != -1 ) {
            result = uri.substring(start, uri.length());
        }
  
        return result;
     }
  
     /**
      * Returns the CORBA name service name portion of the URI.
      * This is xindice:///[corba name]/
      *
      * @param uri the URI to parse.
      * @return The collection path portion of the URI.
      * @exception XMLDBException
      */
     protected String getNamingNameFromURI(String uri) throws XMLDBException {
        if ( ! uri.startsWith(INSTANCE_NAME) ) {
           throw new XMLDBException(ErrorCodes.INVALID_DATABASE);
        }
  
        // Find the start of the collection path.
        int start = uri.indexOf('/', INSTANCE_NAME.length() + SEP.length());
        int end = uri.indexOf('/', start + 1);
        
        // Remove the protocol and Database instance name
        String result = null;
        if ( end != -1 ) {
           result = uri.substring(start + 1, end);
        }
        else {
           result = uri.substring(start + 1, uri.length());
        }
  
        return result;
     }
  
     /**
      * Returns the CORBA bootstrap name from the URI.
      * The XML:DB URI should contain xindice://[bootstrap host]/
      *
      * @param uri the URI to parse.
      * @return The collection path portion of the URI.
      * @exception XMLDBException
      */
     protected String getNamingURI(String uri, String instance) throws 
XMLDBException {
        if ( ! uri.startsWith(INSTANCE_NAME) ) {
           throw new XMLDBException(ErrorCodes.INVALID_DATABASE);
        }
  
        String result = null;
        
        // Find the first double slashes.
        int first = uri.indexOf("//", INSTANCE_NAME.length());
  
        // Find the next slash.c
        int end = uri.indexOf('/', first + 2);
        
        // If we don't have 3 consecutive slashes then there should be a host
        if ( first != (end - 2) ) {
           result = uri.substring(first + 2, end);
           result = "http://"; + result + "/" + instance + "_bootstrap.ior";
        }
            
        return result;
     }
     
     /**
      * Initializes the connection to Xindice via the CORBA API.
      */
     protected void init(String bootstrapURI, String corbaName) throws 
XMLDBException {
        Properties orbConfig = getOrbConfig();
        try {
           ORB orb = ORB.init(new String[0], orbConfig);
  
           Database db = null;
           
           // If a naming service is specified we use that to bootstrap
           String namingURI = (String) config.get(CORBA_NAMING_PROP);
           if ( namingURI != null ) {
              Hashtable env = new Hashtable(5, 0.75f);
              
              env.put(Context.INITIAL_CONTEXT_FACTORY,
                 "com.sun.jndi.cosnaming.CNCtxFactory");
              env.put("java.naming.provider.url", namingURI);
              env.put("java.naming.corba.orb", orb);
              Context ic = new InitialContext(env);
        
              db = (org.apache.xindice.client.corba.db.Database)
                 DatabaseHelper.narrow((org.omg.CORBA.Object)
                    ic.lookup(ROOT_CONTEXT + "/" + corbaName));
           }
           // Otherwise we get the bootstrap IOR via HTTP
           else {
              URL url = new URL (bootstrapURI);
              BufferedReader in = new BufferedReader(new InputStreamReader(
                 url.openStream()));
     
              String ior = in.readLine();
  
              in.close();
  
              db = (org.apache.xindice.client.corba.db.Database)
                 DatabaseHelper.narrow(orb.string_to_object(ior));
           }
           
           // Store the Database instance for this name.
           dbs.put(bootstrapURI + " " + corbaName, db);
        }
        catch (Exception e) {
           throw new XMLDBException(ErrorCodes.VENDOR_ERROR, 1,
              "A connection to the Database instance '" + corbaName +
                 "' could not be created. Error: " + e.getMessage());
        }
     }
     
     protected Properties getOrbConfig() {
        Properties orbConf = new Properties();
        
        // See if we're overriding the default ORB
        String orbClass = (String) config.get(ORB_CLASS_PROP);
        if (orbClass != null) {
           orbConf.put("org.omg.CORBA.ORBClass", orbClass);
        }
              
        String orbSingletonClass = (String) 
config.get(ORB_SINGLETON_CLASS_PROP);
        if (orbSingletonClass != null) {
           orbConf.put("org.omg.CORBA.ORBSingletonClass", orbSingletonClass);
        }
        
        return orbConf;
     }
  }
  
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/client/xmldb/corba/ManagedObject.java
  
  Index: ManagedObject.java
  ===================================================================
  package org.apache.xindice.client.xmldb.corba;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: ManagedObject.java,v 1.1 2002/07/11 03:17:07 kstaken Exp $
   */
  
  /**
    * Provides methods for managing the lifecycle of CORBA Servant instances.
    */
  public interface ManagedObject {
     /**
      * Removes the server side Servant for this object. Should be called when 
the
      * the object is no longer needed.
      */
     public void remove();
  }
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/client/xmldb/corba/services/CollectionManagerImpl.java
  
  Index: CollectionManagerImpl.java
  ===================================================================
  package org.apache.xindice.client.xmldb.corba.services;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: CollectionManagerImpl.java,v 1.1 2002/07/11 03:17:07 kstaken Exp $
   */
  
  import org.apache.xindice.xml.*;
  import org.apache.xindice.xml.dom.*;
  import org.apache.xindice.client.xmldb.*;
  import org.apache.xindice.client.xmldb.corba.*;
  import org.apache.xindice.client.xmldb.services.*;
  import org.apache.xindice.core.FaultCodes;
  import org.apache.xindice.client.corba.db.*;
  import org.apache.xindice.client.corba.EncodedBufferConverter;
  import org.apache.xindice.client.xmldb.services.CollectionManager;
  
  import org.w3c.dom.*;
  
  import org.xmldb.api.base.*;
  import org.xmldb.api.modules.*;
  import org.xmldb.api.base.Collection;
  
  /**
   * CollectionManager provides management facilities for a Collection instance.
   * Administrative access is required for retrieval of the CollectionManager
   * interface. User level access is provided through the underlying Collection
   * itself.
   */
  public class CollectionManagerImpl extends CommonConfigurable
        implements ManagedObject, Service, CollectionManagementService, 
CollectionManager {
     protected org.apache.xindice.client.corba.db.CollectionManager manager = 
null;
     protected org.apache.xindice.client.corba.db.Database db = null;
     protected Collection collection = null;
     protected org.apache.xindice.client.xmldb.corba.DatabaseImpl database = 
null;
  
     /**
      * Creates a new CollectionManager service
      *
      * @param manager the server side CollectionManager to use.
      * @param db the root Database instance that the
      *        CollectionManager is associated with.
      * @param database a reference to the XML:DB Database instance for the API.
      */
     public 
CollectionManagerImpl(org.apache.xindice.client.corba.db.CollectionManager 
manager,
                                  org.apache.xindice.client.corba.db.Database 
db,
                                  
org.apache.xindice.client.xmldb.corba.DatabaseImpl database) {
        this.manager = manager;
        this.db = db;
        this.database = database;
     }
  
     /**
      * Returns the name of the Service
      *
      * @return the name of the Service
      */
     public String getName() {
        return "CollectionManager";
     }
  
     /**
      * Returns the version of the Service
      *
      * @return the version of the Service
      */
     public String getVersion() {
        return "1.0";
     }
  
     /**
      * Provides a reference to the XML:DB collection instance that this service
      * is associated with.
      *
      * @param col the XML:DB collection instance associated with this Service
      */
     public void setCollection(org.xmldb.api.base.Collection col) {
        this.collection = col;
     }
  
     /**
      * Returns the name of the collection that this manager is associated with.
      *
      * @return the name of the collection
      * @exception XMLDBException
      */
     public String getCollectionName() throws XMLDBException {
        try {
           return manager.getName();
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Returns the fully qualified name of the collection that this manager is
      * associated with. This name includes all parent collections.
      *
      * @return the fully qualified name for this collection.
      * @exception XMLDBException
      */
     public String getCanonicalName() throws XMLDBException {
        try {
           return manager.getCanonicalName();
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Creates a new collection in the database identified by name and using
      * the provided configuration.
      *
      * @param path the path of the new collection
      * @param configuration the XML collection configuration to use for
      *        creating this collection.
      * @return The newly created collection
      * @exception XMLDBException
      */
     public Collection createCollection(String path, Document configuration)
           throws XMLDBException {
        try {
  
           EncodedBuffer buffer =
             EncodedBufferConverter.convertFromDocument(configuration);
           Collection col = new CollectionImpl(manager.createCollection(path, 
buffer),
              db, database);
  
           // db.addManagedObject(col);
  
           return col;
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
     
     /**
      * Drops a child collection from this collection.
      *
      * @param collection The child collection to drop.
      * @exception XMLDBException
      */
     public void dropCollection(String name) throws XMLDBException {
        try {
           this.manager.dropCollection(name);
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Returns a list of all indexers for this collection.
      *
      * @return the list of indexers
      * @exception XMLDBException
      */
     public String[] listIndexers() throws XMLDBException {
        try {
           return manager.listIndexers();
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Creates a new Indexer for this collection.
      *
      * @param name The name for this indexer
      * @param configuration The configuration to use for this indexer.
      * @exception XMLDBException
      */
     public void createIndexer(Document configuration)
           throws XMLDBException {
        EncodedBuffer config =
          EncodedBufferConverter.convertFromDocument(configuration);
  
        try {
           manager.createIndexer(config);
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Drops the indexer from the collection
      *
      * @param indexer The indexer to drop.
      * @exception XMLDBException
      */
     public void dropIndexer(String name)
           throws XMLDBException {
        try {
           manager.dropIndexer(name);
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Returns a list of all collection level XMLObjects for this collection.
      *
      * @return the list of XMLObjects.
      * @exception XMLDBException
      */
     public String[] listXMLObjects() throws XMLDBException {
        try {
           return manager.listXMLObjects();
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Creates a new collection level XMLObject using the provided 
configuration.
      * The XMLObject will be added to the collection using the provided name as
      * a key.
      *
      * @param name The name of this XMLObject
      * @param configuration The XML configuration to use
      * @return The created XMLObject
      * @exception XMLDBException
      */
     public void createXMLObject(Document configuration) throws XMLDBException {
        EncodedBuffer config =
          EncodedBufferConverter.convertFromDocument(configuration);
        try {
           manager.createXMLObject(config);
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Drops a collection level XMLObject from the collection.
      *
      * @param object The XMLObject to drop.
      * @exception XMLDBException
      */
     public void dropXMLObject(String name)
           throws XMLDBException {
        try {
           manager.dropXMLObject(name);
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     // Implementation of the CollectionManagementService interface
     
     /**
      * Creates a simple collection with a basic default configuration. More
      * complex configuration requires using a proprietary interface
      */
     public Collection createCollection(String name) throws XMLDBException {
        Document doc = new DocumentImpl();
  
        Element colEle = doc.createElement("collection");
        colEle.setAttribute("compressed", "true");
        colEle.setAttribute("name", name);
  
        doc.appendChild(colEle);
  
        Element filEle = doc.createElement("filer");
        filEle.setAttribute("class", 
"org.apache.xindice.core.filer.BTreeFiler");
        filEle.setAttribute("gzip", "true");
  
        colEle.appendChild(filEle);
  
        return createCollection(name, doc);
     }
     
     /**
      * Removes the named collection from the system.
      */
     public void removeCollection(String name) throws XMLDBException {
        dropCollection(name);
     }
  
     /**
      * Returns the underlying CORBA implementation object for this collection
      *
      * @return the server side object
      */
     protected org.apache.xindice.client.corba.db.CollectionManager 
getServerObject() {
        return manager;
     }
  
     /**
      * Removes the server side Servant for this object. Should be called when 
the
      * the object is no longer needed.
      */
     public void remove() {
        manager.remove();
     }
  }
  
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/client/xmldb/corba/services/DatabaseInstanceManagerImpl.java
  
  Index: DatabaseInstanceManagerImpl.java
  ===================================================================
  package org.apache.xindice.client.xmldb.corba.services;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: DatabaseInstanceManagerImpl.java,v 1.1 2002/07/11 03:17:07 kstaken 
Exp $
   */
  
  import org.apache.xindice.core.FaultCodes;
  import org.apache.xindice.client.corba.EncodedBufferConverter;
  import org.apache.xindice.client.corba.db.*;
  import org.apache.xindice.client.xmldb.*;
  import org.apache.xindice.client.xmldb.corba.*;
  import org.apache.xindice.client.xmldb.services.*;
  
  import java.util.*;
  
  import org.w3c.dom.Document;
  
  import org.xmldb.api.base.*;
  import org.xmldb.api.base.Collection;
  
  /**
    * DatabaseInstanceManager enables management of the Database intance on the
    * server. It also enables you to shutdown the running server.<p>
    *
    * In order to get a reference to the DatabaseInstanceManager object you 
must have
    * administrative access to the server.
    */
  public class DatabaseInstanceManagerImpl extends CommonConfigurable
        implements ManagedObject, Service, DatabaseInstanceManager {
     protected org.apache.xindice.client.corba.db.Database db = null;
     protected DatabaseManager manager;
     protected org.apache.xindice.client.xmldb.corba.DatabaseImpl database = 
null;
  
     /**
      * Creates a new DatabaseInstanceManager instance
      */
     public DatabaseInstanceManagerImpl(DatabaseManager manager,
                                        
org.apache.xindice.client.corba.db.Database db,
                                        
org.apache.xindice.client.xmldb.corba.DatabaseImpl database) {
        this.manager = manager;
        this.db = db;
        this.database = database;
     }
  
     public String getName() {
        return "DatabaseInstanceManager";
     }
  
     public String getVersion() {
        return "1.0";
     }
  
     /**
      * Not used for the DatabaseInstanceManager service.
      */
     public void setCollection(org.xmldb.api.base.Collection col)
           throws XMLDBException {
     }
  
     /**
      * Returns the name of this database
      *
      * @return The name of this database
      * @exception XMLDBException
      */
     public String getDatabaseName() throws XMLDBException  {
        try {
           return manager.getName();
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Shutsdown the Database instance
      *
      * @return the result of the shutdown operation
      * @exception XMLDBException
      */
     public void shutdown() throws XMLDBException {
        try {
           manager.shutdown();
           //return true;
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Removes the server side Servant for this object. Should be called when 
the
      * the object is no longer needed.
      */
     public void remove() {
        manager.remove();
     }
  }
  
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/client/xmldb/corba/services/XMLObjectServiceImpl.java
  
  Index: XMLObjectServiceImpl.java
  ===================================================================
  package org.apache.xindice.client.xmldb.corba.services;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: XMLObjectServiceImpl.java,v 1.1 2002/07/11 03:17:07 kstaken Exp $
   */
  
  import org.apache.xindice.xml.*;
  import org.apache.xindice.client.xmldb.*;
  import org.apache.xindice.core.FaultCodes;
  import org.apache.xindice.client.corba.db.*;
  import org.apache.xindice.client.xmldb.corba.*;
  import org.apache.xindice.client.xmldb.services.*;
  import org.apache.xindice.client.corba.EncodedBufferConverter;
  
  import org.w3c.dom.Document;
  
  import org.xmldb.api.base.*;
  import org.xmldb.api.base.Collection;
  
  /**
   * XMLObjectService enables invocation of XMLObjects within the Xindice 
server.
   *
   * The implementation of this functionality is currently quite simplistic.
   */
  public class XMLObjectServiceImpl extends CommonConfigurable
        implements Service, XMLObjectService {
     protected Collection collection = null;
     
     /**
      * Creates a new XMLObjectService to enable invocation of XMLObjects on the
      * server.
      */
     public XMLObjectServiceImpl() {
     }
  
     public String getName() {
        return "XMLObjectService";
     }
  
     public String getVersion() {
        return "1.0";
     }
  
     /**
      * Sets the collection associated with this service.
      */
     public void setCollection(org.xmldb.api.base.Collection col) {
        this.collection = col;
     }
  
     /**
      * Invokes an XMLObject using the provided URI.
      *
      * @param the uri including parameters for the XMLObject to invoke.
      * @return a Resource encapsulating the result of the invocation. The
      * resource type is determined by the current resourceType setting of the
      * parent collection.
      * @exception XMLDBException Thrown if any error occurs.
      */
     public Resource invokeXMLObject(String uri) throws XMLDBException {
        try {
           // Create an empty Resource to hold the result of the invocation
           Resource result = collection.createResource(null, "XMLResource");
           
           // Invoke the object
           CollectionImpl col = (CollectionImpl) collection;
           EncodedBuffer buf = col.getServerObject().invokeXMLObject(uri);
           
           // TODO: we should make sure that no argument exceptions are thrown
           // TODO: properly handle result types.
           result.setContent(new String(buf.buf));
           return result;
        }
        catch (Exception e) {
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
  }
  
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/client/xmldb/corba/services/XPathQueryServiceImpl.java
  
  Index: XPathQueryServiceImpl.java
  ===================================================================
  package org.apache.xindice.client.xmldb.corba.services;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: XPathQueryServiceImpl.java,v 1.1 2002/07/11 03:17:07 kstaken Exp $
   */
  
  import java.util.*;
  
  import org.apache.xindice.core.FaultCodes;
  import org.apache.xindice.client.corba.db.*;
  import org.apache.xindice.client.corba.*;
  import org.apache.xindice.client.corba.db.Collection;
  import org.apache.xindice.client.xmldb.*;
  import org.apache.xindice.client.xmldb.corba.*;
  
  import org.apache.xindice.client.xmldb.resources.*;
  
  import org.apache.xindice.xml.*;
  import org.apache.xindice.xml.dom.*;
  
  import org.w3c.dom.*;
  import org.xmldb.api.base.*;
  import org.xmldb.api.modules.*;
  
  public class XPathQueryServiceImpl extends CommonConfigurable
     implements org.xmldb.api.modules.XPathQueryService
  {
     private SymbolDeserializer syms;
     private NamespaceMap nsMap = new NamespaceMap();
  
     protected org.xmldb.api.base.Collection collection = null;
  
     public XPathQueryServiceImpl() {
     }
  
     public String getName() throws XMLDBException {
        return "XPathQueryService";
     }
  
     public String getVersion() throws XMLDBException {
        return "1.0";
     }
  
     public void setCollection(org.xmldb.api.base.Collection col)
           throws XMLDBException {
        this.collection = col;
     }
  
     public void setSymbolDeserializer(SymbolDeserializer syms) {
        this.syms = syms;
     }
  
     public void setDefaultNamespace(String uri) throws XMLDBException {
        if ( uri != null )
           nsMap.setDefaultNamespace(uri);
        else
           nsMap.removeDefaultNamespace();
     }
     
     public void removeDefaultNamespace() {
        nsMap.removeDefaultNamespace();
     }
     
     public void setNamespace(String prefix, String uri) throws XMLDBException {
        if ( ( prefix == null ) || prefix.equals("") ) {
           setDefaultNamespace(uri);
        }
        else {
           if ( uri != null ) {
              nsMap.setNamespace(prefix, uri);
           }
        }
     }
     
     public void removeNamespace(String prefix) {
        if ( ( prefix == null ) || prefix.equals("") ) {
           removeDefaultNamespace();
        }
        
        nsMap.removeNamespace(prefix);
     }
     
     public String getDefaultNamespace() {
        return nsMap.getDefaultNamespaceURI();
     }
     
     public String getNamespace(String prefix) {
        if ( ( prefix == null ) || prefix.equals("") ) {
           return nsMap.getDefaultNamespaceURI();
        }
     
        return nsMap.getNamespaceURI(prefix);
     }
     
     public void clearNamespaces() {
        nsMap.clear();
     }
  
     private NamedVal[] getNamespaces() {
        NamedVal[] nv = new NamedVal[nsMap.size()];
        Iterator iter = nsMap.keySet().iterator();
        int i = 0;
        while ( iter.hasNext() ) {
           String prefix = (String)iter.next();
           String uri = nsMap.getNamespaceURI(prefix);
           nv[i++] = new NamedVal(prefix, uri);
        }
        return nv;
     }
     
     /**
      * Executes an XPath query on the server. The results are returned as an
      * ResourceIterator
      *
      * @param query the XPath query string to execute.
      * @exception XMLDBException
      */
     public org.xmldb.api.base.ResourceSet query (String query)
           throws XMLDBException {
        // Get the Xindice collection object from the XML:DB collection wrapper.
        Collection col = ((CollectionImpl) collection).getServerObject();
  
        ResourceSet result = null;
        try {
           EncodedBuffer buffer = col.queryCollection("XPath", query,
              getNamespaces(), syms.getLastModified());
  
           if ( buffer.stamp != -1 ) {
              SymbolTable s = syms.getSymbols(buffer);
              result = new ResourceSetImpl(collection, s, buffer.buf);
           }
           else
              result = new ResourceSetImpl(collection,
                 EncodedBufferConverter.convertToDocument(buffer));
        }
        catch (Exception e) {
           result = new ResourceSetImpl(collection, null);
        }
  
        return result;
     }
     
     public org.xmldb.api.base.ResourceSet queryResource (String id, String 
query)
           throws XMLDBException {
        // Get the Xindice collection object from the XML:DB collection wrapper.
        Collection col = ((CollectionImpl) collection).getServerObject();
  
        ResourceSet result = null;
        try {
           EncodedBuffer buffer = col.queryDocument("XPath", query,
              getNamespaces(), id, syms.getLastModified());
  
           if ( buffer.stamp != -1 ) {
              SymbolTable s = syms.getSymbols(buffer);
              result = new ResourceSetImpl(collection, s, buffer.buf);
           }
           else
              result = new ResourceSetImpl(collection,
                 EncodedBufferConverter.convertToDocument(buffer));
        }
        catch (Exception e) {
           result = new ResourceSetImpl(collection, null);
        }
  
        return result;
     }
     
     public XMLResource queryResult(String query) throws XMLDBException {
        Collection col = ((CollectionImpl) collection).getServerObject();
  
        XMLResource result = null;
        try {
           EncodedBuffer buffer = col.queryCollection("XPath", query, 
getNamespaces(), syms.getLastModified());
  
           if ( buffer.stamp != -1 ) {
              SymbolTable s = syms.getSymbols(buffer);
              result = new XMLResourceImpl("", collection, s, buffer.buf);
           }
           else
              result = new XMLResourceImpl("", collection, new 
String(buffer.buf));
        }
        catch (Exception e) {
           result = null;
        }
  
        return result;
     }
  }
  
  
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/client/xmldb/corba/services/XUpdateQueryServiceImpl.java
  
  Index: XUpdateQueryServiceImpl.java
  ===================================================================
  package org.apache.xindice.client.xmldb.corba.services;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: XUpdateQueryServiceImpl.java,v 1.1 2002/07/11 03:17:07 kstaken Exp $
   */
  
  import org.apache.xindice.core.FaultCodes;
  import org.apache.xindice.client.corba.db.*;
  import org.apache.xindice.client.corba.*;
  import org.apache.xindice.client.corba.db.Collection;
  import org.apache.xindice.client.xmldb.*;
  import org.apache.xindice.client.xmldb.corba.*;
  
  import org.apache.xindice.client.xmldb.resources.*;
  
  import org.apache.xindice.xml.*;
  import org.apache.xindice.xml.dom.*;
  
  import org.w3c.dom.*;
  import org.xmldb.api.base.*;
  import org.xmldb.api.modules.*;
  
  import java.util.*;
  
  public class XUpdateQueryServiceImpl extends CommonConfigurable
     implements org.xmldb.api.modules.XUpdateQueryService
  {
     protected org.xmldb.api.base.Collection collection = null;
     private NamespaceMap nsMap = new NamespaceMap();
  
     public XUpdateQueryServiceImpl() {
     }
  
     public String getName() throws XMLDBException {
        return "XUpdateQueryService";
     }
  
     public String getVersion() throws XMLDBException {
        return "1.0";
     }
  
     public void setCollection(org.xmldb.api.base.Collection col)
           throws XMLDBException {
        this.collection = col;
     }
  
  
      public void setDefaultNamespace(String uri) throws XMLDBException {
         if ( uri != null )
            nsMap.setDefaultNamespace(uri);
         else
            nsMap.removeDefaultNamespace();
      }
  
      public void removeDefaultNamespace() {
         nsMap.removeDefaultNamespace();
      }
  
      public void setNamespace(String prefix, String uri) throws XMLDBException 
{
         if ( ( prefix == null ) || prefix.equals("") ) {
            setDefaultNamespace(uri);
         }
         else {
            if ( uri != null ) {
               nsMap.setNamespace(prefix, uri);
            }
         }
      }
  
      public void removeNamespace(String prefix) {
         if ( ( prefix == null ) || prefix.equals("") ) {
            removeDefaultNamespace();
         }
  
         nsMap.removeNamespace(prefix);
      }
  
      public String getDefaultNamespace() {
         return nsMap.getDefaultNamespaceURI();
      }
  
      public String getNamespace(String prefix) {
         if ( ( prefix == null ) || prefix.equals("") ) {
            return nsMap.getDefaultNamespaceURI();
         }
  
         return nsMap.getNamespaceURI(prefix);
      }
  
      public void clearNamespaces() {
         nsMap.clear();
      }
  
      private NamedVal[] getNamespaces() {
         NamedVal[] nv = new NamedVal[nsMap.size()];
         Iterator iter = nsMap.keySet().iterator();
         int i = 0;
         while ( iter.hasNext() ) {
            String prefix = (String)iter.next();
            String uri = nsMap.getNamespaceURI(prefix);
            nv[i++] = new NamedVal(prefix, uri);
         }
         return nv;
      }
  
     public XMLResource updateResult(String commands) throws XMLDBException {
        // Get the Xindice collection object from the XML:DB collection wrapper.
        Collection col = ((CollectionImpl) collection).getServerObject();
  
        try {
           EncodedBuffer buffer = col.queryCollection("XUpdate", commands, 
getNamespaces(), -1);
           return new XMLResourceImpl("", collection, new String(buffer.buf));
        }
        catch (Exception e) {
        e.printStackTrace();
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Runs a set of XUpdate operations against the collection. All selected
      * documents are to be updated and stored back to the repository.
      *
      * @param commands The XUpdate commands to use.
      * @return the number of nodes updated
      * @exception XMLDBException with expected error codes.<br />
      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
      *  specific errors that occur.<br />
      */
     public long update(String commands) throws XMLDBException {
        XMLResource result = updateResult(commands);
        return getResultCount(result);
     }
  
     public XMLResource updateResourceResult(String id, String commands) throws 
XMLDBException {
        // Get the Xindice collection object from the XML:DB collection wrapper.
        Collection col = ((CollectionImpl) collection).getServerObject();
  
        try {
           EncodedBuffer buffer = col.queryDocument("XUpdate", commands, 
getNamespaces(), id, -1);
           return new XMLResourceImpl("", collection, new String(buffer.buf));
        }
        catch (Exception e) {      
           throw FaultCodes.createXMLDBException(e);
        }
     }
  
     /**
      * Runs a set of XUpdate operations against a resource stored in a
      * collection. The resource will be updated in place in the collection.
      *
      * @param commands The XUpdate commands to use.
      * @return the number of nodes updateds
      * @exception XMLDBException with expected error codes.<br />
      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
      *  specific errors that occur.<br />
      */
     public long updateResource(String id, String commands) throws 
XMLDBException {
        XMLResource result = updateResourceResult(id, commands);
        return getResultCount(result);
     }
     
     protected long getResultCount(XMLResource resource) throws XMLDBException {
        Document doc = (Document) resource.getContentAsDOM();
        // Get the src:modified element
        Node node = doc.getDocumentElement().getFirstChild();
        // The count is a text node within the element.
        String count = node.getFirstChild().getNodeValue();
        
        try {
           return Long.parseLong(count);
        }
        catch (Exception e) {
           return 0;
        }
     }
  }
  
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/client/xmldb/corba/services/package.html
  
  Index: package.html
  ===================================================================
  <html>
    <title>XML:DB API Service Implementations.</title>
    <body>
      <p>Implements several XML:DB Services, including standard and extension 
services.</p>
   </body>
  </html>
  
  
  
  
  
  1.3       +13 -202   
xml-xindice/java/src/org/apache/xindice/client/xmldb/services/CollectionManager.java
  
  Index: CollectionManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/services/CollectionManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CollectionManager.java    26 Feb 2002 08:35:31 -0000      1.2
  +++ CollectionManager.java    11 Jul 2002 03:17:07 -0000      1.3
  @@ -59,18 +59,9 @@
    * $Id$
    */
   
  -import org.apache.xindice.xml.*;
  -import org.apache.xindice.xml.dom.*;
  -import org.apache.xindice.client.xmldb.*;
  -import org.apache.xindice.core.FaultCodes;
  -import org.apache.xindice.client.corba.db.*;
  -import org.apache.xindice.client.corba.EncodedBufferConverter;
  -
   import org.w3c.dom.*;
   
   import org.xmldb.api.base.*;
  -import org.xmldb.api.modules.*;
  -import org.xmldb.api.base.Collection;
   
   /**
    * CollectionManager provides management facilities for a Collection 
instance.
  @@ -78,70 +69,14 @@
    * interface. User level access is provided through the underlying Collection
    * itself.
    */
  -public class CollectionManager extends CommonConfigurable
  -      implements ManagedObject, Service, CollectionManagementService {
  -   protected org.apache.xindice.client.corba.db.CollectionManager manager = 
null;
  -   protected org.apache.xindice.client.corba.db.Database db = null;
  -   protected Collection collection = null;
  -   protected DatabaseImpl database = null;
  -
  -   /**
  -    * Creates a new CollectionManager service
  -    *
  -    * @param manager the server side CollectionManager to use.
  -    * @param db the root Database instance that the
  -    *        CollectionManager is associated with.
  -    * @param database a reference to the XML:DB Database instance for the 
API.
  -    */
  -   public 
CollectionManager(org.apache.xindice.client.corba.db.CollectionManager manager,
  -         org.apache.xindice.client.corba.db.Database db, DatabaseImpl 
database) {
  -      this.manager = manager;
  -      this.db = db;
  -      this.database = database;
  -   }
  -
  -   /**
  -    * Returns the name of the Service
  -    *
  -    * @return the name of the Service
  -    */
  -   public String getName() {
  -      return "CollectionManager";
  -   }
  -
  -   /**
  -    * Returns the version of the Service
  -    *
  -    * @return the version of the Service
  -    */
  -   public String getVersion() {
  -      return "1.0";
  -   }
  -
  -   /**
  -    * Provides a reference to the XML:DB collection instance that this 
service
  -    * is associated with.
  -    *
  -    * @param col the XML:DB collection instance associated with this Service
  -    */
  -   public void setCollection(org.xmldb.api.base.Collection col) {
  -      this.collection = col;
  -   }
  -
  +public interface CollectionManager {   
      /**
       * Returns the name of the collection that this manager is associated 
with.
       *
       * @return the name of the collection
       * @exception XMLDBException
       */
  -   public String getCollectionName() throws XMLDBException {
  -      try {
  -         return manager.getName();
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  +   public String getCollectionName() throws XMLDBException;
   
      /**
       * Returns the fully qualified name of the collection that this manager is
  @@ -150,14 +85,7 @@
       * @return the fully qualified name for this collection.
       * @exception XMLDBException
       */
  -   public String getCanonicalName() throws XMLDBException {
  -      try {
  -         return manager.getCanonicalName();
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  +   public String getCanonicalName() throws XMLDBException;
   
      /**
       * Creates a new collection in the database identified by name and using
  @@ -170,22 +98,7 @@
       * @exception XMLDBException
       */
      public Collection createCollection(String path, Document configuration)
  -         throws XMLDBException {
  -      try {
  -
  -         EncodedBuffer buffer =
  -           EncodedBufferConverter.convertFromDocument(configuration);
  -         Collection col = new CollectionImpl(manager.createCollection(path, 
buffer),
  -            db, database);
  -
  -         // db.addManagedObject(col);
  -
  -         return col;
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  +         throws XMLDBException;
      
      /**
       * Drops a child collection from this collection.
  @@ -193,14 +106,7 @@
       * @param collection The child collection to drop.
       * @exception XMLDBException
       */
  -   public void dropCollection(String name) throws XMLDBException {
  -      try {
  -         this.manager.dropCollection(name);
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  +   public void dropCollection(String name) throws XMLDBException;
   
      /**
       * Returns a list of all indexers for this collection.
  @@ -208,14 +114,7 @@
       * @return the list of indexers
       * @exception XMLDBException
       */
  -   public String[] listIndexers() throws XMLDBException {
  -      try {
  -         return manager.listIndexers();
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  +   public String[] listIndexers() throws XMLDBException;
   
      /**
       * Creates a new Indexer for this collection.
  @@ -225,17 +124,7 @@
       * @exception XMLDBException
       */
      public void createIndexer(Document configuration)
  -         throws XMLDBException {
  -      EncodedBuffer config =
  -        EncodedBufferConverter.convertFromDocument(configuration);
  -
  -      try {
  -         manager.createIndexer(config);
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  +         throws XMLDBException;
   
      /**
       * Drops the indexer from the collection
  @@ -244,14 +133,7 @@
       * @exception XMLDBException
       */
      public void dropIndexer(String name)
  -         throws XMLDBException {
  -      try {
  -         manager.dropIndexer(name);
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  +         throws XMLDBException;
   
      /**
       * Returns a list of all collection level XMLObjects for this collection.
  @@ -259,15 +141,8 @@
       * @return the list of XMLObjects.
       * @exception XMLDBException
       */
  -   public String[] listXMLObjects() throws XMLDBException {
  -      try {
  -         return manager.listXMLObjects();
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  -
  +   public String[] listXMLObjects() throws XMLDBException;
  +   
      /**
       * Creates a new collection level XMLObject using the provided 
configuration.
       * The XMLObject will be added to the collection using the provided name 
as
  @@ -278,16 +153,7 @@
       * @return The created XMLObject
       * @exception XMLDBException
       */
  -   public void createXMLObject(Document configuration) throws XMLDBException 
{
  -      EncodedBuffer config =
  -        EncodedBufferConverter.convertFromDocument(configuration);
  -      try {
  -         manager.createXMLObject(config);
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  +   public void createXMLObject(Document configuration) throws XMLDBException;
   
      /**
       * Drops a collection level XMLObject from the collection.
  @@ -296,61 +162,6 @@
       * @exception XMLDBException
       */
      public void dropXMLObject(String name)
  -         throws XMLDBException {
  -      try {
  -         manager.dropXMLObject(name);
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  -
  -   // Implementation of the CollectionManagementService interface
  -   
  -   /**
  -    * Creates a simple collection with a basic default configuration. More
  -    * complex configuration requires using a proprietary interface
  -    */
  -   public Collection createCollection(String name) throws XMLDBException {
  -      Document doc = new DocumentImpl();
  -
  -      Element colEle = doc.createElement("collection");
  -      colEle.setAttribute("compressed", "true");
  -      colEle.setAttribute("name", name);
  -
  -      doc.appendChild(colEle);
  -
  -      Element filEle = doc.createElement("filer");
  -      filEle.setAttribute("class", 
"org.apache.xindice.core.filer.BTreeFiler");
  -      filEle.setAttribute("gzip", "true");
  -
  -      colEle.appendChild(filEle);
  -
  -      return createCollection(name, doc);
  -   }
  -   
  -   /**
  -    * Removes the named collection from the system.
  -    */
  -   public void removeCollection(String name) throws XMLDBException {
  -      dropCollection(name);
  -   }
  -
  -   /**
  -    * Returns the underlying CORBA implementation object for this collection
  -    *
  -    * @return the server side object
  -    */
  -   protected org.apache.xindice.client.corba.db.CollectionManager 
getServerObject() {
  -      return manager;
  -   }
  -
  -   /**
  -    * Removes the server side Servant for this object. Should be called when 
the
  -    * the object is no longer needed.
  -    */
  -   public void remove() {
  -      manager.remove();
  -   }
  +         throws XMLDBException;
   }
   
  
  
  
  1.2       +4 -66     
xml-xindice/java/src/org/apache/xindice/client/xmldb/services/DatabaseInstanceManager.java
  
  Index: DatabaseInstanceManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/services/DatabaseInstanceManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DatabaseInstanceManager.java      6 Dec 2001 19:33:54 -0000       1.1
  +++ DatabaseInstanceManager.java      11 Jul 2002 03:17:07 -0000      1.2
  @@ -59,17 +59,7 @@
    * $Id$
    */
   
  -import org.apache.xindice.core.FaultCodes;
  -import org.apache.xindice.client.corba.EncodedBufferConverter;
  -import org.apache.xindice.client.corba.db.*;
  -import org.apache.xindice.client.xmldb.*;
  -
  -import java.util.*;
  -
  -import org.w3c.dom.Document;
  -
   import org.xmldb.api.base.*;
  -import org.xmldb.api.base.Collection;
   
   /**
     * DatabaseInstanceManager enables management of the Database intance on the
  @@ -78,36 +68,7 @@
     * In order to get a reference to the DatabaseInstanceManager object you 
must have
     * administrative access to the server.
     */
  -public class DatabaseInstanceManager extends CommonConfigurable
  -      implements ManagedObject, Service {
  -   protected org.apache.xindice.client.corba.db.Database db = null;
  -   protected DatabaseManager manager;
  -   protected DatabaseImpl database = null;
  -
  -   /**
  -    * Creates a new DatabaseInstanceManager instance
  -    */
  -   public DatabaseInstanceManager(DatabaseManager manager,
  -         org.apache.xindice.client.corba.db.Database db, DatabaseImpl 
database) {
  -      this.manager = manager;
  -      this.db = db;
  -      this.database = database;
  -   }
  -
  -   public String getName() {
  -      return "DatabaseInstanceManager";
  -   }
  -
  -   public String getVersion() {
  -      return "1.0";
  -   }
  -
  -   /**
  -    * Not used for the DatabaseInstanceManager service.
  -    */
  -   public void setCollection(org.xmldb.api.base.Collection col)
  -         throws XMLDBException {
  -   }
  +public interface DatabaseInstanceManager {
   
      /**
       * Returns the name of this database
  @@ -115,14 +76,7 @@
       * @return The name of this database
       * @exception XMLDBException
       */
  -   public String getDatabaseName() throws XMLDBException  {
  -      try {
  -         return manager.getName();
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  +   public String getDatabaseName() throws XMLDBException;
   
      /**
       * Shutsdown the Database instance
  @@ -130,22 +84,6 @@
       * @return the result of the shutdown operation
       * @exception XMLDBException
       */
  -   public void shutdown() throws XMLDBException {
  -      try {
  -         manager.shutdown();
  -         //return true;
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  -
  -   /**
  -    * Removes the server side Servant for this object. Should be called when 
the
  -    * the object is no longer needed.
  -    */
  -   public void remove() {
  -      manager.remove();
  -   }
  +   public void shutdown() throws XMLDBException;
   }
   
  
  
  
  1.2       +3 -55     
xml-xindice/java/src/org/apache/xindice/client/xmldb/services/XMLObjectService.java
  
  Index: XMLObjectService.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/services/XMLObjectService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLObjectService.java     6 Dec 2001 19:33:54 -0000       1.1
  +++ XMLObjectService.java     11 Jul 2002 03:17:07 -0000      1.2
  @@ -59,48 +59,14 @@
    * $Id$
    */
   
  -import org.apache.xindice.xml.*;
  -import org.apache.xindice.client.xmldb.*;
  -import org.apache.xindice.core.FaultCodes;
  -import org.apache.xindice.client.corba.db.*;
  -import org.apache.xindice.client.corba.EncodedBufferConverter;
  -
  -import org.w3c.dom.Document;
  -
   import org.xmldb.api.base.*;
  -import org.xmldb.api.base.Collection;
   
   /**
    * XMLObjectService enables invocation of XMLObjects within the Xindice 
server.
    *
    * The implementation of this functionality is currently quite simplistic.
    */
  -public class XMLObjectService extends CommonConfigurable
  -      implements Service {
  -   protected Collection collection = null;
  -   
  -   /**
  -    * Creates a new XMLObjectService to enable invocation of XMLObjects on 
the
  -    * server.
  -    */
  -   public XMLObjectService() {
  -   }
  -
  -   public String getName() {
  -      return "XMLObjectService";
  -   }
  -
  -   public String getVersion() {
  -      return "1.0";
  -   }
  -
  -   /**
  -    * Sets the collection associated with this service.
  -    */
  -   public void setCollection(org.xmldb.api.base.Collection col) {
  -      this.collection = col;
  -   }
  -
  +public interface XMLObjectService {
      /**
       * Invokes an XMLObject using the provided URI.
       *
  @@ -110,24 +76,6 @@
       * parent collection.
       * @exception XMLDBException Thrown if any error occurs.
       */
  -   public Resource invokeXMLObject(String uri) throws XMLDBException {
  -      try {
  -         // Create an empty Resource to hold the result of the invocation
  -         Resource result = collection.createResource(null, "XMLResource");
  -         
  -         // Invoke the object
  -         CollectionImpl col = (CollectionImpl) collection;
  -         EncodedBuffer buf = col.getServerObject().invokeXMLObject(uri);
  -         
  -         // TODO: we should make sure that no argument exceptions are thrown
  -         // TODO: properly handle result types.
  -         result.setContent(new String(buf.buf));
  -         return result;
  -      }
  -      catch (Exception e) {
  -         throw FaultCodes.createXMLDBException(e);
  -      }
  -   }
  -
  +   public Resource invokeXMLObject(String uri) throws XMLDBException;
   }
   
  
  
  

Reply via email to