Re: cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java

2003-12-19 Thread Guido Casper
Gianugo Rabellino wrote:
 Guido Casper wrote:
 Gianugo Rabellino wrote:

 [EMAIL PROTECTED] wrote:

 gcasper 2003/12/17 05:42:14

  Modified:

  src/blocks/webdav/java/org/apache/cocoon/components/source/impl
  WebDAVSource.java Log: Interoperability with mod_dav

 Why so? I think that the cleanest way is to solve this issue where
 it belongs, inside httpclient if possible, or in httpd, with a
 BrowserMatch directive...


 How do you solve that with a BrowserMatch directive? If that is
 possible I revert the change.

 BrowserMatch ^Jakarta Commons-HttpClient redirect-carefully

Redirect (assuming you mean rewrite) what?
How to find out what is a collection and what not?


 mod_dav sends a redirect on collections without a trailing slash.

 And it's disputable which one is the correct behaviour. I tend to
 think that Apache does it right...

IIUC the correct behaviour is to just send the response together with a
Location header so that the WebDAV client adjusts its base URL for
further requests. But since clients tend to ignore that header some
server send a redirect instead. So what mod_dav does is considered well
behaved and to be expected with other servers as well.

Unfortunately this breaks WebDAVSource with
TraversableSourceDescriptionGenerator.
I just tried setting followRirects in WebDAVResource.propfindMethod
without success :-( .

The only other places to fix this is either WebDAVSource or
WebDAVResource.setWebdavProperties/.processProperty.


 httpclient reasonably doesn't modify the set URL in any way. If you
 prefer I could ask slide-dev to change WebDAVResource to set
 followRedirects on propfind requests (I didn't test that yet and
 somewhat fear the performance penalty).

 You think so? Why should there be a performance penalty?

Because of doubling the number of roundtrips.
The problem only shows with TraversableSourceDescriptionGenerator on
collections containing child collections. It's the only one doing a
getSourceProperties (propfind) on child collections. One propfind (and a
redirect since their URL doesn't contain the trailing slash) on each
child collection. And if the number of child collection is big  ...

Guido



Re: cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java

2003-12-18 Thread Guido Casper
Gianugo Rabellino wrote:
 [EMAIL PROTECTED] wrote:
 gcasper 2003/12/17 05:42:14

   Modified:

   src/blocks/webdav/java/org/apache/cocoon/components/source/impl
   WebDAVSource.java Log: Interoperability with mod_dav

 Why so? I think that the cleanest way is to solve this issue where it
 belongs, inside httpclient if possible, or in httpd, with a
 BrowserMatch directive...

How do you solve that with a BrowserMatch directive? If that is possible
I revert the change.

mod_dav sends a redirect on collections without a trailing slash.
httpclient reasonably doesn't modify the set URL in any way. If you
prefer I could ask slide-dev to change WebDAVResource to set
followRedirects on propfind requests (I didn't test that yet and
somewhat fear the performance penalty).

Guido



Re: cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java

2003-12-18 Thread Gianugo Rabellino
Guido Casper wrote:
Gianugo Rabellino wrote:

[EMAIL PROTECTED] wrote:

gcasper 2003/12/17 05:42:14

 Modified:

 src/blocks/webdav/java/org/apache/cocoon/components/source/impl
 WebDAVSource.java Log: Interoperability with mod_dav
Why so? I think that the cleanest way is to solve this issue where it
belongs, inside httpclient if possible, or in httpd, with a
BrowserMatch directive...


How do you solve that with a BrowserMatch directive? If that is possible
I revert the change.
BrowserMatch ^Jakarta Commons-HttpClient redirect-carefully

mod_dav sends a redirect on collections without a trailing slash.
And it's disputable which one is the correct behaviour. I tend to think 
that Apache does it right...

httpclient reasonably doesn't modify the set URL in any way. If you
prefer I could ask slide-dev to change WebDAVResource to set
followRedirects on propfind requests (I didn't test that yet and
somewhat fear the performance penalty).
You think so? Why should there be a performance penalty?

Ciao,

--
Gianugo Rabellino
Pro-netics s.r.l. -  http://www.pro-netics.com
Orixo, the XML business alliance - http://www.orixo.com
(Now blogging at: http://blogs.cocoondev.org/gianugo/)


Re: cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java

2003-12-17 Thread Gianugo Rabellino
[EMAIL PROTECTED] wrote:
gcasper 2003/12/17 05:42:14

  Modified:src/blocks/webdav/java/org/apache/cocoon/components/source/impl
WebDAVSource.java
  Log:
  Interoperability with mod_dav
Why so? I think that the cleanest way is to solve this issue where it 
belongs, inside httpclient if possible, or in httpd, with a BrowserMatch 
directive...

Ciao,

--
Gianugo Rabellino
Pro-netics s.r.l. -  http://www.pro-netics.com
Orixo, the XML business alliance - http://www.orixo.com
(Now blogging at: http://blogs.cocoondev.org/gianugo/)


cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java WebDAVSourceFactory.java

2003-08-22 Thread gcasper
gcasper 2003/08/22 05:23:41

  Modified:src/blocks/webdav/java/org/apache/cocoon/components/source/impl
WebDAVSource.java WebDAVSourceFactory.java
  Log:
  Implemented InspectableSource.
  I know, the design of the InspectableSource interface (and the
  SourceProperty class in particular) is debatable.
  I just want to first come up with an easy tryable sample before discussing
  it.
  
  Revision  ChangesPath
  1.5   +178 -3
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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WebDAVSource.java 27 Jul 2003 20:53:39 -  1.4
  +++ WebDAVSource.java 22 Aug 2003 12:23:41 -  1.5
  @@ -56,9 +56,11 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.OutputStream;
  +import java.io.StringReader;
   import java.util.Collection;
   import java.util.Iterator;
   import java.util.Vector;
  +import java.util.Enumeration;
   
   import javax.xml.transform.TransformerFactory;
   import javax.xml.transform.sax.SAXTransformerFactory;
  @@ -68,18 +70,31 @@
   import org.apache.cocoon.components.source.RestrictableSource;
   import org.apache.cocoon.components.source.helpers.SourceCredential;
   import org.apache.cocoon.components.source.helpers.SourcePermission;
  +import org.apache.cocoon.components.source.helpers.SourceProperty;
  +import org.apache.cocoon.components.source.InspectableSource;
   import org.apache.commons.httpclient.HttpException;
  +import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.framework.component.Component;
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.ComponentException;
   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.impl.validity.TimeStampValidity;
  +import org.apache.excalibur.xml.dom.DOMParser;
   import org.apache.util.HttpURL;
   import org.apache.webdav.lib.WebdavResource;
   import org.apache.webdav.lib.methods.DepthSupport;
  +import org.apache.webdav.lib.Property;
  +import org.apache.webdav.lib.PropertyName;
  +import org.apache.webdav.lib.ResponseEntity;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
  +import org.xml.sax.InputSource;
  +
  +import org.w3c.dom.Document;
   
   /**
*  A source implementation to get access to WebDAV repositories. Use it
  @@ -90,8 +105,8 @@
*  @author a href=mailto:[EMAIL PROTECTED]Daniele Madama/a
*  @version $Id$
   */
  -public class WebDAVSource
  -implements Source, RestrictableSource, ModifiableTraversableSource {
  +public class WebDAVSource implements Composable, Source,
  +RestrictableSource, ModifiableTraversableSource, InspectableSource {
   
   
   private final String NAMESPACE = http://apache.org/cocoon/webdav/1.0;;
  @@ -102,6 +117,8 @@
   
   private final String COLLECTION_NAME = collection;
   
  +private ComponentManager manager = null;
  +
   private String systemId;
   
   private String location;
  @@ -193,6 +210,18 @@
   }
   
   /**
  + * Pass the ComponentManager to the composer. The Composable implementation
  + * should use the specified ComponentManager to acquire the components it needs 
for execution
  + *
  + * @param manager The ComponentManager which this Composable uses
  + *
  + * @throws ComponentException
  + */
  +public void compose(ComponentManager manager) throws ComponentException {
  +this.manager = manager;
  +}
  +
  +/**
* Get the scheme for this Source (webdav://).
*/
   
  @@ -670,5 +699,151 @@
   }
   }
   
  +/**
  + * Returns a enumeration of the properties
  + *
  + * @return Enumeration of SourceProperty
  + *
  + * @throws SourceException If an exception occurs.
  + */
  + public SourceProperty[] getSourceProperties() throws SourceException {
  +
  + Vector sourceproperties = new Vector();
  + DOMParser parser = null;
  + String xml = ;
  + Enumeration props= null;
  + org.apache.webdav.lib.Property prop = null;
  + String propValue = null;
  +
  + try {
  + parser = (DOMParser)this.manager.lookup(DOMParser.ROLE);
  + Enumeration responses = this.resource.propfindMethod(0);
  + while (responses.hasMoreElements()) {
  +
  + 

cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java

2003-08-22 Thread joerg
joerg   2003/08/22 14:33:56

  Modified:src/blocks/webdav/java/org/apache/cocoon/components/source/impl
WebDAVSource.java
  Log:
  unused variable removed
  
  Revision  ChangesPath
  1.6   +1 -2  
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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WebDAVSource.java 22 Aug 2003 12:23:41 -  1.5
  +++ WebDAVSource.java 22 Aug 2003 21:33:56 -  1.6
  @@ -765,7 +765,6 @@
   public SourceProperty getSourceProperty (String namespace, String name)
   throws SourceException {
   
  -  Vector sourceproperties = new Vector();
 DOMParser parser = null;
 String xml = ;
 Enumeration props= null;
  
  
  


cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java

2003-07-27 Thread gianugo
gianugo 2003/07/27 13:53:39

  Modified:src/blocks/webdav/java/org/apache/cocoon/components/source/impl
WebDAVSource.java
  Log:
  Making a better implementation on validity stuff. There are still some
  issues, though, with caching pipelines.
  
  Revision  ChangesPath
  1.4   +37 -10
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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WebDAVSource.java 27 Jul 2003 12:56:16 -  1.3
  +++ WebDAVSource.java 27 Jul 2003 20:53:39 -  1.4
  @@ -83,7 +83,7 @@
   
   /**
*  A source implementation to get access to WebDAV repositories. Use it
  - *  as webdav://[host][:port]/path[?principal=userpassword=password].
  + *  as webdav://[usr]:[EMAIL PROTECTED]:port]/path.
*
*  @author a href=mailto:[EMAIL PROTECTED]Guido Casper/a
*  @author a href=mailto:[EMAIL PROTECTED]Gianugo Rabellino/a
  @@ -109,6 +109,7 @@
   private String password;
   
   private SourceValidity validity = null;
  +private long cachedLastModificationDate;
   private SourceCredential sourcecredential = null;
   
   private WebdavResource resource = null;
  @@ -220,9 +221,9 @@
   return bi;
   }
   } catch (HttpException he) {
  -throw new SourceException(Could not get WebDAV resource, he);
  +throw new SourceException(Could not get WebDAV resource  + 
getSecureURI(), he);
   } catch (Exception e) {
  -throw new SourceException(Could not get WebDAV resource, e);
  +throw new SourceException(Could not get WebDAV resource + 
getSecureURI(), e);
   }
   }
   
  @@ -239,6 +240,14 @@
return webdav://  +  this.systemId.substring(7);
   
   }
  +
  +/**
  + * Return the URI securely, without username and password
  + * 
  + */
  +protected String getSecureURI() {
  + return webdav://  +  this.systemId.substring(7);  
  +}
   
   /**
*  Get the Validity object. This can either wrap the last modification
  @@ -247,10 +256,21 @@
*  codenull/code is returned.
*/
   public SourceValidity getValidity() {
  -if (this.validity == null)
  -this.validity =
  -new TimeStampValidity(this.resource.getGetLastModified());
  -return this.validity;
  + // TODO: Implementation taken from HttpClientSource, who took it from 
URLSource: time for a separate impl?
  + final long lm = getLastModified();
  +
  + if ( lm  0 )
  + {
  + if ( lm == cachedLastModificationDate )
  + {
  + return validity;
  + }
  +
  + cachedLastModificationDate = lm;
  + validity = new TimeStampValidity( lm );
  + return validity;
  + }
  + return null;
   }
   
   /**
  @@ -626,7 +646,13 @@
* @see org.apache.excalibur.source.ModifiableSource#delete()
*/
   public void delete() throws SourceException {
  -// TODO Auto-generated method stub
  + try {
  +this.resource.deleteMethod();
  +} catch (HttpException e) {
  + throw new SourceException(Unable to delete source:  + 
getSecureURI(), e);
  +} catch (IOException e) {
  + throw new SourceException(Unable to delete source:  + 
getSecureURI(), e);
  +}
   }
   
   /**
  @@ -638,10 +664,11 @@
try {
   resource.mkcolMethod();
   } catch (HttpException e) {
  -throw new SourceException(Unable to create collection(s), e);
  +throw new SourceException(Unable to create collection(s)  + 
getSecureURI(), e);
   } catch (IOException e) {
  -throw new SourceException(Unable to create collection(s), e); 
 
  +throw new SourceException(Unable to create collection(s)  + 
getSecureURI(), e);
   }
   }
  +
   
   }
  
  
  


cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java

2003-07-14 Thread cziegeler
cziegeler2003/07/14 09:06:21

  Modified:src/java/org/apache/cocoon/components/pipeline/impl
AbstractCachingProcessingPipeline.java
   src/java/org/apache/cocoon/caching CachedResponse.java
   src/blocks/webdav/java/org/apache/cocoon/components/source/impl
WebDAVSource.java
  Log:
  Cleaning up code
  
  Revision  ChangesPath
  1.8   +3 -3  
cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
  
  Index: AbstractCachingProcessingPipeline.java
  ===
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AbstractCachingProcessingPipeline.java11 Jul 2003 08:59:03 -  1.7
  +++ AbstractCachingProcessingPipeline.java14 Jul 2003 16:06:20 -  1.8
  @@ -518,7 +518,7 @@
   new Date(responseExpires.longValue()));
   }
   this.cachedResponse = response.getResponse();
  -this.cachedLastModified = response.lastModified;
  +this.cachedLastModified = response.getLastModified();
   return;
   } else {
   if (this.getLogger().isDebugEnabled()) {
  @@ -602,7 +602,7 @@
   }
   // we are valid, ok that's it
   this.cachedResponse = response.getResponse();
  -this.cachedLastModified = response.lastModified;
  +this.cachedLastModified = response.getLastModified();
   } else {
   if (this.getLogger().isDebugEnabled()) {
   this.getLogger().debug(validatePipeline: cached content is 
invalid for ' + environment.getURI() + '.);
  
  
  
  1.3   +13 -9 
cocoon-2.1/src/java/org/apache/cocoon/caching/CachedResponse.java
  
  Index: CachedResponse.java
  ===
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/caching/CachedResponse.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CachedResponse.java   3 May 2003 18:34:41 -   1.2
  +++ CachedResponse.java   14 Jul 2003 16:06:21 -  1.3
  @@ -68,10 +68,10 @@
   public final class CachedResponse
   implements Serializable {
   
  -private SourceValidity[] validityObjects;
  -private byte[]   response;
  -private Long expires;
  -public  final long   lastModified;
  +private final SourceValidity[] validityObjects;
  +private final byte[]   response;
  +private Longexpires;
  +private final longlastModified;
   
   /**
* Create a new entry for the cache.
  @@ -82,10 +82,7 @@
*/
   public CachedResponse(SourceValidity[] validityObjects,
 byte[]   response) {
  -this.validityObjects = validityObjects;
  -this.response = response;
  -this.expires = null;
  -this.lastModified = this.setLastModified(System.currentTimeMillis());
  +this(validityObjects, response, null);
   }
   
   /**
  @@ -147,4 +144,11 @@
   // Return the value rounded to the nearest second.
   return lastModified - (lastModified % 1000);
   }
  +/**
  + * @return the last modified time 
  + */
  +public long getLastModified() {
  +return lastModified;
  +}
  +
   }
  
  
  
  1.2   +1 -2  
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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WebDAVSource.java 11 Jul 2003 10:32:35 -  1.1
  +++ WebDAVSource.java 14 Jul 2003 16:06:21 -  1.2
  @@ -68,7 +68,6 @@
   import org.apache.cocoon.components.source.RestrictableSource;
   import org.apache.cocoon.components.source.helpers.SourceCredential;
   import org.apache.cocoon.components.source.helpers.SourcePermission;
  -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.Source;