ozeigermann    2004/04/14 06:29:52

  Modified:    webdavclient/commandline/src/java/org/apache/webdav/cmd
                        Client.java
               webdavclient/clientlib/src/java/org/apache/webdav/lib/properties
                        ResourceTypeProperty.java
  Log:
  Applied patch by Thomas Bernert to address issue #28373
  
  Revision  Changes    Path
  1.9       +27 -4     
jakarta-slide/webdavclient/commandline/src/java/org/apache/webdav/cmd/Client.java
  
  Index: Client.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/webdavclient/commandline/src/java/org/apache/webdav/cmd/Client.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Client.java       13 Apr 2004 09:00:53 -0000      1.8
  +++ Client.java       14 Apr 2004 13:29:52 -0000      1.9
  @@ -56,6 +56,7 @@
   import org.apache.webdav.lib.properties.AclProperty;
   import org.apache.webdav.lib.properties.LockDiscoveryProperty;
   import org.apache.webdav.lib.properties.PrincipalCollectionSetProperty;
  +import org.apache.webdav.lib.properties.ResourceTypeProperty;
   
   
   /**
  @@ -84,7 +85,7 @@
       private HttpURL httpURL;
   
       /** The debug level. */
  -    private int debugLevel = 0;
  +    private int debugLevel = DEBUG_OFF;
   
       /** The WebDAV resource. */
       private WebdavResource webdavResource = null;
  @@ -258,6 +259,12 @@
   
       void connect(String uri)
       {
  +                
  +        if (!uri.endsWith("/") && !uri.endsWith("\\")) {
  +            // append / to the path
  +             uri+="/";
  +        }
  +
           out.println("connect " + uri);
   
           try {
  @@ -266,6 +273,14 @@
               if (webdavResource == null) {
                   webdavResource = new WebdavResource(httpURL);
                   webdavResource.setDebug(debugLevel);
  +                
  +                // is not a collection?
  +                if 
(!((ResourceTypeProperty)webdavResource.getResourceType()).isCollection()) {
  +                    webdavResource = null;
  +                    httpURL = null;
  +                    out.println("Error: " + uri + " is not a collection! Use 
open/connect only for collections!");
  +                }
  +                
               } else {
                   webdavResource.close();
                   webdavResource.setHttpURL(httpURL);
  @@ -273,6 +288,7 @@
               setPath(webdavResource.getPath());
           }
           catch (HttpException we) {
  +            out.print("HttpException.getReasonCode(): "+ we.getReasonCode());
               if (we.getReasonCode() == HttpStatus.SC_UNAUTHORIZED) {
                   try {
                       out.print("UserName: ");
  @@ -302,6 +318,13 @@
                       webdavResource = new WebdavResource(httpURL);
                       webdavResource.setDebug(debugLevel);
                       setPath(webdavResource.getPath());
  +
  +
  +                    if 
(!((ResourceTypeProperty)webdavResource.getResourceType()).isCollection()) {
  +                        webdavResource = null;
  +                        httpURL = null;
  +                        out.println("Error: " + uri + " is not a collection! Use 
open/connect only for collections!");
  +                    }
                   }
                   catch (Exception ex) {
                       handleException(ex);
  
  
  
  1.3       +9 -4      
jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/ResourceTypeProperty.java
  
  Index: ResourceTypeProperty.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/ResourceTypeProperty.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResourceTypeProperty.java 11 Feb 2004 11:30:52 -0000      1.2
  +++ ResourceTypeProperty.java 14 Apr 2004 13:29:52 -0000      1.3
  @@ -49,6 +49,11 @@
        */
       public static final String TAG_NAME = "resourcetype";
   
  +    /**
  +     * The property collection tag.
  +     */
  +    public static final String TAG_COLLECTION = "collection";
  +
   
       // ----------------------------------------------------------- Constructors
   
  @@ -88,7 +93,7 @@
           for (int i = 0; tmp != null && i < tmp.getLength(); i++ ) {
               try {
                   Element child = (Element) tmp.item(i);
  -                if ("collection".equals(DOMUtils.getElementLocalName(child))
  +                if (TAG_COLLECTION.equals(DOMUtils.getElementLocalName(child))
                        && "DAV:".equals(DOMUtils.getElementNamespaceURI(child)))
                   {
                       isCollection=true;
  
  
  

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

Reply via email to