sylvain     02/03/27 07:13:40

  Modified:    .        changes.xml todo.xml
               src/java/org/apache/cocoon/components/treeprocessor/sitemap
                        ActSetNode.java ActTypeNode.java PipelinesNode.java
                        PipelinesNodeBuilder.java RedirectToURINode.java
               src/java/org/apache/cocoon/environment Redirector.java
               src/java/org/apache/cocoon/environment/commandline
                        AbstractCommandLineEnvironment.java
               src/java/org/apache/cocoon/environment/http
                        HttpEnvironment.java
               src/java/org/apache/cocoon/environment/wrapper
                        EnvironmentWrapper.java
  Log:
  Handle internal redirects with "cocoon:"
  
  Revision  Changes    Path
  1.133     +12 -2     xml-cocoon2/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/changes.xml,v
  retrieving revision 1.132
  retrieving revision 1.133
  diff -u -r1.132 -r1.133
  --- changes.xml       26 Mar 2002 12:46:58 -0000      1.132
  +++ changes.xml       27 Mar 2002 15:13:40 -0000      1.133
  @@ -1,10 +1,10 @@
  -<?xml version="1.0"?>
  +<?xml version="1.0"?>
   
   <!DOCTYPE changes PUBLIC "-//APACHE//DTD Changes V1.0//EN" 
