ib          2003/07/15 05:02:03

  Modified:    src/webdav/client/src/org/apache/webdav/ant/taskdefs
                        Put.java Get.java
               src/webdav/client/src/org/apache/webdav/ant
                        CollectionScanner.java
  Log:
  Account for changes in Commons-HttpClient,
  fix some JavaDoc comments
  
  Thanks to Eric Johnson for submitting this patch.
  
  Revision  Changes    Path
  1.9       +12 -15    
jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/taskdefs/Put.java
  
  Index: Put.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/taskdefs/Put.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Put.java  4 Apr 2003 15:25:14 -0000       1.8
  +++ Put.java  15 Jul 2003 12:02:03 -0000      1.9
  @@ -128,7 +128,7 @@
       /**
        * Should we try to lock the remote resource as we upload it?
        *
  -     * @param userid - HTTP userid
  +     * @return <code>true</code> if the resource should be locked on upload.
        */
       public boolean getLock() {
           return this.lock;
  @@ -141,7 +141,7 @@
       /**
        * Get a userid to access the resources
        *
  -     * @returns userid - HTTP userid
  +     * @return userid - HTTP userid
        */
       public String getUserid() {
           return userid;
  @@ -159,7 +159,7 @@
       /**
        * Get a password to access the resources
        *
  -     * @returns userid - HTTP userid
  +     * @return The password for the resources.
        */
       public String getPassword() {
           return password;
  @@ -182,7 +182,7 @@
       /**
        * Set the base URL.
        *
  -     * @param base URL for the request.
  +     * @param url The base URL for the request.
        */
       public void setUrl(String url) {
           if (url.endsWith("/")) {
  @@ -201,17 +201,16 @@
       public void execute() throws BuildException {
           try {
   
  +            URL url = new URL(toURL);
  +
               if ((this.userid != null && !this.userid.equals("")) &&
                   (this.password != null && !this.password.equals(""))) {
  -                client.getState().setCredentials(null,
  +                client.getState().setCredentials(null, url.getHost(),
                       new UsernamePasswordCredentials(this.userid, this.password));
               }
   
               // validity check on the URL
  -            URL url = new URL(toURL);
  -
  -            client.startSession(url.getHost(),
  -                                (url.getPort() < 0 ? 80 : url.getPort()));
  +            client.getHostConfiguration().setHost(url.getHost(), url.getPort() < 0 
? 80 : url.getPort());
   /*
               OptionsMethod optionsMethod = new OptionsMethod();
               optionsMethod.setPath(url.getFile());
  @@ -237,8 +236,6 @@
                   uploadFiles(url.getFile(),
                               fileset.getDirectoryScanner(this.project));
               }
  -
  -            client.endSession();
   
           } catch (MalformedURLException e) {
               throw new BuildException(e.getMessage(), e);
  
  
  
  1.8       +9 -10     
jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/taskdefs/Get.java
  
  Index: Get.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/taskdefs/Get.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Get.java  4 Apr 2003 15:25:14 -0000       1.7
  +++ Get.java  15 Jul 2003 12:02:03 -0000      1.8
  @@ -126,15 +126,15 @@
                       "Includes must be specified");
               }
   
  +            // validity check on the URL
  +            URL url = new URL(baseURL);
  +
               if ((this.userid != null && !this.userid.equals("")) &&
                   (this.password != null && !this.password.equals(""))) {
  -                client.getState().setCredentials(null, new 
UsernamePasswordCredentials(this.userid, this.password));
  +                client.getState().setCredentials(null, url.getHost(), new 
UsernamePasswordCredentials(this.userid, this.password));
               }
   
  -            // validity check on the URL
  -            URL url = new URL(baseURL);
  -
  -            client.startSession(url.getHost(),
  +            client.getHostConfiguration().setHost(url.getHost(),
                                   (url.getPort() < 0 ? 80 : url.getPort()));
   
               Scanner scanner = getScanner(url);
  @@ -176,7 +176,6 @@
                   input.close();
                   getMethod.recycle();
               }
  -            client.endSession();
   
           } catch (BuildException e) {
               log(e.getMessage());
  @@ -199,7 +198,7 @@
       /**
        * Set the base URL.
        *
  -     * @param base URL for the request.
  +     * @param baseURL The base URL for the request.
        */
       public void setBaseurl(String baseURL) {
           if (baseURL.endsWith("/")) {
  
  
  
  1.8       +5 -9      
jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/CollectionScanner.java
  
  Index: CollectionScanner.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/CollectionScanner.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CollectionScanner.java    4 Apr 2003 15:25:14 -0000       1.7
  +++ CollectionScanner.java    15 Jul 2003 12:02:03 -0000      1.8
  @@ -110,10 +110,7 @@
           try {
   
               // check to make sure that DAV is supported...
  -            OptionsMethod options = new OptionsMethod();
  -            options.setPath(baseURL.getFile());
  -            client.startSession(baseURL.getHost(),
  -                                (baseURL.getPort() < 0 ? 80 : baseURL.getPort()));
  +            OptionsMethod options = new OptionsMethod(baseURL.toString());
               client.executeMethod(options);
   
               if (!options.isAllowed("PROPFIND")) {
  @@ -122,8 +119,7 @@
               }
   
               // get a list of all resources from the given URL
  -            PropFindMethod propFind = new PropFindMethod();
  -            propFind.setPath(baseURL.getFile());
  +            PropFindMethod propFind = new PropFindMethod(baseURL.toString());
               propFind.setPropertyNames(PROPERTY_NAMES.elements());
               propFind.setType(PropFindMethod.NAMES);
               client.executeMethod(propFind);
  
  
  

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

Reply via email to