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:52:26 UTC

cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/taskdefs Get.java

bcholmes    00/12/03 22:52:26

  Modified:    src/webdav/client/src/org/apache/webdav/ant
                        CollectionScanner.java
               src/webdav/client/src/org/apache/webdav/ant/taskdefs
                        Get.java
  Log:
  - Update Get task to use new ResourceType property
  
  Revision  Changes    Path
  1.2       +22 -19    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CollectionScanner.java	2000/11/22 06:19:07	1.1
  +++ CollectionScanner.java	2000/12/04 06:52:24	1.2
  @@ -1,4 +1,9 @@
   /*
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/CollectionScanner.java,v 1.2 2000/12/04 06:52:24 bcholmes Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/12/04 06:52:24 $
  + *
  + * ====================================================================
    * The Apache Software License, Version 1.1
    *
    * Copyright (c) 1999 The Apache Software Foundation.  All rights
  @@ -71,10 +76,17 @@
   import org.apache.webdav.lib.methods.PropFindMethod;
   import org.apache.webdav.lib.methods.OptionsMethod;
   
  +import org.apache.webdav.lib.properties.ResourceType;
  +
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
   import org.w3c.dom.NodeList;
   
  +/**
  + * Scan a collection of resources to find ones that match a specified pattern.
  + *
  + * @author <a href="mailto:bcholmes@interlog.com">B.C. Holmes</a>
  + */
   public class CollectionScanner extends Scanner {
   
       private URL baseURL = null;
  @@ -111,7 +123,7 @@
               // check to make sure that DAV is supported...
               OptionsMethod options = new OptionsMethod();
               options.setPath(baseURL.getFile());
  -            client.startSession(baseURL.getHost(), 
  +            client.startSession(baseURL.getHost(),
                                   (baseURL.getPort() < 0 ? 80 : baseURL.getPort()));
               client.executeMethod(options);
   
  @@ -127,17 +139,20 @@
               propFind.setType(PropFindMethod.NAMES);
               client.executeMethod(propFind);
   
  -            for (Enumeration e = propFind.getAllResponseURLs(); 
  +            for (Enumeration e = propFind.getAllResponseURLs();
                    e.hasMoreElements(); ) {
   
                   String href = (String) e.nextElement();
   
  -                for (Enumeration properties = propFind.getResponseProperties(href);
  +                for (Enumeration properties =
  +                        propFind.getResponseProperties(href);
                        properties.hasMoreElements(); ) {
   
  -                    Property property = (Property) properties.nextElement();
  -                    if (property.getName().endsWith("resourcetype")) {
  -                        addResource(href, property.getElement());
  +                    try {
  +                        ResourceType property =
  +                            (ResourceType) properties.nextElement();
  +                        addResource(href, property.isCollection());
  +                    } catch (ClassCastException exception) {
                       }
                   }
               }
  @@ -153,20 +168,8 @@
           }
       }
   
  -    protected void addResource(String href, Element resourcetype) 
  +    protected void addResource(String href, boolean isCollection)
               throws ScanException {
  -
  -        boolean isCollection = false;
  -        NodeList tmp = resourcetype.getChildNodes();
  -        for (int i = 0; i < tmp.getLength(); i++ ) {
  -            try {
  -                Element child = (Element) tmp.item(i);
  -                if (child.getTagName().endsWith("collection")) {
  -                    isCollection = true;
  -                }
  -            } catch (ClassCastException e) {
  -            }
  -        }
   
           try {
               String url = (new URL(getBaseURL(), href)).getFile();
  
  
  
  1.2       +16 -11    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Get.java	2000/11/22 06:19:07	1.1
  +++ Get.java	2000/12/04 06:52:25	1.2
  @@ -1,7 +1,12 @@
   /*
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/taskdefs/Get.java,v 1.2 2000/12/04 06:52:25 bcholmes Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/12/04 06:52:25 $
  + *
  + * ====================================================================
    * 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
  @@ -9,7 +14,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
  @@ -17,15 +22,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"
  @@ -74,9 +79,9 @@
   import org.apache.webdav.lib.methods.GetMethod;
   
   /**
  - * Get a particular resource or collection of resources from a 
  - * WebDAV-compliant web server.  This task differs from the 
  - * basic Get task in Ant because it allows regular expressions 
  + * Get a particular resource or collection of resources from a
  + * WebDAV-compliant web server.  This task differs from the
  + * basic Get task in Ant because it allows regular expressions
    * to be used.
    *
    * <p>  To use this task, first you must it in your Ant build file:
  @@ -135,7 +140,7 @@
               // validity check on the URL
               URL url = new URL(baseURL);
   
  -            client.startSession(url.getHost(), 
  +            client.startSession(url.getHost(),
                                   (url.getPort() < 0 ? 80 : url.getPort()));
   
               Scanner scanner = getScanner(url);
  @@ -148,7 +153,7 @@
   
                   String file = resource.replace('/',File.separatorChar);
   
  -                file = concatenate(dest, file, File.separator);                    
  +                file = concatenate(dest, file, File.separator);
                   FileOutputStream output = new FileOutputStream(file);
   
                   resource = concatenate(url.getFile(), resource, "/");
  @@ -165,7 +170,7 @@
                   if( input == null ) {
                       throw new BuildException( "Can't get " + resource + " to " + file);
                   }
  -		
  +
                   byte[] buffer = new byte[100 * 1024];
                   int length;