"src/documentation/xdocs/dtd/changes-v10.dtd">
   
   <!--
     History of Cocoon changes
  -  $Id: changes.xml,v 1.132 2002/03/26 12:46:58 nicolaken Exp $
  +  $Id: changes.xml,v 1.133 2002/03/27 15:13:40 sylvain Exp $
   -->
   
   <changes title="History of Changes">
  @@ -35,6 +35,16 @@
    </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="SW" type="add">
  +    Handle request forwarding (aka internal redirects) using the "cocoon:"
  +    pseudo-protocol : writing &lt;map:redirect-to uri="cocoon:/foo.bar"/&gt; makes
  +    a recursive call on the current sitemap without going back to the browser
  +    (as usual, "cocoon://foo.bar" uses the root sitemap). This also keeps any data
  +    that have been stored as request attributes.
  +
  +    Note: this is only available in the interpreted sitemap engine for now, and
  +    will come soon on the compiled engine.
  +  </action>
     <action dev="NKB" type="fix">
       Patch (Bug#: 7251) submitted by Marcus Crafter 
       ([EMAIL PROTECTED]):
  
  
  
  1.28      +7 -7      xml-cocoon2/todo.xml
  
  Index: todo.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/todo.xml,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- todo.xml  20 Mar 2002 14:28:24 -0000      1.27
  +++ todo.xml  27 Mar 2002 15:13:40 -0000      1.28
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes
  -  $Id: todo.xml,v 1.27 2002/03/20 14:28:24 nicolaken Exp $
  +  $Id: todo.xml,v 1.28 2002/03/27 15:13:40 sylvain Exp $
   -->
   
   
  @@ -84,15 +84,15 @@
    </actions>
   
    <actions priority="medium">
  -
  + 
     <action context="code">
  -   Make a guide on how to upgrade Cocoon,and see how this can be eased.
  +   Remove all useless blank strings in XSP-generated code that hinder performances.
  +   This should be configurable (through an attribute?) to be able to keep them when
  +   needed.
     </action>
  -  
  +
     <action context="code">
  -   Check if the map:redirect-to should handle all urls including the
  -   special cocoon: protocol. This would require making the redirect
  -   for these urls on the server.
  +   Make a guide on how to upgrade Cocoon,and see how this can be eased.
     </action>
   
     <action context="code">
  
  
  
  1.2       +1 -2      
xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActSetNode.java
  
  Index: ActSetNode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActSetNode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ActSetNode.java   5 Mar 2002 08:26:23 -0000       1.1
  +++ ActSetNode.java   27 Mar 2002 15:13:40 -0000      1.2
  @@ -64,7 +64,6 @@
   import org.apache.cocoon.components.pipeline.StreamPipeline;
   
   import org.apache.cocoon.sitemap.PatternException;
  -import org.apache.cocoon.sitemap.SitemapRedirector;
   
   import org.apache.cocoon.components.treeprocessor.InvokeContext;
   import org.apache.cocoon.components.treeprocessor.MapStackResolver;
  @@ -79,7 +78,7 @@
    * Handles &lt;map:act type="..."&gt; (action-sets calls are handled by {@link 
ActSetNode}).
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Id: ActSetNode.java,v 1.1 2002/03/05 08:26:23 sylvain Exp $
  + * @version CVS $Id: ActSetNode.java,v 1.2 2002/03/27 15:13:40 sylvain Exp $
    */
   
   public class ActSetNode extends SimpleParentProcessingNode
  
  
  
  1.2       +8 -8      
xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActTypeNode.java
  
  Index: ActTypeNode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActTypeNode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ActTypeNode.java  5 Mar 2002 08:26:23 -0000       1.1
  +++ ActTypeNode.java  27 Mar 2002 15:13:40 -0000      1.2
  @@ -57,10 +57,10 @@
   
   import org.apache.cocoon.acting.Action;
   import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.Redirector;
   import org.apache.cocoon.environment.SourceResolver;
   
   import org.apache.cocoon.sitemap.PatternException;
  -import org.apache.cocoon.sitemap.SitemapRedirector;
   
   import org.apache.cocoon.components.treeprocessor.InvokeContext;
   import org.apache.cocoon.components.treeprocessor.MapStackResolver;
  @@ -75,7 +75,7 @@
    * Handles &lt;map:act type="..."&gt; (action-sets calls are handled by {@link 
ActSetNode}).
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Id: ActTypeNode.java,v 1.1 2002/03/05 08:26:23 sylvain Exp $
  + * @version CVS $Id: ActTypeNode.java,v 1.2 2002/03/27 15:13:40 sylvain Exp $
    */
   
   public class ActTypeNode extends SimpleSelectorProcessingNode
  @@ -111,12 +111,12 @@
         throws Exception {
   
           // Prepare data needed by the action
  -        Map               objectModel    = env.getObjectModel();
  -        SitemapRedirector redirector     = PipelinesNode.getRedirector(env);
  -        SourceResolver    resolver       = getSourceResolver(objectModel);
  -        List              mapStack       = context.getMapStack();
  -        String            resolvedSource = source.resolve(mapStack);
  -        Parameters        resolvedParams = 
MapStackResolver.buildParameters(this.parameters, mapStack);
  +        Map            objectModel    = env.getObjectModel();
  +        Redirector     redirector     = PipelinesNode.getRedirector(env);
  +        SourceResolver resolver       = getSourceResolver(objectModel);
  +        List           mapStack       = context.getMapStack();
  +        String         resolvedSource = source.resolve(mapStack);
  +        Parameters     resolvedParams = 
MapStackResolver.buildParameters(this.parameters, mapStack);
   
           Map actionResult;
   
  
  
  
  1.3       +19 -5     
xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNode.java
  
  Index: PipelinesNode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNode.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PipelinesNode.java        12 Mar 2002 15:51:02 -0000      1.2
  +++ PipelinesNode.java        27 Mar 2002 15:13:40 -0000      1.3
  @@ -56,14 +56,16 @@
   
   import org.apache.cocoon.ResourceNotFoundException;
   
  -import org.apache.cocoon.sitemap.SitemapRedirector;
  +import org.apache.cocoon.environment.Redirector;
   
   import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.ForwardRedirector;
   import org.apache.cocoon.components.pipeline.EventPipeline;
   import org.apache.cocoon.components.pipeline.StreamPipeline;
   import org.apache.cocoon.components.treeprocessor.SimpleParentProcessingNode;
   import org.apache.cocoon.components.treeprocessor.ProcessingNode;
   import org.apache.cocoon.components.treeprocessor.InvokeContext;
  +import org.apache.cocoon.Processor;
   
   import java.util.*;
   import org.apache.avalon.framework.component.ComponentException;
  @@ -72,7 +74,7 @@
    * Handles &lt;map:pipelines&gt;
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Id: PipelinesNode.java,v 1.2 2002/03/12 15:51:02 sylvain Exp $
  + * @version CVS $Id: PipelinesNode.java,v 1.3 2002/03/27 15:13:40 sylvain Exp $
    */
   
   public final class PipelinesNode extends SimpleParentProcessingNode
  @@ -81,6 +83,12 @@
       private static final String REDIRECTOR_ATTR = "sitemap:redirector";
   
       private ComponentManager manager;
  +    
  +    private Processor processor;
  +
  +    public PipelinesNode(Processor processor) {
  +        this.processor = processor;
  +    }
   
       /**
        * Keep the component manager used everywhere in the tree so that we can
  @@ -98,8 +106,8 @@
           super.setChildren(nodes);
       }
   
  -    public static SitemapRedirector getRedirector(Environment env) {
  -        return (SitemapRedirector)env.getAttribute(REDIRECTOR_ATTR);
  +    public static Redirector getRedirector(Environment env) {
  +        return (Redirector)env.getAttribute(REDIRECTOR_ATTR);
       }
   
       /**
  @@ -113,7 +121,13 @@
           // Recompose context (and pipelines) to the local component manager
           context.recompose(this.manager);
   
  -        SitemapRedirector redirector = new SitemapRedirector(env);
  +        // Build a redirector
  +        boolean internal = context.isInternalRequest();
  +        ForwardRedirector redirector = new ForwardRedirector(
  +            env, this.processor, this.manager,
  +            (internal ? context.getEventPipeline() : null),
  +            (internal ? context.getStreamPipeline() : null));
  +        this.setupLogger(redirector);
   
           Map objectModel = env.getObjectModel();
   
  
  
  
  1.2       +2 -2      
xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNodeBuilder.java
  
  Index: PipelinesNodeBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNodeBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PipelinesNodeBuilder.java 5 Mar 2002 08:26:23 -0000       1.1
  +++ PipelinesNodeBuilder.java 27 Mar 2002 15:13:40 -0000      1.2
  @@ -61,13 +61,13 @@
    * Builds a &lt;map:pipelines&gt;
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Id: PipelinesNodeBuilder.java,v 1.1 2002/03/05 08:26:23 sylvain 
Exp $
  + * @version CVS $Id: PipelinesNodeBuilder.java,v 1.2 2002/03/27 15:13:40 sylvain 
Exp $
    */
   
   public class PipelinesNodeBuilder extends ContainerNodeBuilder implements 
ThreadSafe {
   
       public ProcessingNode buildNode(Configuration config) throws Exception {
  -        PipelinesNode node = new PipelinesNode();
  +        PipelinesNode node = new PipelinesNode(this.treeBuilder.getProcessor());
           this.treeBuilder.setupNode(node, config);
   
           ProcessingNode[] children = buildChildNodes(config);
  
  
  
  1.2       +2 -2      
xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/RedirectToURINode.java
  
  Index: RedirectToURINode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/RedirectToURINode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RedirectToURINode.java    5 Mar 2002 08:26:23 -0000       1.1
  +++ RedirectToURINode.java    27 Mar 2002 15:13:40 -0000      1.2
  @@ -66,7 +66,7 @@
   /**
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Id: RedirectToURINode.java,v 1.1 2002/03/05 08:26:23 sylvain Exp $
  + * @version CVS $Id: RedirectToURINode.java,v 1.2 2002/03/27 15:13:40 sylvain Exp $
    */
   
   public class RedirectToURINode extends AbstractProcessingNode {
  @@ -88,7 +88,7 @@
               getLogger().info("Redirecting to '" + resolvedURI + "' at " + 
this.getLocation());
           }
   
  -        env.redirect (this.keepSession, resolvedURI);
  +        PipelinesNode.getRedirector(env).redirect(this.keepSession, resolvedURI);
   
           return true;
       }
  
  
  
  1.5       +9 -3      
xml-cocoon2/src/java/org/apache/cocoon/environment/Redirector.java
  
  Index: Redirector.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/Redirector.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Redirector.java   22 Feb 2002 07:03:49 -0000      1.4
  +++ Redirector.java   27 Mar 2002 15:13:40 -0000      1.5
  @@ -50,13 +50,14 @@
   */
   package org.apache.cocoon.environment;
   
  +import org.apache.cocoon.ProcessingException;
   import java.io.IOException;
   
   /**
    * Interface for an redirector abstraction
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Davanum Srinivas</a>
  - * @version CVS $Id: Redirector.java,v 1.4 2002/02/22 07:03:49 cziegeler Exp $
  + * @version CVS $Id: Redirector.java,v 1.5 2002/03/27 15:13:40 sylvain Exp $
    */
   
   public interface Redirector {
  @@ -64,7 +65,12 @@
       /**
        * Redirect to the given URL
        */
  -    void redirect(boolean sessionmode, String url) throws IOException;
  -    void globalRedirect(boolean sessionmode, String url) throws IOException;
  +    void redirect(boolean sessionmode, String url) throws IOException, 
ProcessingException;
  +    void globalRedirect(boolean sessionmode, String url) throws IOException, 
ProcessingException;
  +    
  +    /**
  +     * Was one of the redirection methods called ?
  +     */
  +    boolean hasRedirected();
   }
   
  
  
  
  1.7       +9 -1      
xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java
  
  Index: AbstractCommandLineEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractCommandLineEnvironment.java       22 Feb 2002 07:03:50 -0000      1.6
  +++ AbstractCommandLineEnvironment.java       27 Mar 2002 15:13:40 -0000      1.7
  @@ -69,7 +69,7 @@
    * This environment is used to save the requested file to disk.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
  - * @version CVS $Id: AbstractCommandLineEnvironment.java,v 1.6 2002/02/22 07:03:50 
cziegeler Exp $
  + * @version CVS $Id: AbstractCommandLineEnvironment.java,v 1.7 2002/03/27 15:13:40 
sylvain Exp $
    */
   
   public abstract class AbstractCommandLineEnvironment
  @@ -79,6 +79,7 @@
       protected String contentType;
       protected OutputStream stream;
       protected int contentLength;
  +    protected boolean hasRedirected = false;
   
       public AbstractCommandLineEnvironment(String uri,
                                             String view,
  @@ -96,6 +97,9 @@
        */
       public void redirect(boolean sessionmode, String newURL)
       throws IOException {
  +
  +        this.hasRedirected = true;
  +
           if (sessionmode) {
               CommandLineSession.getSession(true);
           }
  @@ -154,6 +158,10 @@
                   if (redirectSource != null) redirectSource.recycle();
               }
           }
  +    }
  +    
  +    public boolean hasRedirected() {
  +        return this.hasRedirected;
       }
   
       /**
  
  
  
  1.12      +11 -1     
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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- HttpEnvironment.java      22 Mar 2002 02:01:31 -0000      1.11
  +++ HttpEnvironment.java      27 Mar 2002 15:13:40 -0000      1.12
  @@ -68,7 +68,7 @@
   
   /**
    * @author ?
  - * @version CVS $Id: HttpEnvironment.java,v 1.11 2002/03/22 02:01:31 vgritsenko Exp 
$
  + * @version CVS $Id: HttpEnvironment.java,v 1.12 2002/03/27 15:13:40 sylvain Exp $
    */
   public class HttpEnvironment extends AbstractEnvironment implements Redirector {
   
  @@ -90,6 +90,9 @@
   
       /** Cache content type as there is no getContentType() in reponse object */
       private String contentType = null;
  +    
  +    /** Did we redirect ? */
  +    private boolean hasRedirected = false;
   
       /**
        * Constructs a HttpEnvironment object from a HttpServletRequest
  @@ -156,6 +159,9 @@
               getLogger().debug("redirect: something's broken, request = null");
               return;
           }
  +        
  +        this.hasRedirected = true;
  +        
           // check if session mode shall be activated
           if (sessionmode) {
               // The session
  @@ -190,6 +196,10 @@
   
           getLogger().debug("Sending redirect to '" + redirect + "'");
           this.response.sendRedirect (redirect);
  +    }
  +
  +    public boolean hasRedirected() {
  +        return this.hasRedirected;
       }
   
       /**
  
  
  
  1.10      +3 -5      
xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
  
  Index: EnvironmentWrapper.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- EnvironmentWrapper.java   22 Feb 2002 07:03:51 -0000      1.9
  +++ EnvironmentWrapper.java   27 Mar 2002 15:13:40 -0000      1.10
  @@ -72,14 +72,12 @@
    * contains a <code>RequestWrapper</code> object.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version $Id: EnvironmentWrapper.java,v 1.9 2002/02/22 07:03:51 cziegeler Exp $
  + * @version $Id: EnvironmentWrapper.java,v 1.10 2002/03/27 15:13:40 sylvain Exp $
    */
  -public final class EnvironmentWrapper
  -extends AbstractEnvironment
  -implements Environment {
  +public class EnvironmentWrapper extends AbstractEnvironment implements Environment {
   
       /** The wrapped environment */
  -    private Environment environment;
  +    protected Environment environment;
   
       /** The object model */
       private Map objectModel;
  
  
  

----------------------------------------------------------------------
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