cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java
Date Sat, 27 Mar 2004 17:40:11 GMT
unico       2004/03/27 09:40:11

  Modified:    src/blocks/webdav/test/org/apache/cocoon/components/source/impl
                        WebDAVSourceTestCase.java
               src/blocks/webdav/java/org/apache/cocoon/components/source/impl
                        WebDAVSource.java
  Log:
  two bugfixes based on additional testcases
  
  Revision  Changes    Path
  1.3       +51 -6     cocoon-2.1/src/blocks/webdav/test/org/apache/cocoon/components/source/impl/WebDAVSourceTestCase.java
  
  Index: WebDAVSourceTestCase.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/webdav/test/org/apache/cocoon/components/source/impl/WebDAVSourceTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebDAVSourceTestCase.java	27 Mar 2004 16:01:40 -0000	1.2
  +++ WebDAVSourceTestCase.java	27 Mar 2004 17:40:11 -0000	1.3
  @@ -15,10 +15,13 @@
    */
   package org.apache.cocoon.components.source.impl;
   
  +import java.io.InputStream;
  +import java.io.OutputStream;
   import java.util.Iterator;
   
   import org.apache.avalon.excalibur.testcase.ExcaliburTestCase;
   import org.apache.cocoon.components.source.impl.WebDAVSource;
  +import org.apache.excalibur.source.ModifiableTraversableSource;
   import org.apache.excalibur.source.SourceResolver;
   import org.apache.excalibur.source.TraversableSource;
   import org.apache.webdav.lib.WebdavResource;
  @@ -29,9 +32,9 @@
   public class WebDAVSourceTestCase extends ExcaliburTestCase {
       
       private String m_scheme = "webdav";
  -    private String m_credentials = "site:site";
  -    private String m_authority = "localhost:8888/webdav";
  -    private String m_path = "/";
  +    private String m_credentials = "usr:pwd";
  +    private String m_authority = "localhost:8888";
  +    private String m_path = "/webdav/";
       private String m_name = "files";
       private String m_qs = "?foo=bar";
       private String m_location = m_scheme + "://" + m_credentials + "@" + m_authority +
m_path + m_name + m_qs;
  @@ -54,7 +57,7 @@
           resolver.release(source);
       }
   
  -    public void testCollection() throws Exception {
  +    public void testTraversal() throws Exception {
   //        SourceResolver resolver = (SourceResolver) lookup(SourceResolver.ROLE);
   //        String uri = m_location + m_options;
   //        TraversableSource source = (TraversableSource) resolver.resolveURI(uri);
  @@ -68,8 +71,50 @@
   //            assertEquals(m_scheme, parent.getScheme());
   //            assertEquals(m_name, parent.getName());
   //            assertTrue(parent.isCollection());
  +//            resolver.release(child);
   //        }
   //        resolver.release(source);
       }
  -    
  +
  +    public void testModification() throws Exception {
  +//        SourceResolver resolver = (SourceResolver) lookup(SourceResolver.ROLE);
  +//        String uri = m_location + m_options;
  +//        ModifiableTraversableSource source = (ModifiableTraversableSource) resolver.resolveURI(uri);
  +//        ModifiableTraversableSource child = (ModifiableTraversableSource) source.getChild("newcol");
  +//        
  +//        assertTrue(!child.exists());
  +//        child.makeCollection();
  +//        assertTrue(child.exists());
  +//        child.delete();
  +//        assertTrue(!child.exists());
  +//        
  +//        resolver.release(child);
  +//        resolver.release(source);
  +//        
  +//        source = (ModifiableTraversableSource) resolver.resolveURI(uri);
  +//        child = (ModifiableTraversableSource) source.getChild("newdoc.txt");
  +//        assertTrue(!child.exists());
  +//        
  +//        // create document
  +//        String hello = "hello world";
  +//        OutputStream out = child.getOutputStream();
  +//        out.write(hello.getBytes());
  +//        out.close();
  +//        
  +//        assertTrue(child.exists());
  +//        
  +//        // read contents
  +//        byte[] read = new byte[hello.length()];
  +//        InputStream in = child.getInputStream();
  +//        in.read(read);
  +//        
  +//        // compare
  +//        assertEquals(hello, new String(read));
  +//        
  +//        child.delete();
  +//        assertTrue(!child.exists());
  +//        
  +//        resolver.release(source);
  +//        resolver.release(child);
  +    }
   }
  
  
  
  1.25      +20 -9     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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- WebDAVSource.java	27 Mar 2004 15:51:21 -0000	1.24
  +++ WebDAVSource.java	27 Mar 2004 17:40:11 -0000	1.25
  @@ -124,7 +124,7 @@
               
               // parse optional start depth and start action qs parameters
               this.depth = sp.getParameterAsInteger("cocoon:webdav-depth", DepthSupport.DEPTH_1);
  -            this.action = sp.getParameterAsInteger("cocoon:webdav-action", WebdavResource.BASIC);
  +            this.action = sp.getParameterAsInteger("cocoon:webdav-action", WebdavResource.NOACTION);
               
               // [UH] FIXME: Why this alternative way of passing in credentials?
               String principal = url.getUser();
  @@ -191,19 +191,27 @@
       private void initResource(int action, int depth) throws SourceException, SourceNotFoundException
{
   		try {
               boolean update = false;
  -            if (action > this.action) {
  -                this.action = action;
  -                update = true;
  +            if (action != WebdavResource.NOACTION) {
  +                if (action > this.action) {
  +                    this.action = action;
  +                    update = true;
  +                }
  +                else {
  +                    action = this.action;
  +                }
               }
               if (depth > this.depth) {
                   this.depth = depth;
                   update = true;
               }
  +            else {
  +                depth = this.depth;
  +            }
   			if (this.resource == null) {
  -			    this.resource = new WebdavResource(this.url, this.action, this.depth);
  +			    this.resource = new WebdavResource(this.url, action, depth);
   			}
   			else if (update) {
  -			    this.resource.setProperties(this.action, this.depth);
  +			    this.resource.setProperties(action, depth);
   			}
               if (this.action > WebdavResource.NOACTION) {
                   if (this.resource.isCollection()) {
  @@ -525,6 +533,9 @@
        * @see org.apache.excalibur.source.TraversableSource#getChild(java.lang.String)
        */
       public Source getChild(String childName) throws SourceException {
  +        if (!isCollection()) {
  +            throw new SourceException(getSecureURI() + " is not a collection.");
  +        }
           try {
               HttpURL childURL;
               if (this.url instanceof HttpsURL) {
  @@ -748,9 +759,9 @@
        */
       public void makeCollection() throws SourceException {
           initResource(WebdavResource.NOACTION, DepthSupport.DEPTH_0);
  -        if (resource.exists()) return;
  +        if (this.resource.exists()) return;
       	try {
  -            resource.mkcolMethod();
  +            this.resource.mkcolMethod();
           } catch (HttpException e) {
               throw new SourceException("Unable to create collection(s) " + getSecureURI(),
e);
           } catch (IOException e) {
  
  
  

Mime
View raw message