vgritsenko    2003/12/25 11:16:06

  Modified:    java/src/org/apache/xindice/client/xmldb/xmlrpc
                        CollectionImpl.java
               java/src/org/apache/xindice/server/rpc/messages
                        InsertDocument.java
  Added:       java/src/org/apache/xindice/server/rpc/messages
                        InsertResource.java
  Log:
  Add InsertResource, deprecate InsertDocument
  
  Revision  Changes    Path
  1.41      +3 -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.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- CollectionImpl.java       24 Dec 2003 15:46:46 -0000      1.40
  +++ CollectionImpl.java       25 Dec 2003 19:16:06 -0000      1.41
  @@ -315,7 +315,7 @@
               params.put(RPCDefaultMessage.NAME, res.getId());
               params.put(RPCDefaultMessage.DOCUMENT, res.getContent());
   
  -            String name = (String) runRemoteCommand("InsertDocument", 
params);
  +            String name = (String) runRemoteCommand("InsertResource", 
params);
               if (res instanceof XMLResource) {
                   ((XMLResourceImpl) res).setId(name);
               } else {
  
  
  
  1.5       +11 -34    
xml-xindice/java/src/org/apache/xindice/server/rpc/messages/InsertDocument.java
  
  Index: InsertDocument.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/server/rpc/messages/InsertDocument.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InsertDocument.java       7 Aug 2003 20:13:23 -0000       1.4
  +++ InsertDocument.java       25 Dec 2003 19:16:06 -0000      1.5
  @@ -62,46 +62,23 @@
   import org.apache.xindice.core.Collection;
   import org.apache.xindice.server.rpc.RPCDefaultMessage;
   import org.apache.xindice.xml.dom.DOMParser;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   import org.w3c.dom.Document;
   
   import java.util.Hashtable;
   
   /**
  - *
  + * @deprecated Replaced with InsertResource which also handles binary data
    * @version CVS $Revision$, $Date$
    */
  -public class InsertDocument extends RPCDefaultMessage {
  -    public Hashtable execute(Hashtable message) throws Exception {
  -
  -        if (!message.containsKey(COLLECTION)) {
  -            throw new Exception(MISSING_COLLECTION_PARAM);
  -        }
  -
  -        if (!message.containsKey(NAME)) {
  -            throw new Exception(MISSING_NAME_PARAM);
  -        }
  -
  -        if (!message.containsKey(DOCUMENT)) {
  -            throw new Exception(MISSING_DOCUMENT_PARAM);
  -        }
  +public class InsertDocument extends InsertResource {
   
  -        Collection col = getCollection((String) message.get(COLLECTION));
  +    private static final Log log = LogFactory.getLog(InsertDocument.class);
   
  -        Document doc = DOMParser.toDocument((String) message.get(DOCUMENT));
  -        if (doc == null) {
  -            throw new Exception("Unable to parse Document");
  -        }
  -
  -        String id = (String) message.get(NAME);
  -        if (id.equals("")) {
  -            id = col.insertDocument(doc).toString();
  -        } else {
  -            col.insertDocument(id, doc);
  -        }
  -
  -        Hashtable result = new Hashtable();
  -        result.put(RESULT, id);
  -        return result;
  +    public Hashtable execute(Hashtable message) throws Exception {
  +        log.warn("Please use GetResource instead. GetResource supports same 
as GetDocument, plus binary resources");
  +        return super.execute(message);
       }
   }
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/server/rpc/messages/InsertResource.java
  
  Index: InsertResource.java
  ===================================================================
  /*
   * 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/>.
   *
   * CVS $Id: InsertResource.java,v 1.1 2003/12/25 19:16:06 vgritsenko Exp $
   */
  
  package org.apache.xindice.server.rpc.messages;
  
  import org.apache.xindice.core.Collection;
  import org.apache.xindice.server.rpc.RPCDefaultMessage;
  import org.apache.xindice.xml.dom.DOMParser;
  
  import org.w3c.dom.Document;
  
  import java.util.Hashtable;
  
  /**
   *
   * @version CVS $Revision: 1.1 $, $Date: 2003/12/25 19:16:06 $
   */
  public class InsertResource extends RPCDefaultMessage {
      public Hashtable execute(Hashtable message) throws Exception {
  
          if (!message.containsKey(COLLECTION)) {
              throw new Exception(MISSING_COLLECTION_PARAM);
          }
  
          if (!message.containsKey(NAME)) {
              throw new Exception(MISSING_NAME_PARAM);
          }
  
          if (!message.containsKey(DOCUMENT)) {
              throw new Exception(MISSING_DOCUMENT_PARAM);
          }
  
          Object obj = message.get(DOCUMENT);
          if (obj == null) {
              throw new Exception("Unable to parse Document");
          }
  
          String id = (String) message.get(NAME);
          if ("".equals(id)) {
              id = null;
          }
  
          Collection col = getCollection((String) message.get(COLLECTION));
          if (obj instanceof byte[]) {
              id = col.insertBinary(id, (byte[])obj).toString();
          } else {
              Document doc = DOMParser.toDocument((String) obj);
              id = col.insertDocument(id, doc).toString();
          }
  
          Hashtable result = new Hashtable();
          result.put(RESULT, id);
          return result;
      }
  }
  
  
  

Reply via email to