sylvain     01/07/18 05:22:20

  Modified:    .        changes.xml
               src/org/apache/cocoon/components/language/markup/sitemap/java
                        sitemap.xsl
               src/org/apache/cocoon/sitemap AbstractSitemap.java
  Log:
  In http environment, try to reset the response prior to executing the handle-errors 
pipeline.
  
  Revision  Changes    Path
  1.20      +6 -1      xml-cocoon2/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/changes.xml,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- changes.xml       2001/07/12 13:47:30     1.19
  +++ changes.xml       2001/07/18 12:22:19     1.20
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes
  -  $Id: changes.xml,v 1.19 2001/07/12 13:47:30 cziegeler Exp $
  +  $Id: changes.xml,v 1.20 2001/07/18 12:22:19 sylvain Exp $
   -->
   
   <changes title="History of Changes">
  @@ -21,10 +21,15 @@
     <person name="Ricardo Rocha" email="[EMAIL PROTECTED]" id="RR"/>
     <person name="Paul Russell" email="[EMAIL PROTECTED]" id="PR"/>
     <person name="Davanum Srinivas" email="[EMAIL PROTECTED]" id="DM"/>
  +  <person name="Sylvain Wallez" email="[EMAIL PROTECTED]" id="SW"/>
     <person name="Carsten Ziegeler" email="[EMAIL PROTECTED]" id="CZ"/>
    </devs>
   
    <release version="2.1-dev" date="@date@">
  +  <action dev="SW" type="add">
  +    In http environment, reset the response if it hasn't been committed
  +    before executing the handle-errors pipeline.
  +  </action>
     <action dev="CZ" type="add">
       Added reloading of jar files. When cocoon is reloaded by specifying
       cocoon-reload parameter, the class-path is new build and used.
  
  
  
  1.28      +2 -1      
xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl
  
  Index: sitemap.xsl
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- sitemap.xsl       2001/07/12 18:33:29     1.27
  +++ sitemap.xsl       2001/07/18 12:22:19     1.28
  @@ -127,7 +127,7 @@
        *
        * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Giacomo Pati&lt;/a&gt;
        * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Berin Loritsch&lt;/a&gt;
  -     * @version CVS $Id: sitemap.xsl,v 1.27 2001/07/12 18:33:29 bloritsch Exp $
  +     * @version CVS $Id: sitemap.xsl,v 1.28 2001/07/18 12:22:19 sylvain Exp $
        */
       public class <xsl:value-of select="@file-name"/> extends AbstractSitemap {
         static final String LOCATION = "<xsl:value-of select="translate(@file-path, 
'/', '.')"/>.<xsl:value-of select="@file-name"/>";
  @@ -516,6 +516,7 @@
               EventPipeline eventPipeline = null;
               StreamPipeline pipeline = null;
               try {
  +              tryResetResponse(objectModel);
                 eventPipeline = 
(EventPipeline)this.manager.lookup(EventPipeline.ROLE);
                 pipeline = (StreamPipeline)this.manager.lookup(StreamPipeline.ROLE);
                 pipeline.setEventPipeline(eventPipeline);
  
  
  
  1.15      +33 -1     xml-cocoon2/src/org/apache/cocoon/sitemap/AbstractSitemap.java
  
  Index: AbstractSitemap.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/AbstractSitemap.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AbstractSitemap.java      2001/07/07 11:43:34     1.14
  +++ AbstractSitemap.java      2001/07/18 12:22:19     1.15
  @@ -28,12 +28,14 @@
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.framework.thread.ThreadSafe;
  +import org.apache.cocoon.Constants;
   import org.apache.cocoon.acting.Action;
   import org.apache.cocoon.components.classloader.RepositoryClassLoader;
   import org.apache.cocoon.components.pipeline.EventPipeline;
   import org.apache.cocoon.components.pipeline.StreamPipeline;
   import org.apache.cocoon.components.url.URLFactory;
   import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.http.HttpResponse;
   import org.apache.cocoon.generation.Generator;
   import org.apache.cocoon.matching.Matcher;
   import org.apache.cocoon.reading.Reader;
  @@ -49,7 +51,7 @@
    * Base class for generated <code>Sitemap</code> classes
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
  - * @version CVS $Revision: 1.14 $ $Date: 2001/07/07 11:43:34 $
  + * @version CVS $Revision: 1.15 $ $Date: 2001/07/18 12:22:19 $
    */
   public abstract class AbstractSitemap extends AbstractLoggable implements Sitemap, 
Disposable, ThreadSafe {
       private Context context;
  @@ -380,5 +382,35 @@
           if (this.selectors != null) {
               manager.release((Component)this.selectors);
           }
  +    }
  +    
  +    /**
  +      Reset the response if possible. This allows error handlers to have
  +      a higher chance to produce clean output if the pipeline that raised
  +      the error has already output some data.
  +      
  +      @param objectModel the object model
  +      @return true if the response was successfully reset
  +      */
  +    
  +    protected boolean tryResetResponse(Map objectModel)
  +    {
  +        try {
  +            Object responseObj = objectModel.get(Constants.RESPONSE_OBJECT);
  +            if (responseObj instanceof HttpResponse) {
  +                HttpResponse response = (HttpResponse)responseObj;
  +                if (! response.isCommitted()) {
  +                    response.reset();
  +                    getLogger().debug("Response successfully reset");
  +                    return true;
  +                }
  +            }
  +        } catch(Exception e) {
  +            // Log the error, but don't transmit it
  +            getLogger().warn("Problem resetting response", e);
  +        }
  +        
  +        getLogger().debug("Response wasn't reset");
  +        return false;
       }
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to