You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by Scott Sanders <sa...@totalsync.com> on 2000/12/23 05:54:50 UTC

[PATCH] WebDAVXMLPrinter.java namespace info bug

Below is a patch to WebDAVXMLPrinter.java and PropPatchMethod.java.

I just got latest from CVS, and I am attempting to do a PROPPATCH into
Exchange 2000 on a Win 2000 server.  Everything works, except for the record
not actually being created.  I looked into it, and in the WebDAVXMLPrinter
class, in the writeElement() method, a colon is being appended to the
namespace info when writing the element.  Since I am dealing with 6
namespaces and not all of them have colons on the end, this is a problem.

I am assuming that many other methods will also need patched when the write
the opening 'DAV' element.

Three other questions and one comment:

Q1: Would you guys be OK with me contributing a patch for a group of
addNamespace() methods to PropPatchMethod.java as well as
WebDAVXMLPrinter.java to just print the namespaces in the root element?

Q2: What version of JUnit are you integrating?  I got compile errors with
both v3.2 and v3.4.  I was able to compile by modifying the TestXXX.java
classes.  Would you like a patch for that as well?

Q3:  Are you guys interested in a patch for more debug info?  I have coded
up debug info to print out the request and the response, and it has helped
me very much in debugging the issues I am having.

Comment:  After attempting to use Cadaver, Slide, and Dav4J, I can say that
from the client side you guys have done some excellent work.  As you can
probably guess, I will be using slide to retrieve and update information
from Exchange 2000 using WebDAV.  I will only be using the client side of
Slide (for now), but I can say that I will definetly be using it.  Thanks
for the good work.

Scott Sanders
Chief Architect
TotalSync

PS.  As far as I could tell, my JBuilder4 automatically converted tabs to
spaces, so the WebDAVXMLPrinter diff is actually larger than it should be.
Apologies.

cvs -d :pserver:anoncvs@jakarta.apache.org:/home/cvspublic diff -u

Index: methods/PropPatchMethod.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/me
thods/PropPatchMethod.java,v
retrieving revision 1.7
diff -u -r1.7 PropPatchMethod.java
--- methods/PropPatchMethod.java        2000/12/11 03:56:40     1.7
+++ methods/PropPatchMethod.java        2000/12/23 04:32:48
@@ -229,7 +229,7 @@

         WebdavXMLPrinter printer = new WebdavXMLPrinter();
         printer.writeXMLHeader();
