You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by ks...@apache.org on 2002/03/22 08:07:10 UTC

cvs commit: xml-xindice/java/scratchpad/src/org/apache/xindice/server/rpc/messages InsertDocument.java

kstaken     02/03/21 23:07:10

  Modified:    java/scratchpad/src/org/apache/xindice/server/rpc
                        Client.java
  Added:       java/scratchpad/src/org/apache/xindice/server/rpc/messages
                        InsertDocument.java
  Log:
  Correcting client
  
  Revision  Changes    Path
  1.2       +3 -4      xml-xindice/java/scratchpad/src/org/apache/xindice/server/rpc/Client.java
  
  Index: Client.java
  ===================================================================
  RCS file: /home/cvs/xml-xindice/java/scratchpad/src/org/apache/xindice/server/rpc/Client.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Client.java	22 Mar 2002 06:26:19 -0000	1.1
  +++ Client.java	22 Mar 2002 07:07:09 -0000	1.2
  @@ -56,7 +56,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - * $Id: Client.java,v 1.1 2002/03/22 06:26:19 kstaken Exp $
  + * $Id: Client.java,v 1.2 2002/03/22 07:07:09 kstaken Exp $
    */
   
   import java.util.*;
  @@ -78,11 +78,10 @@
      public static void main(String[] args) throws Exception {
         Hashtable message = new Hashtable();
         message.put("message", "GetDocument");
  -      message.put("key", "test");
  +      message.put("key", "utf8");
         message.put("collection", "/db/test3");
   
  -      Hastable result = run(message);
  +      Hashtable result = run(message);
         System.out.println(result.get("result"));
  -      System.out.println(((String) result.get("result")).getEncoding());
      }
   }
  
  
  
  1.1                  xml-xindice/java/scratchpad/src/org/apache/xindice/server/rpc/messages/InsertDocument.java
  
  Index: InsertDocument.java
  ===================================================================
  package org.apache.xindice.server.rpc.messages;
  
  /*
   * 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 apache@apache.org.
   *
   * 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: InsertDocument.java,v 1.1 2002/03/22 07:07:10 kstaken Exp $
   */
  
  import java.util.Hashtable;
  
  import org.w3c.dom.*;
  
  import org.apache.xindice.core.*;
  import org.apache.xindice.xml.*;
  import org.apache.xindice.server.rpc.*;
  
  /**
   *
   */
  public class InsertDocument extends RPCDefaultMessage {
     public static final String RESULT_PARAM = "result";
     public static final String KEY_PARAM = "key";
     public static final String COLLECTION_PARAM = "collection";
     
     // TODO: should have a simple way to validate params.
     
     public Hashtable execute(Hashtable message) throws Exception {
        Collection col = getCollection( (String) message.get(COLLECTION_PARAM) );
  
        Document doc = col.getDocument( (String) message.get(KEY_PARAM) );
        if ( doc == null ) {
           throw new Exception( "Document not found " +
                                (String) message.get(KEY_PARAM) );
        }
  
        Hashtable result = new Hashtable();
        result.put(RESULT_PARAM, TextWriter.toString( doc ));
        return result;
     }
  }