cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2 changes.xml
Date Wed, 18 Dec 2002 08:09:24 GMT
cziegeler    2002/12/18 00:09:24

  Modified:    src/java/org/apache/cocoon/environment/http
                        HttpEnvironment.java
               src/java/org/apache/cocoon/reading ResourceReader.java
               .        changes.xml
  Log:
  Fixing bug 12915
    <action dev="CZ" type="fix" fixes-bug="12915">
      The resource reader now checks if for the same URI the same source is read
      in order to test the if-last-modified header. This behaviour can be turned
      of (for more performance) by the quick-modified-test.
    </action>
  
  Revision  Changes    Path
  1.20      +1 -6      xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
  
  Index: HttpEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- HttpEnvironment.java	5 Dec 2002 10:25:52 -0000	1.19
  +++ HttpEnvironment.java	18 Dec 2002 08:09:24 -0000	1.20
  @@ -239,15 +239,10 @@
        *         environment is not able to test it
        */
       public boolean isResponseModified(long lastModified) {
  -        // workaround for bug #12915
  -        // FIXME
  -        return true;
  -        /*
           long if_modified_since = this.request.getDateHeader("If-Modified-Since");
   
           this.response.setDateHeader("Last-Modified", lastModified);
           return (if_modified_since < lastModified);
  -        */
       }
   
       /**
  
  
  
  1.21      +34 -4     xml-cocoon2/src/java/org/apache/cocoon/reading/ResourceReader.java
  
  Index: ResourceReader.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/reading/ResourceReader.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ResourceReader.java	5 Dec 2002 10:32:58 -0000	1.20
  +++ ResourceReader.java	18 Dec 2002 08:09:24 -0000	1.21
  @@ -56,6 +56,7 @@
   import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.environment.Context;
   import org.apache.cocoon.environment.ObjectModelHelper;
  +import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Response;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.excalibur.source.Source;
  @@ -65,6 +66,7 @@
   
   import java.io.IOException;
   import java.io.InputStream;
  +import java.util.HashMap;
   import java.util.Map;
   
   /**
  @@ -82,19 +84,30 @@
    *           in miliseconds the resources can be cached by any proxy or browser
    *           between Cocoon2 and the requesting visitor.
    *       </dd>
  + *     <dt>&lt;quick-modified-test&gt;</dt>
  + *       <dd>This parameter is optional. This boolean parameter controlls the
  + *           last modified test. If set to true (default is false), only the
  + *           last modified of the current source is tested, but not if the
  + *           same source is used as last time.
  + *       </dd>
    *   </dl>
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
    * @version CVS $Id$
    */
  -public class ResourceReader
  +public final class ResourceReader
     extends AbstractReader
     implements CacheableProcessingComponent {
   
       /** The  source */
       private Source      inputSource;
   
  -
  +    /** The list of generated documents */
  +    private static final Map documents = new HashMap();
  +    
  +    /** quick test */
  +    private boolean quickTest;
  +    
       /**
        * Setup the reader.
        * The resource is opened to get an <code>InputStream</code>,
  @@ -103,6 +116,7 @@
       public void setup(SourceResolver resolver, Map objectModel, String src, Parameters
par)
       throws ProcessingException, SAXException, IOException {
           super.setup(resolver, objectModel, src, par);
  +        this.quickTest = par.getParameterAsBoolean("quick-modified-test", false);
           try {
               this.inputSource = resolver.resolveURI(src);
           } catch (SourceException se) {
  @@ -146,7 +160,17 @@
        *         possible to detect
        */
       public long getLastModified() {
  -        return this.inputSource.getLastModified();
  +    	if (this.quickTest) {
  +    		return this.inputSource.getLastModified();
  +    	}
  +        final Request request = ObjectModelHelper.getRequest(this.objectModel);
  +        final String systemId = (String)documents.get(request.getRequestURI());
  +        if (this.inputSource.getSystemId().equals(systemId)) {
  +            return this.inputSource.getLastModified();
  +        } else {
  +        	documents.remove(request.getRequestURI());
  +        	return 0;
  +        }
       }
   
       /**
  @@ -183,6 +207,12 @@
               inputStream.close();
               inputStream = null;
               out.flush();
  +            
  +            if (!this.quickTest) {
  +	            // if everything is ok, add this to the list of generated documents
  +	            final Request request = ObjectModelHelper.getRequest(this.objectModel);
  +	            documents.put(request.getRequestURI(), this.inputSource.getSystemId());
  +            }
           } catch (SourceException se) {
               throw SourceUtil.handle("Exception during resolving of read source.", se);
           }
  
  
  
  1.310     +6 -1      xml-cocoon2/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/changes.xml,v
  retrieving revision 1.309
  retrieving revision 1.310
  diff -u -r1.309 -r1.310
  --- changes.xml	17 Dec 2002 12:03:06 -0000	1.309
  +++ changes.xml	18 Dec 2002 08:09:24 -0000	1.310
  @@ -608,6 +608,11 @@
       properties which were not addressed in the http request (like unchecked
       checkboxes). This applies to session scope forms only.
     </action>
  +  <action dev="CZ" type="fix" fixes-bug="12915">
  +    The resource reader now checks if for the same URI the same source is read
  +    in order to test the if-last-modified header. This behaviour can be turned
  +    of (for more performance) by the quick-modified-test.
  +  </action>
   </release>
   <release version="2.0.4" date="December 06 2002">
     <action dev="SW" type="update">
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message