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 Changes Path
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 -0000 1.3
+++ WebDAVSource.java 27 Jul 2003 20:53:39 -0000 1.4
@@ -83,7 +83,7 @@
/**
* A source implementation to get access to WebDAV repositories. Use it
- * as webdav://[host][:port]/path[?principal=user&password=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 @@
* <code>null</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);
}
}
+
}