cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r149077 - in cocoon/branches/BRANCH_2_1_X: . src/java/org/apache/cocoon/components/source/impl src/java/org/apache/cocoon/components/treeprocessor/sitemap src/java/org/apache/cocoon/environment/wrapper
Date Sat, 29 Jan 2005 22:17:27 GMT
Author: sylvain
Date: Sat Jan 29 14:17:27 2005
New Revision: 149077

URL: http://svn.apache.org/viewcvs?view=rev&rev=149077
Log:
fix bug #33178 - handling of environment context when returning from a pass-through mounted
sitemap
Modified:
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java
   cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java?view=diff&rev=149077&p1=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java&r1=149076&p2=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java&r2=149077
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
Sat Jan 29 14:17:27 2005
@@ -331,7 +331,6 @@
             this.processKey = CocoonComponentManager.startProcessing(this.environment);
             this.processingPipeline = this.processor.buildPipeline(this.environment);
             this.pipelineProcessor = CocoonComponentManager.getLastProcessor(this.environment);
-            this.environment.changeToLastContext();
 
             String redirectURL = this.environment.getRedirectURL();
             if (redirectURL == null) {

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java?view=diff&rev=149077&p1=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java&r1=149076&p2=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java&r2=149077
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
Sat Jan 29 14:17:27 2005
@@ -30,8 +30,6 @@
 import org.apache.cocoon.components.treeprocessor.TreeProcessor;
 import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
 import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
-import org.apache.cocoon.environment.wrapper.MutableEnvironmentFacade;
 import org.apache.commons.lang.BooleanUtils;
 
 /**
@@ -101,7 +99,8 @@
         String oldContext   = env.getContext();
         Object oldPassThrough = env.getAttribute(COCOON_PASS_THROUGH);
         env.setAttribute(COCOON_PASS_THROUGH, BooleanUtils.toBooleanObject(passThrough));
-        boolean overwriteLastContext = false;
+
+        boolean pipelineWasBuilt = false;
         
         try {
             env.changeContext(resolvedPrefix, resolvedSource);
@@ -111,29 +110,23 @@
                 ProcessingPipeline pp = processor.buildPipeline(env);
                 if (pp != null) {
                     context.setProcessingPipeline( pp );
-                    return true;
+                    pipelineWasBuilt = true;
                 } else {
-                    overwriteLastContext = true;
-                    return false;
+                    pipelineWasBuilt = false;
                 }
             } else {
                 // Processor will create its own pipelines
-                return processor.process(env);
+                pipelineWasBuilt = processor.process(env);
             }
         } finally {
-            // Restore context
-            env.setContext(oldPrefix, oldURI, oldContext);
-            if ( overwriteLastContext ) {
-                EnvironmentWrapper wrapper = null;
-                if ( env instanceof EnvironmentWrapper ) {
-                    wrapper = (EnvironmentWrapper)env;
-                } else if ( env instanceof MutableEnvironmentFacade ) {
-                    wrapper = ((MutableEnvironmentFacade)env).getDelegate();
-                }
-                if ( wrapper != null ) {
-                    wrapper.changeLastContextToCurrent();
-                }                
+            // We restore the context only if no pipeline was built. This allows the pipeline
+            // environment to be left unchanged when we go back to ancestor processors.
+            // If no pipeline was built, we restore the context, so that the current processor
+            // continues executing the sitemap in the correct environment.
+            if (!pipelineWasBuilt) {
+                env.setContext(oldPrefix, oldURI, oldContext);
             }
+            
             if (oldPassThrough != null) {
                 env.setAttribute(COCOON_PASS_THROUGH, oldPassThrough);
             } else {
@@ -145,6 +138,8 @@
             // Recompose pipelines which may have been recomposed by subsitemap
             // context.recompose(this.manager);
         }
+        
+        return pipelineWasBuilt;
     }
 
     private synchronized TreeProcessor getProcessor(String source, String prefix) throws
Exception {

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java?view=diff&rev=149077&p1=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java&r1=149076&p2=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java&r2=149077
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
Sat Jan 29 14:17:27 2005
@@ -58,15 +58,6 @@
     /** The request object */
     protected Request request;
 
-    /** The last context */
-    protected String lastContext;
-
-    /** The last prefix */
-    protected String lastPrefix;
-
-    /** The last uri */
-    protected String lastURI;
-
     /** The stream to output to */
     protected OutputStream outputStream;
     
@@ -422,33 +413,6 @@
             setURIPrefix(prefix);
         }
         this.uris = uris;
