cziegeler 2003/08/07 00:07:02
Modified: src/java/org/apache/cocoon/components/source SitemapSource.java Log: Applying modified patch for bug 14348 from Marco Rolappe Revision Changes Path 1.2 +41 -11 cocoon-2.0/src/java/org/apache/cocoon/components/source/SitemapSource.java Index: SitemapSource.java =================================================================== RCS file: /home/cvs/cocoon-2.0/src/java/org/apache/cocoon/components/source/SitemapSource.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SitemapSource.java 9 Mar 2003 00:02:32 -0000 1.1 +++ SitemapSource.java 7 Aug 2003 07:07:02 -0000 1.2 @@ -50,6 +50,13 @@ */ package org.apache.cocoon.components.source; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.util.Map; + import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.cocoon.ProcessingException; @@ -60,11 +67,11 @@ import org.apache.cocoon.components.pipeline.CacheableEventPipeline; import org.apache.cocoon.components.pipeline.EventPipeline; import org.apache.cocoon.components.pipeline.StreamPipeline; +import org.apache.cocoon.components.store.Store; import org.apache.cocoon.environment.Environment; import org.apache.cocoon.environment.ModifiableSource; import org.apache.cocoon.environment.Source; import org.apache.cocoon.environment.wrapper.EnvironmentWrapper; -import org.apache.cocoon.util.HashUtil; import org.apache.cocoon.xml.AbstractXMLConsumer; import org.apache.cocoon.xml.ContentHandlerWrapper; import org.apache.cocoon.xml.XMLConsumer; @@ -77,13 +84,6 @@ import org.xml.sax.SAXException; import org.xml.sax.ext.LexicalHandler; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; -import java.net.MalformedURLException; - /** * Description of a source which is defined by a pipeline. * @@ -303,9 +303,38 @@ { CacheableEventPipeline cep = (CacheableEventPipeline)this.eventPipeline; PipelineCacheKey pck = cep.generateKey(this.environment); - Map validity = null; + // patch for 14348 + if (pck != null) { + final Store cache = (Store) this.manager.lookup(Store.TRANSIENT_CACHE); + + try { + final String cacheKey = pck.toString() + "/Timestamp"; + Object[] obj = (Object[])cache.get(cacheKey); + Long prevTimestamp = null; + Map prevValidity = null; + if ( obj != null ) { + prevTimestamp = (Long)obj[0]; + prevValidity = (Map)obj[1]; + } + if (prevTimestamp != null) { + this.lastModificationDate = prevTimestamp.longValue(); + } + + Map currValidity = cep.generateValidity(this.environment); + + if (prevValidity == null || !currValidity.equals(prevValidity)) { + // validity changed, update cached validity, timestamp and last modified + this.lastModificationDate = System.currentTimeMillis(); + obj = new Object[] {new Long (this.lastModificationDate), currValidity}; + cache.store(cacheKey, obj); + } + } finally { + this.manager.release(cache); + } + } + /* if (pck != null) { - validity = cep.generateValidity(this.environment); + Map validity = cep.generateValidity(this.environment); if (validity != null) { // the event pipeline is cacheable // now calculate a last modification date @@ -313,6 +342,7 @@ this.lastModificationDate = HashUtil.hash(hashKey); } } + */ } } else { if (redirectURL.indexOf(":") == -1) {