unico       2004/07/06 12:03:06

  Modified:    webdavclient/clientlib/src/java/org/apache/webdav/lib/methods
                        MoveMethod.java CopyMethod.java
  Log:
  add Depth header utility setters and getters
  
  Revision  Changes    Path
  1.3       +48 -4     
jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/MoveMethod.java
  
  Index: MoveMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/MoveMethod.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MoveMethod.java   11 Feb 2004 11:30:51 -0000      1.2
  +++ MoveMethod.java   6 Jul 2004 19:03:06 -0000       1.3
  @@ -73,6 +73,13 @@
           setOverwrite(overwrite);
       }
   
  +    /**
  +     * Method constructor.
  +     */
  +    public MoveMethod(String source, String destination, boolean overwrite, int 
depth) {
  +        this(source, destination, overwrite);
  +        setDepth(depth);
  +    }
   
       // ----------------------------------------------------- Instance Variables
   
  @@ -88,6 +95,10 @@
        */
       private boolean overwrite = true;
   
  +    /**
  +     * Depth.
  +     */
  +    private int depth = DepthSupport.DEPTH_INFINITY;
   
       // ------------------------------------------------------------- Properties
   
  @@ -108,6 +119,14 @@
           else if(headerName.equalsIgnoreCase("Destination")){
               setDestination(headerValue);
           }
  +        else if (headerName.equalsIgnoreCase("Depth")) {
  +            if (headerValue.equalsIgnoreCase("Infinity")) {
  +                setDepth(DepthSupport.DEPTH_INFINITY);
  +            }
  +            else if (headerValue.equalsIgnoreCase("0")) {
  +                setDepth(0);
  +            }
  +        }
           else{
               super.setRequestHeader(headerName, headerValue);
           }
  @@ -166,6 +185,24 @@
           return overwrite;
       }
   
  +    /**
  +     * Depth setter.
  +     * 
  +     * @param depth New depth value
  +     */
  +    public void setDepth(int depth) {
  +        checkNotUsed();
  +        this.depth = depth;
  +    }
  +
  +    /**
  +     * Depth getter.
  +     * 
  +     * @return Depth value
  +     */
  +    public int getDepth() {
  +        return this.depth;
  +    }
   
       // --------------------------------------------------- WebdavMethod Methods
   
  @@ -193,8 +230,15 @@
           if (!isOverwrite())
               super.setRequestHeader("Overwrite", "F");
   
  +        switch (depth) {
  +             case DepthSupport.DEPTH_0:
  +                 super.setRequestHeader("Depth", "0");
  +                 break;
  +             case DepthSupport.DEPTH_INFINITY:
  +                 super.setRequestHeader("Depth", "Infinity");
  +                 break;
  +        }
       }
  -
   
   }
   
  
  
  
  1.3       +45 -5     
jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/CopyMethod.java
  
  Index: CopyMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/CopyMethod.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CopyMethod.java   11 Feb 2004 11:30:51 -0000      1.2
  +++ CopyMethod.java   6 Jul 2004 19:03:06 -0000       1.3
  @@ -74,6 +74,10 @@
           setOverwrite(overwrite);
       }
   
  +    public CopyMethod(String source, String destination, boolean overwrite, int 
depth) {
  +        this(source, destination, overwrite);
  +        setDepth(depth);
  +    }
   
       // ----------------------------------------------------- Instance Variables
   
  @@ -89,6 +93,10 @@
        */
       private boolean overwrite = true;
   
  +    /**
  +     * Depth.
  +     */
  +    private int depth = DepthSupport.DEPTH_INFINITY;
   
       // ----------------------------------------------------- Instance Variables
   
  @@ -105,9 +113,17 @@
               setOverwrite(! (headerValue.equalsIgnoreCase("F") ||
                              headerValue.equalsIgnoreCase("False") ) );
           }
  -        else if(headerName.equalsIgnoreCase("Destination")){
  +        else if (headerName.equalsIgnoreCase("Destination")){
               setDestination(headerValue);
           }
  +        else if (headerName.equalsIgnoreCase("Depth")) {
  +            if (headerValue.equalsIgnoreCase("Infinity")) {
  +                setDepth(DepthSupport.DEPTH_INFINITY);
  +            }
  +            else if (headerValue.equalsIgnoreCase("0")) {
  +                setDepth(0);
  +            }
  +        }
           else{
               super.setRequestHeader(headerName, headerValue);
           }
  @@ -167,6 +183,23 @@
           return overwrite;
       }
   
  +    /**
  +     * Depth setter.
  +     * 
  +     * @param depth New depth value
  +     */
  +    public void setDepth(int depth) {
  +        this.depth = depth;
  +    }
  +    
  +    /**
  +     * Depth getter.
  +     * 
  +     * @return int Depth value
  +     */
  +    public int getDepth() {
  +        return this.depth;
  +    }
   
       public String getName() {
           return "COPY";
  @@ -194,8 +227,15 @@
           if (!isOverwrite())
               super.setRequestHeader("Overwrite", "F");
   
  +        switch (depth) {
  +             case DepthSupport.DEPTH_0:
  +                 super.setRequestHeader("Depth", "0");
  +                 break;
  +             case DepthSupport.DEPTH_INFINITY:
  +                 super.setRequestHeader("Depth", "Infinity");
  +                 break;
  +        }
       }
  -
   
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to