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 bc...@locus.apache.org on 2000/12/04 07:32:48 UTC

cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/properties ResourceType.java

bcholmes    00/12/03 22:32:47

  Modified:    src/webdav/client/src/org/apache/webdav/lib/methods
                        CopyMethod.java DeleteMethod.java LockMethod.java
                        MoveMethod.java PropFindMethod.java
                        WebdavMethod.java WebdavMethodBase.java
                        XMLResponseMethodBase.java
  Added:       src/webdav/client/src/org/apache/webdav/lib/properties
                        ResourceType.java
  Log:
  - start creating interfaces to model the properties that we know about (ResourceType is first)
  - Revise XMLResponseMethodBase to move the XML parsing into a different method (parseXMLResponse()) so that we can remove the requirement of the subclassing class
  - Allow a WebdavException to be thrown from the parseResponse() message
  - make DeleteMethod an XML Response method.
  
  Revision  Changes    Path
  1.3       +52 -79    jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CopyMethod.java
  
  Index: CopyMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CopyMethod.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CopyMethod.java	2000/11/30 02:23:03	1.2
  +++ CopyMethod.java	2000/12/04 06:32:40	1.3
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CopyMethod.java,v 1.2 2000/11/30 02:23:03 remm Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/11/30 02:23:03 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CopyMethod.java,v 1.3 2000/12/04 06:32:40 bcholmes Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/12/04 06:32:40 $
    *
    * ====================================================================
    *
    * 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,149 +59,122 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   package org.apache.webdav.lib.methods;
   
  -import java.io.*;
  -import java.util.*;
   import org.apache.webdav.lib.State;
   import org.apache.webdav.lib.Header;
  -import org.apache.webdav.lib.WebdavStatus;
  -
   
   /**
    * COPY Method.
  - * 
  + *
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  + * @author <a href="mailto:bcholmes@interlog.com">B.C. Holmes</a>
    */
   public class CopyMethod
  -    extends WebdavMethodBase {
  -    
  -    
  +    extends XMLResponseMethodBase {
  +
  +
       // ----------------------------------------------------------- Constructors
  -    
  -    
  +
  +
       /**
        * Method constructor.
        */
       public CopyMethod() {
  -        
  +
           name = "COPY";
  -        
  +
       }
  -    
  -    
  +
  +
       // ----------------------------------------------------- Instance Variables
  -    
  -    
  +
  +
       /**
        * Destination.
        */
       private String destination;
  -    
  -    
  +
  +
       /**
        * Overwrite.
        */
       private boolean overwrite = true;
  -    
  -    
  +
  +
       // ----------------------------------------------------- Instance Variables
  -    
  -    
  +
  +
       /**
        * Destination setter.
  -     * 
  +     *
        * @param destination New destination value
        */
       public void setDestination(String destination) {
           checkNotUsed();
           this.destination = destination;
       }
  -    
  -    
  +
  +
       /**
        * Destination getter.
  -     * 
  +     *
        * @return String destination value
        */
       public String getDestination() {
           return destination;
       }
  -    
  -    
  +
  +
       /**
        * Overwrite setter.
  -     * 
  +     *
        * @param overwrite New overwrite value
        */
       public void setOverwrite(boolean overwrite) {
           checkNotUsed();
           this.overwrite = overwrite;
       }
  -    
  -    
  +
  +
       /**
        * Overwrite getter.
  -     * 
  +     *
        * @return boolean Overwrite value
        */
       public boolean isOverwrite() {
           return overwrite;
       }
  -    
  -    
  +
  +
       /**
        * Overwrite getter.
  -     * 
  +     *
        * @return boolean Overwrite value
        */
       public boolean getOverwrite() {
           return overwrite;
       }
  -    
  -    
  +
  +
       // --------------------------------------------------- WebdavMethod Methods
  -    
  -    
  +
  +
       /**
        * Generate additional headers needed by the request.
  -     * 
  +     *
  +     * @param host the host
        * @param state State token
        */
  -    public void generateHeaders(State state) {
  -        
  -        super.generateHeaders(state);
  -        
  +    public void generateHeaders(String host, State state) {
  +
  +        super.generateHeaders(host, state);
  +
           setHeader("Destination", destination);
           if (!isOverwrite())
               setHeader("Overwrite", "F");
  -        
  -    }
  -    
  -    
  -    /**
  -     * Generate the query body.
  -     * 
  -     * @return String query
  -     */
  -    public String generateQuery() {
  -        return null;
  -    }
  -    
  -    
  -    /**
  -     * Parse response.
  -     * 
  -     * @param is Input stream
  -     */
  -    public void parseResponse(InputStream is)
  -        throws IOException {
  -        
  -        // Parse the 207 error report
  -        
  +
       }
  -    
  -    
   }
  
  
  
  1.2       +50 -49    jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/DeleteMethod.java
  
  Index: DeleteMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/DeleteMethod.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeleteMethod.java	2000/11/22 06:19:09	1.1
  +++ DeleteMethod.java	2000/12/04 06:32:41	1.2
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/DeleteMethod.java,v 1.1 2000/11/22 06:19:09 remm Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/11/22 06:19:09 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/DeleteMethod.java,v 1.2 2000/12/04 06:32:41 bcholmes Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/12/04 06:32:41 $
    *
    * ====================================================================
    *
    * 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,65 +59,66 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   package org.apache.webdav.lib.methods;
   
  -import java.io.*;
  -import java.util.*;
   import org.apache.webdav.lib.State;
   import org.apache.webdav.lib.Header;
   import org.apache.webdav.lib.WebdavStatus;
   
   
   /**
  - * DELETE Method.
  - * 
  + * DELETE Method.  The delete method can be sent to either a collection or
  + * non-collection resource.  If a delete is sent to a collection, then all
  + * members of that collection are deleted.
  + *
  + * <p>   Deletes can fail because of permission problems or if a resource is
  + * currently locked.
  + *
  + * <p>   A typical request/response pair might look like this:
  + *
  + * <h3>Request</h3>
  + * <pre>
  + * DELETE /container/ HTTP/1.1
  + * Host: www.foo.bar
  + * </pre>
  + *
  + * <h3>Response</h3>
  + * <pre>
  + * HTTP/1.1 207 Multi-Status
  + * Content-Type: text/xml; charset="utf-8"
  + * Content-Length: xxxx
  + * &lt;?xml version="1.0" encoding="utf-8" ?&gt;
  + *   &lt;d:multistatus xmlns:d="DAV:"&gt;
  + *   &lt;d:response&gt;
  + *     &lt;d:href&gt;http://www.foo.bar/container/resource3&lt;/d:href&gt;
  + *     &lt;d:status&gt;HTTP/1.1 423 Locked&lt;/d:status&gt;
  + *   &lt;/d:response&gt;
  + * &lt;/d:multistatus&gt;
  + * </pre>
  + *
  + * <p>   In this example, the delete failed because one of the members was
  + * locked.
  + *
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  + * @author <a href="mailto:bcholmes@apache.org">B.C. Holmes</a>
    */
   public class DeleteMethod
  -    extends WebdavMethodBase {
  -    
  -    
  +    extends XMLResponseMethodBase {
  +
  +
       // ----------------------------------------------------------- Constructors
  -    
  -    
  +
  +
       /**
        * Method constructor.
        */
       public DeleteMethod() {
  -        
           name = "DELETE";
  -        
       }
  -    
  -    
  +
  +
       // --------------------------------------------------- WebdavMethod Methods
  -    
  -    
  -    /**
  -     * Generate the query body.
  -     * 
  -     * @return String query
  -     */
  -    public String generateQuery() {
  -        return null;
  -    }
  -    
  -    
  -    /**
  -     * Parse response.
  -     * 
  -     * @param is Input stream
  -     */
  -    public void parseResponse(InputStream is)
  -        throws IOException {
  -        
  -        // We have to parse the multistatus error report if status = 207
  -        
  -        
  -        
  -    }
  -    
  -    
  +
   }
  
  
  
  1.5       +67 -68    jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LockMethod.java
  
  Index: LockMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LockMethod.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LockMethod.java	2000/11/30 19:46:34	1.4
  +++ LockMethod.java	2000/12/04 06:32:41	1.5
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LockMethod.java,v 1.4 2000/11/30 19:46:34 remm Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/11/30 19:46:34 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LockMethod.java,v 1.5 2000/12/04 06:32:41 bcholmes Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/12/04 06:32:41 $
    *
    * ====================================================================
    *
    * 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,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   package org.apache.webdav.lib.methods;
   
  @@ -73,6 +73,7 @@
   import javax.xml.parsers.ParserConfigurationException;
   
   import org.apache.webdav.lib.State;
  +import org.apache.webdav.lib.WebdavException;
   import org.apache.webdav.lib.WebdavStatus;
   
   import org.apache.webdav.lib.util.DOMUtils;
  @@ -96,34 +97,34 @@
    * the resource at a time.  Locking helps to prevent the "lost update" problem.
    * There are two types of lock currently defined by the WebDAV specification:
    * exclusive locks and shared locks.
  - * 
  - * <p>   Per the specification, a lock indicates that someone is updating the 
  - * resource, (hence the lock is a "write lock"), although the specification 
  - * notes that the the syntax is extensible, and permits the eventual creation 
  + *
  + * <p>   Per the specification, a lock indicates that someone is updating the
  + * resource, (hence the lock is a "write lock"), although the specification
  + * notes that the the syntax is extensible, and permits the eventual creation
    * of locking for other access types.
    *
  - * <h3>Shared and Exclusive Locks<h3>
  + * <h3>Shared and Exclusive Locks</h3>
    *
  - * <p>   The most basic form of lock is an <em>exclusive lock</em>. This is a 
  - * lock where the access right in question is only granted to a single client. 
  - * The need for this arbitration results from a desire to avoid having to merge 
  + * <p>   The most basic form of lock is an <em>exclusive lock</em>. This is a
  + * lock where the access right in question is only granted to a single client.
  + * The need for this arbitration results from a desire to avoid having to merge
    * results.  However, there are times when the goal of a lock is not to exclude
  - * others from exercising an access right but rather to provide a mechanism for 
  - * principals to indicate that they intend to exercise their access rights. 
  - * <em>Shared locks</em> are provided for this case. A shared lock allows 
  - * multiple clients to receive a lock. Hence any user with appropriate 
  - * access can get the lock.  
  - *
  - * <p>   With shared locks there are two trust sets that affect a resource. 
  - * The first trust set is created by access permissions.  Principals who are 
  - * trusted, for example, may have permission to write to the resource.  Among 
  - * those who have access permission to write to the resource, the set of 
  - * principals who have taken out a shared lock also must trust each other, 
  - * creating a (typically) smaller trust set within the access permission write 
  + * others from exercising an access right but rather to provide a mechanism for
  + * principals to indicate that they intend to exercise their access rights.
  + * <em>Shared locks</em> are provided for this case. A shared lock allows
  + * multiple clients to receive a lock. Hence any user with appropriate
  + * access can get the lock.
  + *
  + * <p>   With shared locks there are two trust sets that affect a resource.
  + * The first trust set is created by access permissions.  Principals who are
  + * trusted, for example, may have permission to write to the resource.  Among
  + * those who have access permission to write to the resource, the set of
  + * principals who have taken out a shared lock also must trust each other,
  + * creating a (typically) smaller trust set within the access permission write
    * set.
  - * 
  + *
    * <h3>Lock Compatibility</h3>
  - * 
  + *
    * <p>   The following table indicates what happens if a new lock request
    * is sent to a resource that is already locked: </p>
    *
  @@ -143,8 +144,8 @@
    */
   public class LockMethod
       extends XMLResponseMethodBase implements DepthMethod {
  -    
   
  +
       // -------------------------------------------------------------- Constants
   
   
  @@ -159,24 +160,24 @@
       // ----------------------------------------------------- Instance Variables
   
   
  -    /** 
  -     * The scope of lock we're requesting.  The default scope is 
  -     * SCOPE_EXCLUSIVE. 
  +    /**
  +     * The scope of lock we're requesting.  The default scope is
  +     * SCOPE_EXCLUSIVE.
        */
       private short scope = SCOPE_EXCLUSIVE;
   
  -    
  -    /** 
  -     * The type of lock we're requesting.  The default type is TYPE_WRITE. 
  +
  +    /**
  +     * The type of lock we're requesting.  The default type is TYPE_WRITE.
        */
       private short type = TYPE_WRITE;
   
  -    
  +
       /**
        * Depth.
        */
       private int depth = -1;
  -    
  +
   
       /**
        * Opaque token of the lock we're trying to refresh.
  @@ -192,18 +193,18 @@
   
       private State state = null;
   
  -    
  +
       private String lockToken = null;
   
   
       // ----------------------------------------------------------- Constructors
  +
   
  -    
       /**
        * Method constructor.
        */
       public LockMethod() {
  -        
  +
           name = "LOCK";
   
       }
  @@ -214,7 +215,7 @@
   
       /**
        * Depth setter.
  -     * 
  +     *
        * @param depth New depth value
        */
       public void setDepth(int depth) {
  @@ -225,11 +226,11 @@
           }
           this.depth = depth;
       }
  -    
  -    
  +
  +
       /**
        * Depth getter.
  -     * 
  +     *
        * @return int depth value
        */
       public int getDepth() {
  @@ -244,7 +245,7 @@
   
   
       public boolean isRefresh() {
  -        return !((this.refreshOpaqueToken == null ) || 
  +        return !((this.refreshOpaqueToken == null ) ||
                    (this.refreshOpaqueToken.equals("")));
       }
   
  @@ -254,7 +255,7 @@
       }
   
   
  -    /** 
  +    /**
        * Sets the owner of the lock.  This method provides only "basic" owner
        * information.  Thus, <code>setOwner("Jezebel Lipshitz")</code> will
        * produce an <code>owner</code> element in the request document like this:
  @@ -264,7 +265,7 @@
        * </pre>
        *
        * <p>  Examples in the Webdav specification suggest that one can use
  -     * e-mail addresses, home page URLs, or other information; this 
  +     * e-mail addresses, home page URLs, or other information; this
        * implementation doesn't handle any of that.
        */
       public void setOwner(String owner) {
  @@ -295,8 +296,8 @@
           }
           this.timeout = timeout;
       }
  +
   
  -    
       // --------------------------------------------------- WebdavMethod Methods
   
   
  @@ -309,18 +310,18 @@
           this.timeout = TIMEOUT_INFINITY;
           this.state = null;
       }
  -    
   
  +
       /**
        * Generate additional headers needed by the request.
  -     * 
  +     *
        * @param host the host
        * @param state State token
        */
       public void generateHeaders(String host, State state) {
  -        
  +
           super.generateHeaders(host, state);
  -        
  +
           switch (depth) {
               case DEPTH_0:
                   setHeader("Depth", "0");
  @@ -345,11 +346,11 @@
   
           this.state = state;
       }
  -    
  -    
  +
  +
       /**
        * Generate the query body.
  -     * 
  +     *
        * @return String query
        */
       public String generateQuery() {
  @@ -361,9 +362,9 @@
                   throw new IllegalStateException
                       ("The owner property has not been set");
               }
  -        
  +
               try {
  -                DocumentBuilderFactory factory = 
  +                DocumentBuilderFactory factory =
                       DocumentBuilderFactory.newInstance();
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   Document document = builder.newDocument();
  @@ -376,7 +377,7 @@
                   lockinfo.appendChild(lockscope);
   
                   if (this.scope == SCOPE_EXCLUSIVE) {
  -                    Element exclusive = 
  +                    Element exclusive =
                           document.createElement("DAV:exclusive");
                       lockscope.appendChild(exclusive);
                   } else {
  @@ -412,17 +413,17 @@
   
       /**
        * Parse response.
  -     * 
  +     *
        * @param input Input stream
        */
       public void parseResponse(InputStream input)
  -        throws IOException {
  +        throws IOException, WebdavException {
           int status = getStatusCode();
  -        if (status == WebdavStatus.SC_OK || 
  -            status == WebdavStatus.SC_MULTI_STATUS || 
  +        if (status == WebdavStatus.SC_OK ||
  +            status == WebdavStatus.SC_MULTI_STATUS ||
               status == WebdavStatus.SC_CONFLICT) {
   
  -            super.parseResponse(input);
  +            parseXMLResponse(input);
   
               if (status == WebdavStatus.SC_OK) {
                   String prefix = DOMUtils.findDavPrefix(
  @@ -442,6 +443,4 @@
               }
           }
       }
  -
  -
   }
  
  
  
  1.3       +59 -59    jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MoveMethod.java
  
  Index: MoveMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MoveMethod.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MoveMethod.java	2000/11/30 02:23:04	1.2
  +++ MoveMethod.java	2000/12/04 06:32:41	1.3
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MoveMethod.java,v 1.2 2000/11/30 02:23:04 remm Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/11/30 02:23:04 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MoveMethod.java,v 1.3 2000/12/04 06:32:41 bcholmes Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/12/04 06:32:41 $
    *
    * ====================================================================
    *
    * 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,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   package org.apache.webdav.lib.methods;
   
  @@ -72,136 +72,136 @@
   
   /**
    * MOVE Method.
  - * 
  + *
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
    */
   public class MoveMethod
       extends WebdavMethodBase {
  -    
  -    
  +
  +
       // ----------------------------------------------------------- Constructors
  -    
  -    
  +
  +
       /**
        * Method constructor.
        */
       public MoveMethod() {
  -        
  +
           name = "MOVE";
  -        
  +
       }
  -    
  -    
  +
  +
       // ----------------------------------------------------- Instance Variables
  -    
  -    
  +
  +
       /**
        * Destination.
        */
       private String destination;
  -    
  -    
  +
  +
       /**
        * Overwrite.
        */
       private boolean overwrite = true;
  -    
  -    
  +
  +
       // ------------------------------------------------------------- Properties
  -    
  -    
  +
  +
       /**
        * Destination setter.
  -     * 
  +     *
        * @param destination New destination value
        */
       public void setDestination(String destination) {
           checkNotUsed();
           this.destination = destination;
       }
  -    
  -    
  +
  +
       /**
        * Destination getter.
  -     * 
  +     *
        * @return String destination value
        */
       public String getDestination() {
           return destination;
       }
  -    
  -    
  +
  +
       /**
        * Overwrite setter.
  -     * 
  +     *
        * @param overwrite New overwrite value
        */
       public void setOverwrite(boolean overwrite) {
           checkNotUsed();
           this.overwrite = overwrite;
       }
  -    
  -    
  +
  +
       /**
        * Overwrite getter.
  -     * 
  +     *
        * @return boolean Overwrite value
        */
       public boolean isOverwrite() {
           return overwrite;
       }
  -    
  -    
  +
  +
       /**
        * Overwrite getter.
  -     * 
  +     *
        * @return boolean Overwrite value
        */
       public boolean getOverwrite() {
           return overwrite;
       }
  -    
  -    
  +
  +
       // --------------------------------------------------- WebdavMethod Methods
  -    
  -    
  +
       /**
        * Generate additional headers needed by the request.
  -     * 
  +     *
  +     * @param host the host
        * @param state State token
        */
  -    public void generateHeaders(State state) {
  -        
  -        super.generateHeaders(state);
  -        
  +    public void generateHeaders(String host, State state) {
  +
  +        super.generateHeaders(host, state);
  +
           setHeader("Destination", destination);
           if (!isOverwrite())
               setHeader("Overwrite", "F");
  -        
  +
       }
  -    
  -    
  +
  +
       /**
        * Generate the query body.
  -     * 
  +     *
        * @return String query
        */
       public String generateQuery() {
           return null;
       }
  -    
  -    
  +
  +
       /**
        * Parse response.
  -     * 
  +     *
        * @param is Input stream
        */
       public void parseResponse(InputStream is)
           throws IOException {
  -        
  +
           // Parse the 207 error report
  -        
  +
       }
  -    
  -    
  +
  +
   }
  
  
  
  1.7       +140 -112  jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java
  
  Index: PropFindMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PropFindMethod.java	2000/11/30 19:46:35	1.6
  +++ PropFindMethod.java	2000/12/04 06:32:41	1.7
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java,v 1.6 2000/11/30 19:46:35 remm Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/11/30 19:46:35 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java,v 1.7 2000/12/04 06:32:41 bcholmes Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/12/04 06:32:41 $
    *
    * ====================================================================
    *
    * 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,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   package org.apache.webdav.lib.methods;
   
  @@ -71,11 +71,14 @@
   import java.util.Hashtable;
   import java.util.Vector;
   
  -import org.apache.webdav.lib.State;
   import org.apache.webdav.lib.Header;
   import org.apache.webdav.lib.Property;
  +import org.apache.webdav.lib.State;
  +import org.apache.webdav.lib.WebdavException;
   import org.apache.webdav.lib.WebdavStatus;
   
  +import org.apache.webdav.lib.properties.ResourceType;
  +
   import org.apache.webdav.lib.util.DOMUtils;
   import org.apache.webdav.lib.util.DOMWriter;
   import org.apache.webdav.lib.util.WebdavXMLPrinter;
  @@ -91,22 +94,22 @@
   
   /**
    * This class implements the WebDAV PROPFIND Method.
  - * 
  - * <P>     The PROPFIND method retrieves properties defined on the resource 
  - * identified by the Request-URI, if the resource does not have any internal 
  - * members, or on the resource identified by the Request-URI and potentially 
  - * its member resources, if the resource is a collection that has internal 
  - * member URIs. 
  - * 
  + *
  + * <P>     The PROPFIND method retrieves properties defined on the resource
  + * identified by the Request-URI, if the resource does not have any internal
  + * members, or on the resource identified by the Request-URI and potentially
  + * its member resources, if the resource is a collection that has internal
  + * member URIs.
  + *
    * <P>     A typical request looks like this:
  - * 
  + *
    * <PRE>
  - * 
  + *
    * PROPFIND /file HTTP/1.1
    * Host: www.foo.bar
    * Content-type: text/xml; charset="utf-8"
    * Content-Length: xxxx
  - * 
  + *
    * &lt;?xml version="1.0" encoding="utf-8" ?&gt;
    *   &lt;D:propfind xmlns:D="DAV:"&gt;
    *   &lt;D:prop xmlns:R="http://www.foo.bar/boxschema/"&gt;
  @@ -119,117 +122,117 @@
    * </PRE>
    *
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  - * @author B.C. Holmes
  + * @author <a href="mailto:bcholmes@interlog.com">B.C. Holmes</a>
    */
  -public class PropFindMethod extends XMLResponseMethodBase 
  +public class PropFindMethod extends XMLResponseMethodBase
       implements DepthMethod {
  -    
  -    
  +
  +
       // -------------------------------------------------------------- Constants
  -    
  -    
  +
  +
       /**
        * Request of named properties.
        */
       public static final int BY_NAME = 0;
  -    
  -    
  +
  +
       /**
        * Request of all properties name and value.
        */
       public static final int ALL = 1;
  -    
  -    
  +
  +
       /**
        * Request of all properties name.
        */
       public static final int NAMES = 2;
  -    
  -    
  +
  +
       // ----------------------------------------------------------- Constructors
  -    
  -    
  +
  +
       /**
        * Method constructor.
        */
       public PropFindMethod() {
  -        
  +
           name = "PROPFIND";
  -        
  +
       }
  -    
  -    
  +
  +
       // ----------------------------------------------------- Instance Variables
  -    
  -    
  +
  +
       /**
        * Type of the Propfind.
        */
       private int type = ALL;
  -    
  -    
  +
  +
       /**
        * Property name list.
        */
       private Enumeration propertyNames;
  -    
  -    
  +
  +
       /**
        * Depth.
        */
       private int depth = DEPTH_INFINITY;
  -    
  -    
  +
  +
       /**
        * Hashtable of response nodes
        */
       private Hashtable responseHashtable = null;
  -    
  -    
  +
  +
       /**
        * The namespace abbreviation that prefixes DAV tags
        */
       private String prefix = null;
  -    
  -    
  +
  +
       // ------------------------------------------------------------- Properties
  -    
  -    
  +
  +
       /**
        * Type setter.
  -     * 
  +     *
        * @param type New type value
        */
       public void setType(int type) {
           checkNotUsed();
           this.type = type;
       }
  -    
  -    
  +
  +
       /**
        * Type getter.
  -     * 
  +     *
        * @return int type value
        */
       public int getType() {
           return type;
       }
  -    
  -    
  +
  +
       /**
        * Depth setter.
  -     * 
  +     *
        * @param depth New depth value
        */
       public void setDepth(int depth) {
           checkNotUsed();
           this.depth = depth;
       }
  -    
  -    
  +
  +
       /**
        * Depth getter.
  -     * 
  +     *
        * @return int depth value
        */
       public int getDepth() {
  @@ -239,7 +242,7 @@
   
       /**
        * Property names setter.
  -     * 
  +     *
        * @param propertyNames List of the property names
        */
       public void setPropertyNames(Enumeration propertyNames) {
  @@ -249,26 +252,26 @@
   
   
       // --------------------------------------------------- WebdavMethod Methods
  -    
  +
   
       public void recycle() {
           super.recycle();
           prefix = null;
           responseHashtable = null;
       }
  -    
  +
       /**
        * Generate additional headers needed by the request.
  -     * 
  +     *
        * @param host the host
        * @param state State token
        */
       public void generateHeaders(String host, State state) {
  -        
  +
           super.generateHeaders(host, state);
  -        
  +
           setHeader("Content-Type", "text/xml; charset=\"utf-8\"");
  -        
  +
           switch (depth) {
           case DEPTH_0:
               setHeader("Depth", "0");
  @@ -280,53 +283,61 @@
               setHeader("Depth", "infinity");
               break;
           }
  -        
  +
       }
  -    
  -    
  +
  +
       /**
        * Generate the query body.
  -     * 
  +     *
        * @return String query
        */
       public String generateQuery() {
  -        
  +
           WebdavXMLPrinter printer = new WebdavXMLPrinter();
           printer.writeXMLHeader();
           printer.writeElement("D", "DAV", "propfind", WebdavXMLPrinter.OPENING);
  -        
  +
           switch (type) {
           case ALL:
               printer.writeElement("D", "allprop", WebdavXMLPrinter.NO_CONTENT);
               break;
           case NAMES:
  -            printer.writeElement("D", "propname", 
  +            printer.writeElement("D", "propname",
                                    WebdavXMLPrinter.NO_CONTENT);
               break;
           case BY_NAME:
               printer.writeElement("D", "prop", WebdavXMLPrinter.OPENING);
               while (propertyNames.hasMoreElements()) {
                   String propertyName = (String) propertyNames.nextElement();
  -                printer.writeElement(null, propertyName, 
  +                printer.writeElement(null, propertyName,
                                        WebdavXMLPrinter.NO_CONTENT);
               }
               printer.writeElement("D", "prop", WebdavXMLPrinter.CLOSING);
               break;
           }
  -        
  +
           printer.writeElement("D", "DAV", "propfind", WebdavXMLPrinter.CLOSING);
           if (debug > 1) {
               System.out.println("Request body:");
               System.out.println(printer.toString());
           }
           return printer.toString();
  -        
  +
       }
   
   
  +    /**
  +     * This method returns an enumeration of URL paths.  If the PropFindMethod
  +     * was sent to the URL of a collection, then there will be multiple URLs.
  +     * The URLs are picked out of the <code>&lt;D:href&gt;</code> elements
  +     * of the response.
  +     *
  +     * @return an enumeration of URL paths as Strings
  +     */
       public Enumeration getAllResponseURLs() {
           checkUsed();
  -        
  +
           if (getStatusCode() == WebdavStatus.SC_MULTI_STATUS) {
               return getResponseHashtable().keys();
           } else {
  @@ -364,33 +375,34 @@
           }
       }
   
  -
  +    /**
  +     * Returns an enumeration of <code>Property</code> objects.
  +     */
       public Enumeration getResponseProperties(String urlPath) {
  -        
  +
           checkUsed();
  -        
  +
           Vector vector = new Vector();
   
           if (getStatusCode() == WebdavStatus.SC_MULTI_STATUS) {
               try {
  -                Element response = 
  +                Element response =
                       (Element) getResponseHashtable().get(urlPath);
                   if (response != null) {
                       NodeList list = response.getElementsByTagName
                           (getPrefix() + "prop");
                       for (int i = 0; i < list.getLength(); i++) {
  -                        try {
  -                            Element prop = (Element) list.item(i);
  -                            NodeList subList = prop.getChildNodes();
  -                            for (int j = 0; j < subList.getLength(); j++) {
  -                                try {
  -                                    vector.add(new PropertyImpl
  -                                        (getPrefix(), 
  -                                         (Element) subList.item(j)));
  -                                } catch (ClassCastException e) {
  -                                }
  +
  +                        Element prop = (Element) list.item(i);
  +                        NodeList subList = prop.getChildNodes();
  +                        for (int j = 0; j < subList.getLength(); j++) {
  +                            try {
  +                                Element element = (Element) subList.item(j);
  +                                vector.addElement(convertElementToProperty(
  +                                    element));
  +                            } catch (ClassCastException e) {
  +                                // skip anything that's not an element
                               }
  -                        } catch (ClassCastException e) {
                           }
                       }
                   }
  @@ -410,30 +422,34 @@
   
   
       /**
  -     * Parse response.
  -     * 
  -     * @param input Input stream
  -     */
  -    public void parseResponse(InputStream input)
  -        throws IOException {
  -        if (getStatusCode() == WebdavStatus.SC_MULTI_STATUS) {
  -            super.parseResponse(input);
  +     * This method creates a property implementation from an element.
  +     * It treats known properties (i.e., the DAV properties) specially.
  +     * These properties are instantiated as an implementation from the
  +     * <code>org.apache.webdav.lib.properties</code> package.
  +     */
  +    protected Property convertElementToProperty(Element element) {
  +        Property property = null;
  +        String tagName = element.getTagName();
  +        if (tagName.equals(getPrefix() + "resourcetype")) {
  +            property = new ResourceTypePropertyImpl(getPrefix(), element);
  +        } else {
  +            property = new PropertyImpl(getPrefix(), element);
           }
  +        return property;
       }
   
  +    // -------------------------------------------------- Property Inner Classes
   
  -    // --------------------------------------------------- Property Inner Class
  -    
  -    
  +
       class PropertyImpl implements Property {
  -        
  +
           PropertyImpl(String prefix, Element element) {
               this.element = element;
               this.prefix = prefix;
           }
   
  -        private String prefix;
  -        private Element element;
  +        protected String prefix;
  +        protected Element element;
   
           public String getName() {
               return element.getTagName();
  @@ -450,17 +466,17 @@
           public int getStatusCode() {
               int status = -1;
               try {
  -                Element propstat = 
  +                Element propstat =
                       (Element) element.getParentNode().getParentNode();
   
  -                NodeList statusList = 
  +                NodeList statusList =
                       propstat.getElementsByTagName(prefix + "status");
                   if (statusList != null && statusList.getLength() != 1) {
                       // ????
                   } else {
                       try {
                           Element child = (Element) statusList.item(0);
  -                        status = 
  +                        status =
                               DOMUtils.parseStatus(DOMUtils.getTextValue(child));
                       } catch (ClassCastException e) {
                       }
  @@ -482,5 +498,17 @@
           }
       }
   
  +    class ResourceTypePropertyImpl extends PropertyImpl
  +        implements ResourceType {
   
  +        ResourceTypePropertyImpl(String prefix, Element element) {
  +            super(prefix, element);
  +        }
  +
  +        public boolean isCollection() {
  +            NodeList tmp = element.getElementsByTagName(
  +                this.prefix + "collection");
  +            return (tmp.getLength() > 0);
  +        }
  +    }
   }
  
  
  
  1.3       +90 -89    jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethod.java
  
  Index: WebdavMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethod.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebdavMethod.java	2000/11/27 22:56:00	1.2
  +++ WebdavMethod.java	2000/12/04 06:32:42	1.3
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethod.java,v 1.2 2000/11/27 22:56:00 remm Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/11/27 22:56:00 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethod.java,v 1.3 2000/12/04 06:32:42 bcholmes Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/12/04 06:32:42 $
    *
    * ====================================================================
    *
    * 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,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   package org.apache.webdav.lib.methods;
   
  @@ -67,218 +67,219 @@
   import java.util.*;
   import org.apache.webdav.lib.State;
   import org.apache.webdav.lib.Header;
  +import org.apache.webdav.lib.WebdavException;
   
   /**
    * WebDAV method.
  - * 
  + *
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
    */
   public interface WebdavMethod {
  -    
  -    
  +
  +
       // -------------------------------------------------------------- Constants
  -    
  -    
  +
  +
       /**
        * Protocol version.
        */
       public static final String PROTOCOL = "HTTP/1.1";
  -    
  -    
  +
  +
       // ------------------------------------------------------------- Properties
  -    
  -    
  +
  +
       /**
        * Debug property setter.
  -     * 
  +     *
        * @param int Debug
        */
       public void setDebug(int debug);
  -    
  -    
  +
  +
       /**
        * Set the method as used.
        */
       public void setUsed();
  -    
  -    
  +
  +
       /**
        * Status code property setter.
  -     * 
  +     *
        * @param int Status code
        */
       public void setStatusCode(int statusCode);
  -    
  -    
  +
  +
       /**
        * Status code property getter.
  -     * 
  +     *
        * @return int Status code
        */
       public int getStatusCode();
  -    
  -    
  +
  +
       /**
        * Status text property setter.
  -     * 
  +     *
        * @param statusText Status text
        */
       public void setStatusText(String statusText);
  -    
  -    
  +
  +
       /**
        * Status text property getter.
  -     * 
  +     *
        * @return String status text
        */
       public String getStatusText();
  -    
  -    
  +
  +
       /**
        * Path property setter.
  -     * 
  +     *
        * @param path Absolute path
        */
       public void setPath(String path);
  -    
  -    
  +
  +
       /**
        * Path property getter.
  -     * 
  +     *
        * @return String path
        */
       public String getPath();
  -    
  -    
  +
  +
       /**
        * Set header.
  -     * 
  +     *
        * @param headerName Header name
        * @param headerValue Header value
        */
       public void setHeader(String headerName, String headerValue);
  -    
  -    
  +
  +
       /**
        * Get header.
  -     * 
  +     *
        * @param headerName Header name
        * @return String header value (null if the header doesn't exist)
        */
       public Header getHeader(String headerName);
  -    
  -    
  +
  +
       /**
        * Remove header.
  -     * 
  +     *
        * @param headerName Header name
        */
       public void removeHeader(String headerName);
  -    
  -    
  +
  +
       /**
        * Checks if this method's instance has already been used, and has not been
        * recycled.
  -     * 
  +     *
        * @return boolean True if the method's instance has already been used
        */
       public boolean hasBeenUsed();
  -    
  -    
  +
  +
       /**
        * True if this methods should automatically follow redirects.
  -     * 
  +     *
        * @return boolean True if auto redirect should be used for this method
        */
       public boolean followRedirects();
  -    
  -    
  +
  +
       // ------------------------------------------------------ Interface Methods
  -    
  -    
  +
  +
       /**
        * Ensures the correctness of the request according to criterions which are
        * method dependent.
  -     * 
  +     *
        * @return boolean True if the method is valid
        */
       public boolean validate();
  -    
  -    
  +
  +
       /**
        * Recycle the method object, so that it can be reused again. Any attempt
        * to reuse an object without recycling it will throw a WebdavException.
        */
       public void recycle();
  -    
  -    
  +
  +
       /**
        * Get headers.
  -     * 
  +     *
        * @return Enumeration
        */
       public Enumeration getHeaders();
  -    
  -    
  +
  +
       /**
        * Generate additional headers needed by the request.
  -     * 
  +     *
        * @param state State token
        */
       public void generateHeaders(String host, State state);
  -    
  -    
  +
  +
       /**
        * Is the query body submitted through an InputStream of with a String.
        * If an InputStream is available, it's used.
  -     * 
  +     *
        * @return boolean True if the content is avalable in an InputStream
        */
       public boolean isStreamedQuery();
  -    
  -    
  +
  +
       /**
        * Generate the query.
  -     * 
  +     *
        * @return String query
        */
       public String generateQuery();
  -    
  -    
  +
  +
       /**
        * Stream the body of the query. This function should be used to send large
        * request bodies.
        */
       public void streamQuery(OutputStream out)
           throws IOException ;
  -    
  -    
  +
  +
       /**
        * Process response headers. The contract of this method is that it only
        * parses the response headers.
  -     * 
  +     *
        * @param headers Headers list
        */
       public void processResponseHeaders(Hashtable headers);
  -    
  -    
  +
  +
       /**
        * Parse response.
  -     * 
  +     *
        * @param is Input stream
        */
       public void parseResponse(InputStream is)
  -        throws IOException;
  -    
  -    
  +        throws IOException, WebdavException;
  +
  +
       /**
        * Generate the HTTP request line.
  -     * 
  +     *
        * @return String request line
        */
       public String generateRequestLine();
  -    
  -    
  -    
  -    
  +
  +
  +
  +
   }
  
  
  
  1.4       +134 -133  jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java
  
  Index: WebdavMethodBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WebdavMethodBase.java	2000/11/30 02:23:05	1.3
  +++ WebdavMethodBase.java	2000/12/04 06:32:42	1.4
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java,v 1.3 2000/11/30 02:23:05 remm Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/11/30 02:23:05 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/WebdavMethodBase.java,v 1.4 2000/12/04 06:32:42 bcholmes Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/12/04 06:32:42 $
    *
    * ====================================================================
    *
    * 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,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   package org.apache.webdav.lib.methods;
   
  @@ -69,230 +69,231 @@
   import org.apache.webdav.lib.Cookie;
   import org.apache.webdav.lib.Header;
   import org.apache.webdav.lib.WebdavClient;
  +import org.apache.webdav.lib.WebdavException;
   import org.apache.webdav.lib.WebdavStatus;
   
   
   /**
    * WebDAV method abstract implementation.
  - * 
  + *
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
    */
   public abstract class WebdavMethodBase
       implements WebdavMethod {
  -    
  -    
  +
  +
       // ----------------------------------------------------- Instance Variables
  -    
  -    
  +
  +
       /**
        * True if this method has already been executed.
        */
       private boolean used = false;
  -    
  -    
  +
  +
       /**
        * Debug.
        */
       protected int debug = 0;
  -    
  -    
  +
  +
       /**
        * Status code.
        */
       protected int statusCode = WebdavStatus.SC_OK;
  -    
  -    
  +
  +
       /**
        * Status text.
        */
       protected String statusText = "OK";
  -    
  -    
  +
  +
       /**
        * Server path.
        */
       protected String path = "/";
  -    
  -    
  +
  +
       /**
        * Method name.
        */
       protected String name;
  -    
  -    
  +
  +
       /**
        * Headers.
        */
       protected Hashtable headers = new Hashtable();
  -    
  -    
  +
  +
       /**
        * Global state.
        */
       protected State state;
  -    
  -    
  +
  +
       // ----------------------------------------------------------- Constructors
  -    
  -    
  +
  +
       /**
        * Method constructor.
        */
       public WebdavMethodBase() {
  -        
  +
       }
  -    
  -    
  +
  +
       // ------------------------------------------------------------- Properties
  -    
  -    
  +
  +
       /**
        * Debug property setter.
  -     * 
  +     *
        * @param int Debug
        */
       public void setDebug(int debug) {
           this.debug = debug;
       }
  -    
  -    
  +
  +
       /**
        * Status code property setter.
  -     * 
  +     *
        * @param int Status code
        */
       public void setStatusCode(int statusCode) {
           this.statusCode = statusCode;
       }
  -    
  -    
  +
  +
       /**
        * Status code property getter.
  -     * 
  +     *
        * @return int Status code
        */
       public int getStatusCode() {
           return statusCode;
       }
  -    
  -    
  +
  +
       /**
        * Status text property setter.
  -     * 
  +     *
        * @param statusText Status text
        */
       public void setStatusText(String statusText) {
           this.statusText = statusText;
       }
  -    
  -    
  +
  +
       /**
        * Status text property getter.
  -     * 
  +     *
        * @return String status text
        */
       public String getStatusText() {
           return statusText;
       }
  -    
  -    
  +
  +
       /**
        * Path property setter.
  -     * 
  +     *
        * @param path Absolute path
        */
       public void setPath(String path) {
           this.path = path;
       }
  -    
  -    
  +
  +
       /**
        * Path property getter.
  -     * 
  +     *
        * @return String path
        */
       public String getPath() {
           return path;
       }
  -    
  -    
  +
  +
       /**
        * Set header.
  -     * 
  +     *
        * @param headerName Header name
        * @param headerValue Header value
        */
       public void setHeader(String headerName, String headerValue) {
  -        headers.put(headerName.toLowerCase(), 
  +        headers.put(headerName.toLowerCase(),
                       new Header(headerName, headerValue));
       }
  -    
  -    
  +
  +
       /**
        * Get header.
  -     * 
  +     *
        * @param headerName Header name
        * @return String header value (null if the header doesn't exist)
        */
       public Header getHeader(String headerName) {
           return (Header) headers.get(headerName.toLowerCase());
       }
  -    
  -    
  +
  +
       /**
        * Remove header.
  -     * 
  +     *
        * @param headerName Header name
        */
       public void removeHeader(String headerName) {
           headers.remove(headerName.toLowerCase());
       }
  -    
  -    
  +
  +
       /**
        * Checks if this method's instance has already been used, and has not been
        * recycled.
  -     * 
  +     *
        * @return boolean True if the method's instance has already been used
        */
       public final boolean hasBeenUsed() {
           return (used);
       }
  -    
  -    
  +
  +
       /**
        * True if this methods should automatically follow redirects.
  -     * 
  +     *
        * @return boolean True if auto redirect should be used for this method
        */
       public boolean followRedirects() {
           return (false);
       }
  -    
  -    
  +
  +
       // --------------------------------------------------- WebdavMethod Methods
  -    
  -    
  +
  +
       /**
        * Set the method as used.
        */
       public void setUsed() {
           used = true;
       }
  -    
  -    
  +
  +
       /**
        * Ensures the correctness of the request according to criterions which are
        * method dependent.
  -     * 
  +     *
        * @return boolean True if the method is valid
        */
       public boolean validate() {
           // By default, the request is valid.
           return (true);
       }
  -    
  -    
  +
  +
       /**
        * Recycle the method object, so that it can be reused again. Any attempt
        * to reuse an object without recycling it will throw a WebdavException.
  @@ -305,142 +306,142 @@
           state = null;
           used = false;
       }
  -    
  -    
  +
  +
       /**
        * Get headers.
  -     * 
  +     *
        * @return Enumeration
        */
       public Enumeration getHeaders() {
           return headers.elements();
       }
  -    
  -    
  +
  +
       /**
        * Generate additional headers needed by the request.
  -     * 
  +     *
        * @param state State token
  -     * @deprecated this method is deprecated in favour of the 
  +     * @deprecated this method is deprecated in favour of the
        * <CODE>generateHeaders(String, State)</CODE> method.
        */
       public void generateHeaders(State state) {
       }
  -    
  -    
  +
  +
       /**
        * Generate additional headers needed by the request.
  -     * 
  +     *
        * @param host the host
        * @param state State token
        */
       public void generateHeaders(String host, State state) {
  -        
  +
           // Default implementation adds the lock token headers if necessary
           this.state = state;
  -         
  +
           generateHeaders(state);
  -        
  +
           // good practice to provide a user-agent indicator
           if (!headers.containsKey("user-agent")) {
               headers.put("user-agent", WebdavClient.USER_AGENT);
           }
  -        
  +
           if (!headers.containsKey("host")) {
               headers.put("host", new Header("host", host));
           }
  -        
  +
           // add the cookies
           if (!headers.containsKey("cookie")) {
               Vector cookies = state.getCookies();
  -            headers.put("cookie", 
  +            headers.put("cookie",
                 Cookie.createCookieHeader(host, getPath(), cookies));
           }
       }
  -    
  -    
  +
  +
       /**
        * Is the query body submitted through an InputStream of with a String.
        * If an InputStream is available, it's used.
  -     * 
  +     *
        * @return boolean True if the content is avalable in an InputStream
        */
       public boolean isStreamedQuery() {
           // By default, the query is NOT streamed.
           return false;
       }
  -    
  -    
  +
  +
       /**
        * Generate the query body.
  -     * 
  +     *
        * @return String query
        */
       public String generateQuery() {
           return "";
       }
  -    
  -    
  +
  +
       /**
        * Stream the body of the query. This function should be used to send large
        * request bodies.
        */
       public void streamQuery(OutputStream out)
           throws IOException {
  -        
  +
       }
  -    
  -    
  +
  +
       /**
        * Process response headers. The contract of this method is that it only
        * parses the response headers.
  -     * 
  +     *
        * @param headers Headers list
        */
       public void processResponseHeaders(Hashtable headers) {
  -        
  +
           // We replace the request headers with the response headers
           this.headers = headers;
  -        
  +
           if (debug > 0) {
               Enumeration list = headers.elements();
               while (list.hasMoreElements()) {
                   Header current = (Header) list.nextElement();
  -                System.out.println(current.getName() + ": " + 
  +                System.out.println(current.getName() + ": " +
                                      current.getValue());
               }
  -            
  +
           }
  -        
  +
       }
  -    
  -    
  +
  +
       /**
        * Parse response.
  -     * 
  +     *
        * @param is Input stream
        */
       public abstract void parseResponse(InputStream is)
  -        throws IOException;
  -    
  -    
  +        throws IOException, WebdavException;
  +
  +
       /**
        * Generate the HTTP request line.
  -     * 
  +     *
        * @return String request line
        */
       public final String generateRequestLine() {
  -        
  +
           return (name + " " + path + " " + PROTOCOL + "\r\n");
  -        
  +
       }
  -    
  -    
  +
  +
       // ------------------------------------------------------ Protected Methods
  -    
  -    
  +
  +
       /**
  -     * Check if the method has been executed, and throws an 
  +     * Check if the method has been executed, and throws an
        * IllegalStateException otherwise.
        */
       protected void checkUsed() {
  @@ -448,10 +449,10 @@
               throw new IllegalStateException
                   ("Method must be executed before this function is called");
       }
  -    
  -    
  +
  +
       /**
  -     * Check if the method has been executed, and throws an 
  +     * Check if the method has been executed, and throws an
        * IllegalStateException otherwise.
        */
       protected void checkNotUsed() {
  @@ -460,6 +461,6 @@
                   ("This function must be called before this method "
                    + "is executed");
       }
  -    
  -    
  +
  +
   }
  
  
  
  1.3       +32 -25    jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/XMLResponseMethodBase.java
  
  Index: XMLResponseMethodBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/XMLResponseMethodBase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLResponseMethodBase.java	2000/11/29 06:13:57	1.2
  +++ XMLResponseMethodBase.java	2000/12/04 06:32:42	1.3
  @@ -4,7 +4,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
  @@ -12,7 +12,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
  @@ -20,15 +20,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"
  @@ -56,7 +56,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   package org.apache.webdav.lib.methods;
   
  @@ -69,6 +69,7 @@
   import javax.xml.parsers.FactoryConfigurationError;
   import javax.xml.parsers.ParserConfigurationException;
   
  +import org.apache.webdav.lib.WebdavException;
   import org.apache.webdav.lib.WebdavStatus;
   
   import org.w3c.dom.Document;
  @@ -78,7 +79,7 @@
   
   /**
    * Utility class for XML response parsing.
  - * 
  + *
    * @author B.C. Holmes
    * @author Remy Maucherat
    */
  @@ -93,14 +94,14 @@
        * Response document.
        */
       private Document responseDocument = null;
  -    
  -    
  +
  +
       /**
        * Document builder.
        */
       protected static DocumentBuilder builder = null;
  -    
  -    
  +
  +
       // ------------------------------------------------------------- Properties
   
       /**
  @@ -113,38 +114,44 @@
       }
   
       // --------------------------------------------------- WebdavMethod Methods
  -    
  +
       /**
  -     * Parse response.  This method always assumes that the response is a
  -     * valid XML response; subclasses should probably issue a status code
  -     * check before calling <code>super.parseResponse(input)</code>.
  -     * 
  +     * Parse response.
  +     *
        * @param input Input stream
        */
       public void parseResponse(InputStream input)
  -        throws IOException {
  -        
  +        throws IOException, WebdavException {
  +        if (getStatusCode() == WebdavStatus.SC_MULTI_STATUS) {
  +            parseXMLResponse(input);
  +        }
  +    }
  +
  +
  +    protected void parseXMLResponse(InputStream input)
  +        throws IOException, WebdavException {
  +
           if (builder == null) {
               try {
  -                DocumentBuilderFactory factory = 
  +                DocumentBuilderFactory factory =
                       DocumentBuilderFactory.newInstance();
                   builder = factory.newDocumentBuilder();
               } catch (ParserConfigurationException e) {
  -                throw new IllegalArgumentException
  +                throw new WebdavException
                       ("XML Parser Configuration error: " + e.getMessage());
               }
           }
  -        
  +
           try {
  -            
  +
               responseDocument = builder.parse(new InputSource(input));
  -            
  +
           } catch (Exception e) {
               throw new IOException
  -                ("XML parsing error; response stream is not valid XML: " 
  +                ("XML parsing error; response stream is not valid XML: "
                    + e.getMessage());
           }
  -        
  +
       }
   }
   
  
  
  
  1.1                  jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/properties/ResourceType.java
  
  Index: ResourceType.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/properties/ResourceType.java,v 1.1 2000/12/04 06:32:47 bcholmes Exp $
   * $Revision: 1.1 $
   * $Date: 2000/12/04 06:32:47 $
   *
   * ====================================================================
   *
   * 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 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
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.webdav.lib.properties;
  
  import org.apache.webdav.lib.Property;
  
  import org.w3c.dom.Element;
  
  /**
   * An interface that describes a standard Resource Type property (as defined by
   * the WebDAV specification).
   *
   * @author <a href="mailto:bcholmes@interlog.com">B.C. Holmes</a>
   */
  public interface ResourceType extends Property {
  
      /**
       * Returns true if the resource is a collection.  A collection is indicated
       * by a response like this:
       *
       * <pre>
       * &lt;D:resourcetype&gt;&lt;D:collection/&gt;&lt;/D:resourcetype&gt;
       * </pre>
       */
      public boolean isCollection();
  }
  
  

Re: Is there DepthMethod?

Posted by "Park, Sung-Gu" <je...@thinkfree.com>.
I thought the DepthMethod should be just "Depth".
But for Depth, it's better to represent one of abstract methods.
then, DepthMethodBase!   ^^;

----- Original Message ----- 
From: "Remy Maucherat" <re...@apache.org>
To: <sl...@jakarta.apache.org>
Sent: Wednesday, December 06, 2000 2:35 AM
Subject: Re: Is there DepthMethod?


> > Hello.
> >
> > There is org/apache/webdav/lib/methods/DepthMethod.
> > But, there is no Depth WebDAV method.
> > I recommend you change the class name.  ^^
> 
> I thought it was confusing too, so I agree we should change it (the abstract
> method classes have "Base" appended to their name). Any suggestions ?
> 
> > In the LockMethod,
> > It's easier to understand to use "DEPTH_INFINITY" rather than "-1".
> > for default depth field and for recycle().
> 
> Makes sense too.
> 
> Remy
> 

Re: Is there DepthMethod?

Posted by Remy Maucherat <re...@apache.org>.
> Hello.
>
> There is org/apache/webdav/lib/methods/DepthMethod.
> But, there is no Depth WebDAV method.
> I recommend you change the class name.  ^^

I thought it was confusing too, so I agree we should change it (the abstract
method classes have "Base" appended to their name). Any suggestions ?

> In the LockMethod,
> It's easier to understand to use "DEPTH_INFINITY" rather than "-1".
> for default depth field and for recycle().

Makes sense too.

Remy


Authenticator.java

Posted by "Park, Sung-Gu" <je...@thinkfree.com>.
It's my digest scheme patch for  Authorization.


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

public class Authenticator {


    protected static Base64 base64 = new Base64();


    public static String challengeResponse(String challenge,
                                           Credentials credentials)
        throws WebdavException {

        if (challenge.startsWith("Basic")) {
            return basic(credentials);
        } else if (challenge.startsWith("Digest")) {
            throw new WebdavException("Unable to authenticate for Digest");
        }
        return null;

    }

    public static String challengeResponse(String challenge,
                                           Credentials credentials,
                                           String path)
        throws WebdavException {

        if (challenge.startsWith("Basic")) {
            return basic(credentials);
        } else if (challenge.startsWith("Digest")) {
            int indx = challenge.indexOf("realm");
// FIX ME: in the secure communication, it's possbile to have a problem.
            String realm = challenge.substring(indx);
            return digest(credentials, realm, path);
        }
        return null;
    }


    public static String digest(Credentials credentials, String realm,
                                String path) {

        String authString =
            "Digest username=\"" + credentials.getUserName() + "\", " +
            "realm=\"" + realm + "\", nonce=\"...\", " +
            "uri=\"" + path + "\", " +
            "response=\"...\", opaque=\"...\"";

        return authString;
    }

<snip>



Re: Header and HeaderElement

Posted by "Park, Sung-Gu" <je...@thinkfree.com>.
There is no order.  Even though it's not important.


----- Original Message ----- 
From: "B.C. Holmes" <bc...@roxton.com>
To: <sl...@jakarta.apache.org>
Sent: Thursday, December 07, 2000 1:15 PM
Subject: Re: Header and HeaderElement


> Remy Maucherat wrote:
> > 
> > I'll probably get rid of the current Header class, and replace it with the
> > HeaderElement class (actually, HeaderElement will become Header).
> > 
> > The only thing which will be changed is NameValuePair.toString(), which
> > would have to do what Header.toString() is doing. Header and NameValuePair
> > have the same API, so it shouldn't break anything (except I'll have to
> > replace HeaderElement by Header in the code).
> > 
> > Is it ok with you BC ?
> 
>      That's fine by me, although right now, the HeaderElement really
> only models the value part of the Header.  I'd had, in the back of my
> mind, a plan to turn Header into a subclass of NameValuePair with an
> overload on toString(), but your approach also works.
> 
> BCing you
> -- 
> B.C. Holmes             \u2625               http://www.bcholmes.org/
> "How often has somebody sensed they were needed without being told?
>  When you have a hurt in your heart you're too proud to disclose
>  Look over there... look over there...  Somebody always knows."
>                   - _La Cage aux Folles_
> 

Re: Header and HeaderElement

Posted by "B.C. Holmes" <bc...@roxton.com>.
Remy Maucherat wrote:
> 
> I'll probably get rid of the current Header class, and replace it with the
> HeaderElement class (actually, HeaderElement will become Header).
> 
> The only thing which will be changed is NameValuePair.toString(), which
> would have to do what Header.toString() is doing. Header and NameValuePair
> have the same API, so it shouldn't break anything (except I'll have to
> replace HeaderElement by Header in the code).
> 
> Is it ok with you BC ?

     That's fine by me, although right now, the HeaderElement really
only models the value part of the Header.  I'd had, in the back of my
mind, a plan to turn Header into a subclass of NameValuePair with an
overload on toString(), but your approach also works.

BCing you
-- 
B.C. Holmes             \u2625               http://www.bcholmes.org/
"How often has somebody sensed they were needed without being told?
 When you have a hurt in your heart you're too proud to disclose
 Look over there... look over there...  Somebody always knows."
                  - _La Cage aux Folles_

Header and HeaderElement

Posted by Remy Maucherat <re...@apache.org>.
Hi,

I'll probably get rid of the current Header class, and replace it with the
HeaderElement class (actually, HeaderElement will become Header).

The only thing which will be changed is NameValuePair.toString(), which
would have to do what Header.toString() is doing. Header and NameValuePair
have the same API, so it shouldn't break anything (except I'll have to
replace HeaderElement by Header in the code).

Is it ok with you BC ?

Remy


Basic Auth.

Posted by "Park, Sung-Gu" <je...@thinkfree.com>.
Yeah, I think so. Basic auth should work fine.
But in my test, it wouldn't...   I dont' know why.
(especially, in Zope & Apache Server...)

Actually, in IIS 5.0, every methods're ok.


----- Original Message ----- 
From: "Remy Maucherat" <re...@betaversion.org>
To: <sl...@jakarta.apache.org>
Sent: Wednesday, December 06, 2000 6:06 AM
Subject: Re: parseStatusLine? and Authorization?


> > In the case of 2),
> > If the WebDAV Client has "HTTP/1.1 401 Autorized Required" Response,
> > it is required to parse www-authenticate for realm and sendRequest
> > again
> > with "Authorization" Header like this:
> >     Authorization: Digest username="jericho",
> >                         realm="String $from_www-auathenticate",
> > nonce="...",
> >                         response="...", opaque="..."
> > -------------------------
> > so, the additional work is need for this part.....
> >          if (method.getStatusCode() == WebdavStatus.SC_UNAUTHORIZED) {
> >                 Header authenticateChallenge =
> >                     (Header) responseHeaders.get("www-authenticate");
> >                 if (authenticateChallenge != null) {
> >                     state.setAuthenticateToken
> >                         (authenticateChallenge.getValue());
> >                 }
> > for username, realm, nonce... etc...
> 
> I know about the status text problem. I had higher priority problems, so I
> didn't try to fix it yet.
> 
> Digest is not supported yet. Since it's a very important auth method for WebDAV,
> it's high on the priority list. Basic auth is supported (and it should work
> fine).
> 
> Remy
> 

Re: parseStatusLine? and Authorization?

Posted by Remy Maucherat <re...@betaversion.org>.
> In the case of 2),
> If the WebDAV Client has "HTTP/1.1 401 Autorized Required" Response,
> it is required to parse www-authenticate for realm and sendRequest
> again
> with "Authorization" Header like this:
>     Authorization: Digest username="jericho",
>                         realm="String $from_www-auathenticate",
> nonce="...",
>                         response="...", opaque="..."
> -------------------------
> so, the additional work is need for this part.....
>          if (method.getStatusCode() == WebdavStatus.SC_UNAUTHORIZED) {
>                 Header authenticateChallenge =
>                     (Header) responseHeaders.get("www-authenticate");
>                 if (authenticateChallenge != null) {
>                     state.setAuthenticateToken
>                         (authenticateChallenge.getValue());
>                 }
> for username, realm, nonce... etc...

I know about the status text problem. I had higher priority problems, so I
didn't try to fix it yet.

Digest is not supported yet. Since it's a very important auth method for WebDAV,
it's high on the priority list. Basic auth is supported (and it should work
fine).

Remy

Authorization: Basic?

Posted by "Park, Sung-Gu" <je...@thinkfree.com>.
Well.... I don't know why....   "Authorization: Basic....." is not working...
the debugging message is correct!!

    EBUG:WebdavClient:Authorization: Basic ajJyaWNobzpqMnJpY2hv
    DEBUG:WebdavClient:Response: HTTP/1.1 400 Bad Request

Nonethless, I've got "400 Bad Request" Response for COPY method in Apache mod_dav Server.
Why?  Any ideas?

  ----- Original Message ----- 
  From: Park, Sung-Gu 
  To: slide-dev@jakarta.apache.org 
  Sent: Wednesday, December 06, 2000 5:16 AM
  Subject: Re: parseStatusLine? and Authorization?


  In the case of 2),
  If the WebDAV Client has "HTTP/1.1 401 Autorized Required" Response,
  it is required to parse www-authenticate for realm and sendRequest again
  with "Authorization" Header like this:
      Authorization: Digest username="jericho",
                          realm="String $from_www-auathenticate", nonce="...",
                          response="...", opaque="..."
  -------------------------
  so, the additional work is need for this part.....
           if (method.getStatusCode() == WebdavStatus.SC_UNAUTHORIZED) {
                  Header authenticateChallenge =
                      (Header) responseHeaders.get("www-authenticate");
                  if (authenticateChallenge != null) {
                      state.setAuthenticateToken
                          (authenticateChallenge.getValue());
                  }
  for username, realm, nonce... etc...


  ----- Original Message ----- 
  From: "Park, Sung-Gu" <je...@thinkfree.com>
  To: <sl...@jakarta.apache.org>
  Sent: Wednesday, December 06, 2000 4:09 AM
  Subject: parseStatusLine? and Authorization?


  > 
  > 1)
  > For status-line tokenizing, it's used StringTokenizer as default Constructor.
  > But It's wrong.  the third parameter of the StatusLine is allowed to use a space.
  > The quick pactch for this is below:
  > 
  >        statusText = statusLine.substring(13);
  >         /*
  >         try {
  >             file://statusText = st.nextToken();
  >         } catch (NoSuchElementException ignored) {
  >         }
  >         */
  > 
  > 
  > 2)
  > I have a suggestion. 
  > For interoperability,  Authorization Header is required for COPY, MOVE, UNLOCK, etc...
  > How will it be going with this?   I think It's important...  even though TC4 is not supported.
  > 
  > 

Re: parseStatusLine? and Authorization?

Posted by "Park, Sung-Gu" <je...@thinkfree.com>.
In the case of 2),
If the WebDAV Client has "HTTP/1.1 401 Autorized Required" Response,
it is required to parse www-authenticate for realm and sendRequest again
with "Authorization" Header like this:
    Authorization: Digest username="jericho",
                        realm="String $from_www-auathenticate", nonce="...",
                        response="...", opaque="..."
-------------------------
so, the additional work is need for this part.....
         if (method.getStatusCode() == WebdavStatus.SC_UNAUTHORIZED) {
                Header authenticateChallenge =
                    (Header) responseHeaders.get("www-authenticate");
                if (authenticateChallenge != null) {
                    state.setAuthenticateToken
                        (authenticateChallenge.getValue());
                }
for username, realm, nonce... etc...


----- Original Message ----- 
From: "Park, Sung-Gu" <je...@thinkfree.com>
To: <sl...@jakarta.apache.org>
Sent: Wednesday, December 06, 2000 4:09 AM
Subject: parseStatusLine? and Authorization?


> 
> 1)
> For status-line tokenizing, it's used StringTokenizer as default Constructor.
> But It's wrong.  the third parameter of the StatusLine is allowed to use a space.
> The quick pactch for this is below:
> 
>        statusText = statusLine.substring(13);
>         /*
>         try {
>             file://statusText = st.nextToken();
>         } catch (NoSuchElementException ignored) {
>         }
>         */
> 
> 
> 2)
> I have a suggestion. 
> For interoperability,  Authorization Header is required for COPY, MOVE, UNLOCK, etc...
> How will it be going with this?   I think It's important...  even though TC4 is not supported.
> 
> 

parseStatusLine? and Authorization?

Posted by "Park, Sung-Gu" <je...@thinkfree.com>.
1)
For status-line tokenizing, it's used StringTokenizer as default Constructor.
But It's wrong.  the third parameter of the StatusLine is allowed to use a space.
The quick pactch for this is below:

       statusText = statusLine.substring(13);
        /*
        try {
            //statusText = st.nextToken();
        } catch (NoSuchElementException ignored) {
        }
        */


2)
I have a suggestion. 
For interoperability,  Authorization Header is required for COPY, MOVE, UNLOCK, etc...
How will it be going with this?   I think It's important...  even though TC4 is not supported.



Is there DepthMethod?

Posted by "Park, Sung-Gu" <je...@thinkfree.com>.
Hello.

There is org/apache/webdav/lib/methods/DepthMethod.
But, there is no Depth WebDAV method.
I recommend you change the class name.  ^^

In the LockMethod,
It's easier to understand to use "DEPTH_INFINITY" rather than "-1".
for default depth field and for recycle().

Sung-Gu.