-        this.lastURI = uris;
-        this.lastContext = this.context;
-        this.lastPrefix = this.prefix.toString();
-    }
-
-    public void changeContext(String prefix, String context)
-    throws IOException {
-        super.changeContext(prefix, context);
-        this.lastContext = this.context;
-        this.lastPrefix  = this.prefix.toString();
-        this.lastURI     = this.uris;
-    }
-
-    public void changeLastContextToCurrent() {
-        this.lastContext = this.context;
-        this.lastPrefix  = this.prefix.toString();
-        this.lastURI     = this.uris;
-    }
-
-    /**
-     * Change the current context to the last one set by changeContext()
-     * and return last processor
-     */
-    public void changeToLastContext() {
-        this.setContext(this.lastContext);
-        this.setURIPrefix(this.lastPrefix);
-        this.uris = this.lastURI;
     }
 
     /**

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java?view=diff&rev=149077&p1=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java&r1=149076&p2=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java&r2=149077
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java
Sat Jan 29 14:17:27 2005
@@ -44,10 +44,6 @@
 
     private EnvironmentWrapper env;
 
-    // Track the first values set for prefix and uri
-    private String prefix;
-    private String uri;
-
     public MutableEnvironmentFacade(EnvironmentWrapper env) {
         this.env = env;
     }
@@ -64,23 +60,12 @@
     // EnvironmentWrapper-specific method (SW:still have to understand why SitemapSource
needs them)
     public void setURI(String prefix, String uri) {
         this.env.setURI(prefix, uri);
-
-        if (this.uri == null) {
-            // First call : keep the values to restore them on the wrapped
-            // enviromnent in reset()
-            this.prefix = prefix;
-            this.uri = uri;
-        }
     }
 
     public void setOutputStream(OutputStream os) {
         this.env.setOutputStream(os);
     }
 
-    public void changeToLastContext() {
-        this.env.changeToLastContext();
-    }
-
     // Move this to the Environment interface ?
     public String getRedirectURL() {
         return this.env.getRedirectURL();
@@ -88,11 +73,6 @@
 
     public void reset() {
         this.env.reset();
-        // TODO - If we remove the line below, do we break something
-        //        else again? If we leave it in, the SitemapSource
-        //        object is unusable after a call to getInputStream()
-        //        or toSAX() :(
-        //this.env.setURI(this.uri, this.prefix);
     }
     //----------------------------------
 

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?view=diff&rev=149077&p1=cocoon/branches/BRANCH_2_1_X/status.xml&r1=149076&p2=cocoon/branches/BRANCH_2_1_X/status.xml&r2=149077
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml	Sat Jan 29 14:17:27 2005
@@ -205,8 +205,8 @@
    <action dev="JH" type="fix" fixes-bug="33097">
     Fixed caching of i18n bundles when using multiple locations.
    </action>
-   <action dev="CZ" type="fix" fixes-bug="33178" due-to="Jean-Baptiste Quenot" due-to-email="jbq@anyware-tech.com">
-     Fixing uri handling when the pass-through feature for mounting sitemaps is used.
+   <action dev="SW" type="fix" fixes-bug="33178" due-to="Jean-Baptiste Quenot" due-to-email="jbq@anyware-tech.com">
+     Fix handling of environment context when returning from a pass-through sitemap mount.
    </action>
    <action dev="CZ" type="add" fixes-bug="33287" due-to="Jens Maukisch" due-to-email="jmaukisch@s-und-n.de">
      Portal Block: Add portal tools framework contribution.

Mime
View raw message