logo       

cvs commit: xml-xindice/java/src/org/apache/xindice/server/rpc/messages Ins: msg#00238

Subject: cvs commit: xml-xindice/java/src/org/apache/xindice/server/rpc/messages InsertResource.java InsertDocument.java
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 apache@xxxxxxxxxxx
   *
   * 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;
      }
  }
  
  
  



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe