kevinross    2003/07/10 14:39:33

  Modified:    java/src/org/apache/xindice/server/rpc
                        RPCDefaultMessage.java RPCMessageInterface.java
               java/src/org/apache/xindice/server/rpc/messages
                        GetCollectionConfiguration.java
  Log:
  formatting, organize imports
  
  Revision  Changes    Path
  1.8       +74 -74    
xml-xindice/java/src/org/apache/xindice/server/rpc/RPCDefaultMessage.java
  
  Index: RPCDefaultMessage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/rpc/RPCDefaultMessage.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RPCDefaultMessage.java    27 Dec 2002 18:37:24 -0000      1.7
  +++ RPCDefaultMessage.java    10 Jul 2003 21:39:32 -0000      1.8
  @@ -67,77 +67,77 @@
    */
   public abstract class RPCDefaultMessage implements RPCMessage {
   
  -   public static final String API_NAME = "Xindice XML-RPC";
  -   public static final String API_VERSION = "0.1";
  -   public static final String RESULT = "result";
  -   public static final String NAME = "name";
  -   public static final String COLLECTION = "collection";
  -   public static final String DOCUMENT = "document";
  -   public static final String COMPRESSED = "compressed";
  -   public static final String TIMESTAMP = "timestamp";
  -   public static final String PATTERN = "pattern";
  -   public static final String MAXKEYSIZE = "maxkeysize";
  -   public static final String PAGESIZE = "pagesize";
  -   public static final String TYPE = "type";
  -   public static final String QUERY = "query";
  -   public static final String NAMESPACES = "namespaces";
  -   public static final String CONFIGURATION = "configuration";
  -   public static final String META = "meta";
  -
  -   public static final String MISSING_COLLECTION_PARAM = "Required parameter 
'collection' not found.";
  -   public static final String MISSING_NAME_PARAM = "Required parameter 
'name' not found.";
  -   public static final String MISSING_DOCUMENT_PARAM = "Required parameter 
'document' not found.";
  -   public static final String MISSING_PATTERN_PARAM = "Required parameter 
'pattern' not found.";
  -   public static final String MISSING_TYPE_PARAM = "Required parameter 
'type' not found.";
  -   public static final String MISSING_QUERY_PARAM = "Required parameter 
'query' not found.";
  -   public static final String MISSING_TIMESTAMP_PARAM = "For compressed 
results a timestamp must be provided.";
  -   public static final String MISSING_CONFIGURATION_PARAM = "You must either 
provide a document containing the configuration or specify the 'name' and 
'patter' parameters.";
  -   public static final String MISSING_META_CONFIGURATION = "Meta information 
requested but not enabled";
  -   public static final String MISSING_META_PARAM = "Required parameter 
'meta' not found";
  -
  -   /**
  -    * Retrieves a Collection instance based on the path provided in name.
  -    *
  -    * @param name The collection to retrieve
  -    * @return The Collection value
  -    * @exception Exception
  -    */
  -   protected Collection getCollection( String name ) throws Exception {
  -      // Get rid of any trailling slashes.
  -      while (name.endsWith("/")) {
  -         name = name.substring(0, name.lastIndexOf("/"));
  -      }
  -      
  -      // name must start with a /
  -      if ( name.startsWith( "/" ) ) {
  -         // find the database name. We just skip the first slash
  -         int colIndex = name.indexOf( '/', 1 );
  -
  -         // We assume there's no collection specified
  -         String dbName =  name.substring( 1 );;
  -         String colName = "/";
  -
  -         // if colIndex isn't -1 then we need to pick out the db and 
collection
  -         if ( colIndex != -1 ) {         
  -            dbName = name.substring( 1, colIndex );
  -
  -            // The rest of the name locates the collection
  -            colName = name.substring( colIndex + 1 );
  -         }
  -
  -         Database db = Database.getDatabase( dbName );
  -         if ( db == null ) {
  -            throw new Exception( "Database " + dbName + " could not be 
found" );
  -         }
  -         Collection col = db.getCollection( colName );
  -         if ( col == null ) {
  -            throw new Exception( "Collection " + colName + " could not be 
found" );
  -         }
  -
  -         return col;
  -      }
  -      else {
  -         throw new Exception( "Collection name must begin with a '/'" );
  -      }
  -   }   
  +     public static final String API_NAME = "Xindice XML-RPC";
  +     public static final String API_VERSION = "0.1";
  +     public static final String RESULT = "result";
  +     public static final String NAME = "name";
  +     public static final String COLLECTION = "collection";
  +     public static final String DOCUMENT = "document";
  +     public static final String COMPRESSED = "compressed";
  +     public static final String TIMESTAMP = "timestamp";
  +     public static final String PATTERN = "pattern";
  +     public static final String MAXKEYSIZE = "maxkeysize";
  +     public static final String PAGESIZE = "pagesize";
  +     public static final String TYPE = "type";
  +     public static final String QUERY = "query";
  +     public static final String NAMESPACES = "namespaces";
  +     public static final String CONFIGURATION = "configuration";
  +     public static final String META = "meta";
  +
  +     public static final String MISSING_COLLECTION_PARAM = "Required 
parameter 'collection' not found.";
  +     public static final String MISSING_NAME_PARAM = "Required parameter 
'name' not found.";
  +     public static final String MISSING_DOCUMENT_PARAM = "Required parameter 
'document' not found.";
  +     public static final String MISSING_PATTERN_PARAM = "Required parameter 
'pattern' not found.";
  +     public static final String MISSING_TYPE_PARAM = "Required parameter 
'type' not found.";
  +     public static final String MISSING_QUERY_PARAM = "Required parameter 
'query' not found.";
  +     public static final String MISSING_TIMESTAMP_PARAM = "For compressed 
results a timestamp must be provided.";
  +     public static final String MISSING_CONFIGURATION_PARAM = "You must 
either provide a document containing the configuration or specify the 'name' 
and 'patter' parameters.";
  +     public static final String MISSING_META_CONFIGURATION = "Meta 
information requested but not enabled";
  +     public static final String MISSING_META_PARAM = "Required parameter 
'meta' not found";
  +
  +     /**
  +      * Retrieves a Collection instance based on the path provided in name.
  +      *
  +      * @param name The collection to retrieve
  +      * @return The Collection value
  +      * @exception Exception
  +      */
  +     protected Collection getCollection(String name) throws Exception {
  +             // Get rid of any trailling slashes.
  +             while (name.endsWith("/")) {
  +                     name = name.substring(0, name.lastIndexOf("/"));
  +             }
  +
  +             // name must start with a /
  +             if (name.startsWith("/")) {
  +                     // find the database name. We just skip the first slash
  +                     int colIndex = name.indexOf('/', 1);
  +
  +                     // We assume there's no collection specified
  +                     String dbName = name.substring(1);
  +                     String colName = "/";
  +
  +                     // if colIndex isn't -1 then we need to pick out the db 
and collection
  +                     if (colIndex != -1) {
  +                             dbName = name.substring(1, colIndex);
  +
  +                             // The rest of the name locates the collection
  +                             colName = name.substring(colIndex + 1);
  +                     }
  +
  +                     Database db = Database.getDatabase(dbName);
  +                     if (db == null) {
  +                             throw new Exception("Database " + dbName + " 
could not be found");
  +                     }
  +                     Collection col = db.getCollection(colName);
  +                     if (col == null) {
  +                             throw new Exception("Collection " + colName + " 
could not be found");
  +                     }
  +
  +                     return col;
  +             }
  +             else {
  +                     throw new Exception("Collection name must begin with a 
'/'");
  +             }
  +     }
   }
  
  
  
  1.4       +7 -13     
xml-xindice/java/src/org/apache/xindice/server/rpc/RPCMessageInterface.java
  
  Index: RPCMessageInterface.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/rpc/RPCMessageInterface.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RPCMessageInterface.java  17 Nov 2002 20:33:52 -0000      1.3
  +++ RPCMessageInterface.java  10 Jul 2003 21:39:32 -0000      1.4
  @@ -66,18 +66,12 @@
    */
   public final class RPCMessageInterface {
   
  -   public static final String MESSAGE_PARAM = "message";
  +     public static final String MESSAGE_PARAM = "message";
   
  -   public Hashtable run(Hashtable message) throws Exception {
  -      // The method determines what class we load to handle the message.
  -      RPCMessage handler = null;
  -      handler = (RPCMessage) 
Class.forName("org.apache.xindice.server.rpc.messages." +
  -            message.get(MESSAGE_PARAM)).newInstance();
  -
  -      return handler.execute(message);
  -   }
  +     public Hashtable run(Hashtable message) throws Exception {
  +             // The method determines what class we load to handle the 
message.
  +             RPCMessage handler = (RPCMessage) 
Class.forName("org.apache.xindice.server.rpc.messages." + 
message.get(MESSAGE_PARAM)).newInstance();
  +             return handler.execute(message);
  +     }
   
   }
  -
  -
  -
  
  
  
  1.6       +17 -18    
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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- GetCollectionConfiguration.java   30 Dec 2002 11:06:06 -0000      1.5
  +++ GetCollectionConfiguration.java   10 Jul 2003 21:39:32 -0000      1.6
  @@ -67,27 +67,26 @@
   /**
    *
    */
  -public class GetCollectionConfiguration extends RPCDefaultMessage {   
  -   
  -   public Hashtable execute(Hashtable message) throws Exception {
  +public class GetCollectionConfiguration extends RPCDefaultMessage {
   
  -      if(!message.containsKey(COLLECTION)) {
  -         throw new Exception(MISSING_COLLECTION_PARAM);
  -      }
  +     public Hashtable execute(Hashtable message) throws Exception {
   
  -      // TODO: figure out what goes here.  done.
  +             if (!message.containsKey(COLLECTION)) {
  +                     throw new Exception(MISSING_COLLECTION_PARAM);
  +             }
   
  -      Hashtable result = new Hashtable();
  -      try {
  +             Hashtable result = new Hashtable();
  +             try {
   
  -          /* getCollection() throws an exception if collection doesnt exist 
*/
  -          Collection col = getCollection( (String) message.get(COLLECTION) );
  -          result.put(RESULT, "yes");
  -      } catch (Exception e) {
  +                     /* 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");
  -      }
  +                     result.put(RESULT, "no");
  +             }
   
  -      return result;
  -   }
  +             return result;
  +     }
   }
  
  
  

Reply via email to