-        printer.writeElement("D", "DAV", "propertyupdate",
+        printer.writeElement("D", "DAV:", "propertyupdate",
                              WebdavXMLPrinter.OPENING);

         if (toSet.size() > 0) {
@@ -275,7 +275,7 @@

         }

-        printer.writeElement("D", "DAV", "propertyupdate",
+        printer.writeElement("D", "DAV:", "propertyupdate",
                              WebdavXMLPrinter.CLOSING);
         return printer.toString();
     }


Index: util/WebdavXMLPrinter.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/ut
il/WebdavXMLPrinter.java
,v
retrieving revision 1.1
diff -u -r1.1 WebdavXMLPrinter.java
--- util/WebdavXMLPrinter.java  2000/11/22 06:19:11     1.1
+++ util/WebdavXMLPrinter.java  2000/12/23 04:32:49
@@ -7,7 +7,7 @@
  *
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
+ *    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
@@ -23,15 +23,15 @@
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution, if
- *    any, must include the following acknowlegement:
- *       "This product includes software developed by the
+ *    any, must include the following acknowlegement:
+ *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowlegement may appear in the software itself,
  *    if and wherever such third-party acknowlegements normally appear.
  *
  * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
  *    Foundation" must not be used to endorse or promote products derived
- *    from this software without prior written permission. For written
+ *    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"
@@ -59,81 +59,81 @@
  *
  * [Additional notices, if required by prior licensing conditions]
  *
- */
+ */

 package org.apache.webdav.lib.util;

 /**
  * WebdavXMLPrinter helper class.
- *
+ *
  * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  */
 public class WebdavXMLPrinter {
-
-
+
+
     // --------------------------------------------------------------
Constants
-
-
+
+
     /**
      * Opening tag.
      */
     public static final int OPENING = 0;
-
-
+
+
     /**
      * Closing tag.
      */
     public static final int CLOSING = 1;
-
-
+
+
     /**
      * Element with no content.
      */
     public static final int NO_CONTENT = 2;
-
-
+
+
     // -----------------------------------------------------------
Constructors
-
-
+
+
     /**
      * Constructor.
      */
     public WebdavXMLPrinter() {
         buffer = new StringBuffer();
     }
-
-
+
+
     // ----------------------------------------------------- Instance
Variables
-
-
+
+
     /**
      * Buffer.
      */
     protected StringBuffer buffer;
-
-
+
+
     // --------------------------------------------------------- Public
Methods
-
-
+
+
     /**
      * Write property to the XML.
-     *
+     *
      * @param namespace Namespace
      * @param namespaceInfo Namespace info
      * @param name Property name
      * @param value Property value
      */
-    public void writeProperty(String namespace, String namespaceInfo,
+    public void writeProperty(String namespace, String namespaceInfo,
                               String name, String value) {
         writeElement(namespace, namespaceInfo, name, OPENING);
         buffer.append(value);
         writeElement(namespace, namespaceInfo, name, CLOSING);
     }
-
-
+
+
     /**
      * Write property to the XML.
-     *
+     *
      * @param namespace Namespace
      * @param name Property name
      * @param value Property value
@@ -143,22 +143,22 @@
         buffer.append(value);
         writeElement(namespace, name, CLOSING);
     }
-
-
+
+
     /**
      * Write property to the XML.
-     *
+     *
      * @param namespace Namespace
      * @param name Property name
      */
     public void writeProperty(String namespace, String name) {
         writeElement(namespace, name, NO_CONTENT);
     }
-
-
+
+
     /**
      * Write an element.
-     *
+     *
      * @param name Element name
      * @param namespace Namespace abbreviation
      * @param type Element type
@@ -166,25 +166,25 @@
     public void writeElement(String namespace, String name, int type) {
         writeElement(namespace, null, name, type);
     }
-
-
+
+
     /**
      * Write an element.
-     *
+     *
      * @param namespace Namespace abbreviation
      * @param namespaceInfo Namespace info
      * @param name Element name
      * @param type Element type
      */
-    public void writeElement(String namespace, String namespaceInfo,
+    public void writeElement(String namespace, String namespaceInfo,
                              String name, int type) {
         if ((namespace != null) && (namespace.length() > 0)) {
             switch (type) {
             case OPENING:
                 if (namespaceInfo != null) {
-                    buffer.append("<" + namespace + ":" + name + " xmlns:"
-                                  + namespace + "=\""
-                                  + namespaceInfo + ":\">");
+                    buffer.append("<" + namespace + ":" + name + " xmlns:"
+                                  + namespace + "=\""
+                                  + namespaceInfo + "\">");
                 } else {
                     buffer.append("<" + namespace + ":" + name + ">");
                 }
@@ -195,9 +195,9 @@
             case NO_CONTENT:
             default:
                 if (namespaceInfo != null) {
-                    buffer.append("<" + namespace + ":" + name
-                                  + " xmlns:" + namespace
-                                  + "=\"" + namespaceInfo + ":\"/>");
+                    buffer.append("<" + namespace + ":" + name
+                                  + " xmlns:" + namespace
+                                  + "=\"" + namespaceInfo + "\"/>");
                 } else {
                     buffer.append("<" + namespace + ":" + name + "/>");
                 }
@@ -218,36 +218,36 @@
             }
         }
     }
-
-
+
+
     /**
      * Write text.
-     *
+     *
      * @param text Text to append
      */
     public void writeText(String text) {
         buffer.append(text);
     }
-
-
+
+
     /**
      * Write XML Header.
      */
     public void writeXMLHeader() {
         buffer.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
     }
-
-
+
+
     // --------------------------------------------------------- Object
Methods
-
-
+
+
     /**
      * Retrieve generated XML.
-     *
+     *
      * @return String containing the generated XML
      */
     public String toString() {
         return buffer.toString();
     }
-
+
 }



Re: [PATCH] WebDAVXMLPrinter.java namespace info bug

Posted by Remy Maucherat <re...@apache.org>.
> =========
>
> public class PropPatchMethod
>     public String generateQuery() {
>        printer.writeElement("D", "DAV:", "propertyupdate",
>                              WebdavXMLPrinter.OPENING);
> +        printer.writeElement("D", "propertyupdate",
> WebdavXMLPrinter.CLOSING);

The namespace name parameter is ignored in closing tags, so the namespace
name can be left in here.

> =========
>
> public class PropFindMethod extends XMLResponseMethodBase
>     public String generateQuery() {
> +        printer.writeElement("D", "DAV:", "propfind",
> WebdavXMLPrinter.OPENING);
> +        printer.writeElement("D", "propfind", WebdavXMLPrinter.CLOSING);
>
> =========
>

Ooops, yet another typo. I'll commit the fix ASAP.

Thanks,
Remy


A bug in DOMUtils.java

Posted by "Park, Sung-Gu" <je...@thinkfree.com>.
Have you ever tested the slide with XML, DOM Level 2?

Hmm...
Finally, I found it.  I can keep to work for a test.  ^___^
Because of this,  I was in trouble.  -_-;

=========================================================

public class DOMUtils {
    <snip>

    public static NodeList getElementsByTagNameNS(
        Node node, String tagName, String namespace) {

       <snip>

-                    Object[] params = { tagName, namespace };
+                    Object[] params = { namespace, tagName };


=========================================================

※           getElementsByTagNameNS introduced in DOM Level 2

               Returns a NodeList of all the Elements with a given local
               name and namespace URI in the order in which they are
               encountered in a preorder traversal of the Document tree.
               Parameters
               namespaceURI of type DOMString
                    The namespace URI of the elements to match on. The
                    special value "*" matches all namespaces.
               localName of type DOMString
                    The local name of the elements to match on. The special
                    value "*" matches all local names.
               Return Value
               NodeList A new NodeList object containing all the matched
                        Elements.
               No Exceptions




Slide client?(cmd/Main.java)

Posted by "Park, Sung-Gu" <je...@thinkfree.com>.
Well... slide client...  It has somewhat wrong parts...
Especially, the parts without using properly PROPFIND for "cd" and more.

And it doesn't consider of multi-session management for the webdav client.
It needs kinda several helpers for the webdav client.

I'm working on that part...   ^^
Just refer to my interest.

P.S.: Remy, I hope you send me your test codes of XMLResponseMethodBase for
lib/properties
        what if you have still them... Thank you in advance...   it's ok not
to send me them...  ^^;
        mailto:jericho@thinkfree.com



Re: [PATCH] WebDAVXMLPrinter.java namespace info bug

Posted by "Park, Sung-Gu" <je...@thinkfree.com>.
In the case of changing WebDAVXMLPrinter, we need these corrections also.



=========

public class PropPatchMethod
    public String generateQuery() {
       printer.writeElement("D", "DAV:", "propertyupdate",
                             WebdavXMLPrinter.OPENING);
+        printer.writeElement("D", "propertyupdate",
WebdavXMLPrinter.CLOSING);

=========

public class PropFindMethod extends XMLResponseMethodBase
    public String generateQuery() {
+        printer.writeElement("D", "DAV:", "propfind",
WebdavXMLPrinter.OPENING);
+        printer.writeElement("D", "propfind", WebdavXMLPrinter.CLOSING);

=========


----- Original Message -----
From: "Remy Maucherat" <re...@betaversion.org>
To: <sl...@jakarta.apache.org>
Sent: Sunday, December 24, 2000 7:01 AM
Subject: Re: [PATCH] WebDAVXMLPrinter.java namespace info bug


| Quoting Scott Sanders <sa...@totalsync.com>:
|
| > Q1: Would you guys be OK with me contributing a patch for a group of
| > addNamespace() methods to PropPatchMethod.java as well as
| > WebDAVXMLPrinter.java to just print the namespaces in the root element?
|
| No extra method should be needed. addPropertyToSet / addPropertyToRemove
and
| the method body generation could do that is they were a bit smarter.
|
| > Comment:  After attempting to use Cadaver, Slide, and Dav4J, I can say
| > that
| > from the client side you guys have done some excellent work.  As you
| > can
| > probably guess, I will be using slide to retrieve and update
| > information
| > from Exchange 2000 using WebDAV.  I will only be using the client side
| > of
| > Slide (for now), but I can say that I will definetly be using it.
| > Thanks
| > for the good work.
|
| :)
|
| Remy
|


Re: [PATCH] WebDAVXMLPrinter.java namespace info bug

Posted by Remy Maucherat <re...@betaversion.org>.
Quoting Scott Sanders <sa...@totalsync.com>:

> Q1: Would you guys be OK with me contributing a patch for a group of
> addNamespace() methods to PropPatchMethod.java as well as
> WebDAVXMLPrinter.java to just print the namespaces in the root element?

No extra method should be needed. addPropertyToSet / addPropertyToRemove and 
the method body generation could do that is they were a bit smarter.

> Comment:  After attempting to use Cadaver, Slide, and Dav4J, I can say
> that
> from the client side you guys have done some excellent work.  As you
> can
> probably guess, I will be using slide to retrieve and update
> information
> from Exchange 2000 using WebDAV.  I will only be using the client side
> of
> Slide (for now), but I can say that I will definetly be using it. 
> Thanks
> for the good work.

:)

Remy