cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r517729 - in /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline: ./ impl/
Date Tue, 13 Mar 2007 15:21:37 GMT
Author: gkossakowski
Date: Tue Mar 13 08:21:36 2007
New Revision: 517729

URL: http://svn.apache.org/viewvc?view=rev&rev=517729
Log:
Making pipelines more HTTP-compliant
Now pipelines will set approporiate status code in (hopefully) every case.
Also Last-Modified headers are produced in all cases.

Modified:
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java?view=diff&rev=517729&r1=517728&r2=517729
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
(original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
Tue Mar 13 08:21:36 2007
@@ -24,6 +24,8 @@
 import java.util.NoSuchElementException;
 import java.util.StringTokenizer;
 
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.avalon.excalibur.pool.Recyclable;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.parameters.ParameterException;
@@ -546,6 +548,8 @@
             handleException(e);
         }
 
+        //Request has been succesfully processed, set approporiate status code
+        environment.setStatus(HttpServletResponse.SC_OK);
         return true;
     }
 
@@ -656,7 +660,9 @@
         } catch (Exception e) {
             handleException(e);
         }
-
+        
+        //Request has been succesfully processed, set approporiate status code
+        environment.setStatus(HttpServletResponse.SC_OK);
         return true;
     }
 

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java?view=diff&rev=517729&r1=517728&r2=517729
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
(original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
Tue Mar 13 08:21:36 2007
@@ -23,6 +23,8 @@
 import java.util.ArrayList;
 import java.util.Date;
 
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
@@ -91,8 +93,10 @@
 
     protected Store transientStore = null;
 
-    /** Abstract method defined in subclasses */
-    protected abstract void cacheResults(Environment environment,
+    /** Abstract method defined in subclasses 
+     * @return <u>complete</u> cached response or <code>null</code><br>
+     *         See issue COCOON-2009 for discussion*/
+    protected abstract CachedResponse cacheResults(Environment environment,
             OutputStream os)
         throws Exception;
 
@@ -365,7 +369,14 @@
                 // Now that we have processed the pipeline,
                 // we do the actual caching
                 //
-                cacheResults(environment,os);
+                CachedResponse completeCachedResponse = cacheResults(environment,os);
+                
+                if (completeCachedResponse != null) {
+                	//Dirty work-around for setting Last-Modified header as there is no appoporiate
method
+                	//org.apache.cocoon.environment.http.HttpEnvironment.isResponseModified
will set it and the result of
+                	//the actual check is neither meaningful nor important here
+                	environment.isResponseModified(completeCachedResponse.getLastModified());
+                }
 
             } catch (Exception e) {
                 handleException(e);
@@ -373,6 +384,8 @@
                 releaseLock(this.toCacheKey);
             }
 
+            //Request has been succesfully processed, set approporiate status code
+            environment.setStatus(HttpServletResponse.SC_OK);
             return true;
         }
 
@@ -897,7 +910,9 @@
         } catch (Exception e) {
             handleException(e);
         }
-
+        
+        //Request has been succesfully processed, set approporiate status code
+        environment.setStatus(HttpServletResponse.SC_OK);
         return true;
     }
 

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java?view=diff&rev=517729&r1=517728&r2=517729
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
(original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
Tue Mar 13 08:21:36 2007
@@ -166,7 +166,8 @@
     /**
      * Cache longest cacheable path plus cache points.
      */
-    protected void cacheResults(Environment environment, OutputStream os)  throws Exception
{
+    protected CachedResponse cacheResults(Environment environment, OutputStream os)  throws
Exception {
+    	CachedResponse completeCachedResponse = null;
 
         if (this.toCacheKey != null) {
             if ( this.cacheCompleteResponse ) {
@@ -179,6 +180,7 @@
                 response.setContentType(environment.getContentType());
                 this.cache.store(this.toCacheKey.copy(),
                                  response);
+                completeCachedResponse = response;
                 //
                 // Scan back along the pipelineCacheKey for
                 // for any cachepoint(s)
@@ -232,6 +234,7 @@
 
             }
         }
+        return completeCachedResponse;
     }
 
     /**

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java?view=diff&rev=517729&r1=517728&r2=517729
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
(original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
Tue Mar 13 08:21:36 2007
@@ -43,7 +43,7 @@
     /**
     * Cache longest cacheable key
     */
-    protected void cacheResults(Environment environment, OutputStream os)  throws Exception
{
+    protected CachedResponse cacheResults(Environment environment, OutputStream os)  throws
Exception {
         if (this.toCacheKey != null) {
             // See if there is an expires object for this resource.
             Long expiresObj = (Long) environment.getObjectModel().get(ObjectModelHelper.EXPIRES_OBJECT);
@@ -61,7 +61,9 @@
             }
 
             this.cache.store(this.toCacheKey, response);
+            return response;
         }
+        return null;
     }
 
     /**

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java?view=diff&rev=517729&r1=517728&r2=517729
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java
(original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java
Tue Mar 13 08:21:36 2007
@@ -39,6 +39,8 @@
 import java.io.OutputStream;
 import java.util.Map;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * This pipeline implementation caches the complete content for a defined
  * period of time (expires).
@@ -165,6 +167,8 @@
             handleException(e);
         }
 
+        //Request has been succesfully processed, set approporiate status code
+        environment.setStatus(HttpServletResponse.SC_OK);
         return true;
     }
 
@@ -352,6 +356,8 @@
             handleException(e);
         }
 
+        //Request has been succesfully processed, set approporiate status code
+        environment.setStatus(HttpServletResponse.SC_OK);
         return true;
     }
 }



Mime
View raw message