jbates      2002/12/30 03:06:07

  Modified:    .        build.xml
               java/src/org/apache/xindice/client/xmldb/xmlrpc
                        CollectionImpl.java
               java/src/org/apache/xindice/server/rpc/messages
                        CreateIndexer.java GetCollectionConfiguration.java
                        GetIndexerConfiguration.java RemoveCollection.java
  Added:       java/lib xml-apis-1.1.jar
  Removed:     java/lib xml-apis-1.0b3.jar xml-apis-2.2.1.jar
  Log:
  Fixed TODO's in XML-RPC server handler.
  Also inserted correct xml-apis.jar
  
  Revision  Changes    Path
  1.38      +2 -2      xml-xindice/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xindice/build.xml,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- build.xml 23 Dec 2002 21:30:24 -0000      1.37
  +++ build.xml 30 Dec 2002 11:06:06 -0000      1.38
  @@ -76,7 +76,7 @@
           <include name="commons-logging-1.0.1.jar" />
           <include name="xalan-2.4.0.jar"/>
           <include name="xercesImpl-2.1.0.jar"/>
  -        <include name="xml-apis-2.2.1.jar"/>
  +        <include name="xml-apis-1.1.jar"/>
           <include name="xmldb-common.jar"/>
           <include name="xmldb-api-20021118.jar"/>
           <include name="xmldb-api-sdk-20021118.jar"/>
  
  
  
  1.1                  xml-xindice/java/lib/xml-apis-1.1.jar
  
        <<Binary file>>
  
  
  1.20      +15 -3     
xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java
  
  Index: CollectionImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- CollectionImpl.java       23 Dec 2002 21:28:59 -0000      1.19
  +++ CollectionImpl.java       30 Dec 2002 11:06:06 -0000      1.20
  @@ -142,7 +142,13 @@
               /* Just check the collection does actually exist */
               Hashtable params = new Hashtable();
               params.put(RPCDefaultMessage.COLLECTION, collPath);
  -            runRemoteCommand("GetCollectionConfiguration", params);
  +            String exists =
  +                    (String) runRemoteCommand("GetCollectionConfiguration", 
params);
  +            if (!"yes".equals(exists)) {
  +
  +                throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
  +                                     "Collection not found: " + collPath);
  +            }
           } catch (MalformedURLException e) {
               
                        client = null;
  @@ -606,7 +612,13 @@
               Hashtable params = new Hashtable();
               params.put(RPCDefaultMessage.COLLECTION, collPath);
               params.put(RPCDefaultMessage.NAME, childName);
  -            runRemoteCommand("RemoveCollection", params);
  +            String result = (String) runRemoteCommand("RemoveCollection", 
params);
  +
  +            if (!result.equals("yes")) {
  +
  +                throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
  +                    "Cannot remove child collection");
  +            }
           } catch (Exception e) {
               
               throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
  
  
  
  1.4       +4 -3      
xml-xindice/java/src/org/apache/xindice/server/rpc/messages/CreateIndexer.java
  
  Index: CreateIndexer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/rpc/messages/CreateIndexer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CreateIndexer.java        31 Oct 2002 07:00:44 -0000      1.3
  +++ CreateIndexer.java        30 Dec 2002 11:06:06 -0000      1.4
  @@ -92,8 +92,9 @@
               throw new Exception( "Unable to parse Indexer configuration" );
            }
            
  -         // TODO: should extract the name from the document.
  -         message.put(NAME, "");
  +         // TODO: should extract the name from the document. done.
  +         String name = doc.getDocumentElement().getAttribute("name");
  +         message.put(NAME, name);
         }
         // Otherwise we need to build the configuration from the name and 
