Return-Path: Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 66096 invoked by uid 500); 27 Jul 2003 12:56:16 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 66083 invoked by uid 500); 27 Jul 2003 12:56:16 -0000 Delivered-To: apmail-cocoon-2.1-cvs@apache.org Received: (qmail 66079 invoked from network); 27 Jul 2003 12:56:16 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 27 Jul 2003 12:56:16 -0000 Received: (qmail 35325 invoked by uid 1409); 27 Jul 2003 12:56:16 -0000 Date: 27 Jul 2003 12:56:16 -0000 Message-ID: <20030727125616.35324.qmail@icarus.apache.org> From: gianugo@apache.org To: cocoon-2.1-cvs@apache.org Subject: cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N gianugo 2003/07/27 05:56:16 Modified: src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java Log: Implemented ModifiableTraversable + small fixes on getURI() Revision Changes Path 1.3 +30 -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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- WebDAVSource.java 14 Jul 2003 16:06:21 -0000 1.2 +++ WebDAVSource.java 27 Jul 2003 12:56:16 -0000 1.3 @@ -69,11 +69,10 @@ import org.apache.cocoon.components.source.helpers.SourceCredential; import org.apache.cocoon.components.source.helpers.SourcePermission; import org.apache.commons.httpclient.HttpException; -import org.apache.excalibur.source.ModifiableSource; +import org.apache.excalibur.source.ModifiableTraversableSource; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; import org.apache.excalibur.source.SourceValidity; -import org.apache.excalibur.source.TraversableSource; import org.apache.excalibur.source.impl.validity.TimeStampValidity; import org.apache.util.HttpURL; import org.apache.webdav.lib.WebdavResource; @@ -92,7 +91,7 @@ * @version $Id$ */ public class WebDAVSource - implements Source, RestrictableSource, ModifiableSource, TraversableSource { + implements Source, RestrictableSource, ModifiableTraversableSource { private final String NAMESPACE = "http://apache.org/cocoon/webdav/1.0"; @@ -173,8 +172,10 @@ try { return new WebDAVSource(location, principal, password, protocol, true); } catch (HttpException finalHe) { + finalHe.printStackTrace(System.err); throw new SourceException("Error creating the source: ", finalHe); } catch (IOException e) { + e.printStackTrace(System.err); throw new SourceException("Error creating the source: ", e); } } catch (IOException e) { @@ -219,9 +220,9 @@ return bi; } } catch (HttpException he) { - throw new SourceException("Could get WebDAV resource", he); + throw new SourceException("Could not get WebDAV resource", he); } catch (Exception e) { - throw new SourceException("Could get WebDAV resource", e); + throw new SourceException("Could not get WebDAV resource", e); } } @@ -229,7 +230,14 @@ * Return the unique identifer for this source */ public String getURI() { - return this.systemId; + // Change http: to webdav: + //return "webdav:" + this.systemId.substring(5); + //add Source credentials + if (principal != null) + return "webdav://" + this.principal + ":" + this.password + "@" + this.systemId.substring(7); + else + return "webdav://" + this.systemId.substring(7); + } /** @@ -619,6 +627,21 @@ */ public void delete() throws SourceException { // TODO Auto-generated method stub + } + + /** + * Create the collection, if it doesn't exist. + * @see org.apache.excalibur.source.ModifiableTraversableSource#makeCollection() + */ + public void makeCollection() throws SourceException { + if (resource.exists()) return; + try { + resource.mkcolMethod(); + } catch (HttpException e) { + throw new SourceException("Unable to create collection(s)", e); + } catch (IOException e) { + throw new SourceException("Unable to create collection(s)", e); + } } }