unico       2004/03/29 02:52:46

  Modified:    src/blocks/webdav/java/org/apache/cocoon/components/source/impl
                        WebDAVSource.java
  Log:
  check if MKCOL actually succeeded
  
  Revision  Changes    Path
  1.26      +22 -7     
cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java
  
  Index: WebDAVSource.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- WebDAVSource.java 27 Mar 2004 17:40:11 -0000      1.25
  +++ WebDAVSource.java 29 Mar 2004 10:52:46 -0000      1.26
  @@ -547,7 +547,7 @@
               return WebDAVSource.newWebDAVSource(childURL, this.protocol, 
getLogger());
           }
           catch (URIException e) {
  -            throw new SourceException("Failure creating child", e);
  +            throw new SourceException("Failed to create child", e);
           }        
       }
   
  @@ -627,7 +627,7 @@
               return WebDAVSource.newWebDAVSource(parentURL, this.protocol, 
getLogger());
           }
           catch (URIException e) {
  -            throw new SourceException("Failure creating parent", e);
  +            throw new SourceException("Failed to create parent", e);
           }
       }
   
  @@ -745,7 +745,7 @@
           
           private void cancel() {
               if (isClosed) {
  -                throw new IllegalStateException("Cannot cancel: outputstrem 
is already closed");
  +                throw new IllegalStateException("Cannot cancel: outputstream 
is already closed");
               }
               this.isClosed = true;
           }
  @@ -761,10 +761,25 @@
           initResource(WebdavResource.NOACTION, DepthSupport.DEPTH_0);
           if (this.resource.exists()) return;
        try {
  -            this.resource.mkcolMethod();
  -        } catch (HttpException e) {
  +            if (!this.resource.mkcolMethod()) {
  +                int status = this.resource.getStatusCode();
  +                // Ignore status 405 - Not allowed: collection already exists
  +                if (status != 405) {
  +                    final String msg = 
  +                        "Unable to create collection " + getSecureURI()
  +                        + ". Server responded " + 
this.resource.getStatusCode()
  +                        + " (" + this.resource.getStatusMessage() + ")";
  +                    throw new SourceException(msg);
  +                }
  +            }
  +        }
  +     catch (HttpException e) {
               throw new SourceException("Unable to create collection(s) " + 
getSecureURI(), e);
  -        } catch (IOException e) {
  +        }
  +     catch (SourceException e) {
  +            throw e;
  +        }
  +        catch (IOException e) {
               throw new SourceException("Unable to create collection(s)"  + 
getSecureURI(), e);                        
           }
       }
  
  
  

Reply via email to