pattern.
         else {
  
  
  
  1.5       +13 -4     
xml-xindice/java/src/org/apache/xindice/server/rpc/messages/GetCollectionConfiguration.java
  
  Index: GetCollectionConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/rpc/messages/GetCollectionConfiguration.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- GetCollectionConfiguration.java   23 Dec 2002 21:39:05 -0000      1.4
  +++ GetCollectionConfiguration.java   30 Dec 2002 11:06:06 -0000      1.5
  @@ -60,6 +60,7 @@
    */
   
   import org.apache.xindice.server.rpc.RPCDefaultMessage;
  +import org.apache.xindice.core.Collection;
   
   import java.util.Hashtable;
   
  @@ -74,11 +75,19 @@
            throw new Exception(MISSING_COLLECTION_PARAM);
         }
   
  -      // TODO: figure out what goes here.
  -      // Collection col = getCollection( (String) message.get(COLLECTION) );
  +      // TODO: figure out what goes here.  done.
   
         Hashtable result = new Hashtable();
  -      result.put(RESULT, "yes");
  +      try {
  +
  +          /* getCollection() throws an exception if collection doesnt exist 
*/
  +          Collection col = getCollection( (String) message.get(COLLECTION) );
  +          result.put(RESULT, "yes");
  +      } catch (Exception e) {
  +
  +          result.put(RESULT, "no");
  +      }
  +
         return result;
      }
   }
  
  
  
  1.5       +25 -5     
xml-xindice/java/src/org/apache/xindice/server/rpc/messages/GetIndexerConfiguration.java
  
  Index: GetIndexerConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/rpc/messages/GetIndexerConfiguration.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- GetIndexerConfiguration.java      23 Dec 2002 21:39:05 -0000      1.4
  +++ GetIndexerConfiguration.java      30 Dec 2002 11:06:06 -0000      1.5
  @@ -60,11 +60,15 @@
    */
   
   import org.apache.xindice.server.rpc.RPCDefaultMessage;
  +import org.apache.xindice.core.Collection;
  +import org.apache.xindice.core.indexer.Indexer;
   
   import java.util.Hashtable;
   
   /**
  + * Check if an indexer in a particular collection exists...
    *
  + * Warning: this message is not used at all by the current XML-RPC client...
    */
   public class GetIndexerConfiguration extends RPCDefaultMessage {   
      
  @@ -74,11 +78,27 @@
            throw new Exception(MISSING_COLLECTION_PARAM);
         }
   
  -      // TODO: figure out what goes here.
  -      // Collection col = getCollection( (String) message.get(COLLECTION) );
  -
         Hashtable result = new Hashtable();
  -      result.put(RESULT, "yes");
  +
  +      // TODO: figure out what goes here. done.
  +      try {
  +
  +          Collection col = getCollection( (String) message.get(COLLECTION) );
  +          Indexer idx = col.getIndexer((String) message.get(NAME));
  +
  +          if (idx != null) {
  +
  +              result.put(RESULT, "yes");
  +          } else {
  +
  +              result.put(RESULT, "no");
  +          }
  +      } catch (Exception e) {
  +
  +          /* No such collection */
  +          result.put(RESULT, "no");
  +      }
  +
         return result;
      }
   }
  
  
  
  1.3       +15 -7     
xml-xindice/java/src/org/apache/xindice/server/rpc/messages/RemoveCollection.java
  
  Index: RemoveCollection.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/rpc/messages/RemoveCollection.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RemoveCollection.java     31 Oct 2002 07:00:44 -0000      1.2
  +++ RemoveCollection.java     30 Dec 2002 11:06:06 -0000      1.3
  @@ -68,7 +68,7 @@
    *
    */
   public class RemoveCollection extends RPCDefaultMessage {   
  -   // TODO: should have a simple way to validate params.
  +   // TODO: should have a simple way to validate params. done.
   
      public Hashtable execute(Hashtable message) throws Exception {
   
  @@ -79,13 +79,21 @@
         if ( ! message.containsKey(NAME) ) {
            throw new Exception(MISSING_NAME_PARAM);
         }
  -      
  -      Collection col = getCollection( (String) message.get(COLLECTION)
  +
  +       Hashtable result = new Hashtable();
  +      try {
  +
  +          Collection col = getCollection( (String) message.get(COLLECTION)
                                         + "/" + (String) message.get(NAME));
  -      col.dropCollection( col );
  +          col.dropCollection( col );
  +          result.put(RESULT, "yes");
  +
  +      } catch (Exception e) {
  +
  +          /* No such collection... */
  +          result.put(RESULT, "no");
  +      }
   
  -      Hashtable result = new Hashtable();
  -      result.put(RESULT, "yes");
         return result;
      }
   }
  
  
  

Reply via email to