cziegeler    2003/10/30 04:31:05

  Modified:    src/java/org/apache/cocoon/environment Environment.java
                        ForwardRedirector.java EnvironmentHelper.java
               src/java/org/apache/cocoon/environment/wrapper
                        EnvironmentWrapper.java
               src/java/org/apache/cocoon/environment/http
                        HttpEnvironment.java
  Log:
  Updating environment handling
  
  Revision  Changes    Path
  1.11      +3 -2      
cocoon-2.2/src/java/org/apache/cocoon/environment/Environment.java
  
  Index: Environment.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/Environment.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Environment.java  30 Oct 2003 12:20:45 -0000      1.10
  +++ Environment.java  30 Oct 2003 12:31:05 -0000      1.11
  @@ -93,7 +93,8 @@
       /**
        * Redirect to the given URL
        */
  -    void redirect(String url, boolean permanent) throws IOException;
  +    void redirect(String url, boolean global, boolean permanent) 
  +    throws IOException;
   
       /**
        * Set the content type of the generated resource
  
  
  
  1.12      +2 -5      
cocoon-2.2/src/java/org/apache/cocoon/environment/ForwardRedirector.java
  
  Index: ForwardRedirector.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/ForwardRedirector.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ForwardRedirector.java    30 Oct 2003 12:20:45 -0000      1.11
  +++ ForwardRedirector.java    30 Oct 2003 12:31:05 -0000      1.12
  @@ -55,7 +55,6 @@
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.treeprocessor.TreeProcessor;
  -import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
   
   /**
    * A <code>Redirector</code> that handles forward redirects, i.e. internal
  @@ -125,10 +124,8 @@
           // FIXME : how to handle global redirect to cocoon: ?
           if (url.startsWith("cocoon:")) {
               cocoonRedirect(url);
  -        } else if (env instanceof EnvironmentWrapper) {
  -            ((EnvironmentWrapper)env).globalRedirect(sessionMode,url);
           } else {
  -            
EnvironmentHelper.getCurrentProcessor().getEnvironmentHelper().redirect(this.env,
 sessionMode, url);
  +            
EnvironmentHelper.getCurrentProcessor().getEnvironmentHelper().globalRedirect(this.env,
 sessionMode, url);
           }
           this.hasRedirected = true;
       }
  
  
  
  1.9       +15 -7     
cocoon-2.2/src/java/org/apache/cocoon/environment/EnvironmentHelper.java
  
  Index: EnvironmentHelper.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/EnvironmentHelper.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- EnvironmentHelper.java    30 Oct 2003 12:20:45 -0000      1.8
  +++ EnvironmentHelper.java    30 Oct 2003 12:31:05 -0000      1.9
  @@ -287,15 +287,22 @@
       }
       
       public void redirect(Environment env, 
  -                                boolean sessionmode, 
  -                                String newURL) 
  +                         boolean sessionmode, 
  +                         String newURL) 
       throws IOException {
  -        this.doRedirect(env, sessionmode, newURL, false);
  +        this.doRedirect(env, sessionmode, newURL, false, false);
  +    }
  +
  +    public void globalRedirect(Environment env, 
  +                               boolean sessionmode, 
  +                               String newURL) 
  +    throws IOException {
  +        this.doRedirect(env, sessionmode, newURL, false, true);
       }
   
       public void permanentRedirect(Environment env, boolean sessionmode, 
String newURL) 
       throws IOException {
  -        this.doRedirect(env, sessionmode, newURL, true);
  +        this.doRedirect(env, sessionmode, newURL, true, false);
       }
   
      /**
  @@ -304,7 +311,8 @@
      protected void doRedirect(Environment env, 
                                boolean sessionmode, 
                                String newURL, 
  -                             boolean permanent) 
  +                             boolean permanent,
  +                             boolean global) 
       throws IOException {
           final Request request = 
ObjectModelHelper.getRequest(env.getObjectModel());
           // check if session mode shall be activated
  @@ -337,7 +345,7 @@
           }
           // redirect
           final Response response = 
ObjectModelHelper.getResponse(env.getObjectModel());
  -        env.redirect(newURL, permanent);
  +        env.redirect(newURL, global, permanent);
       }
   
       /**
  
  
  
  1.14      +5 -19     
cocoon-2.2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
  
  Index: EnvironmentWrapper.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- EnvironmentWrapper.java   29 Oct 2003 18:58:06 -0000      1.13
  +++ EnvironmentWrapper.java   30 Oct 2003 12:31:05 -0000      1.14
  @@ -277,26 +277,12 @@
       /**
        * Redirect the client to a new URL is not allowed
        */
  -    public void redirect(boolean sessionmode, String newURL)
  +    public void redirect(String newURL, boolean global, boolean permanent)
       throws IOException {
  -        this.redirectURL = newURL;
  -
  -        // check if session mode shall be activated
  -        if (sessionmode) {
  -            // get session from request, or create new session
  -            request.getSession(true);
  -        }
  -    }
  -
  -    /**
  -     * Redirect in the first non-wrapped environment
  -     */
  -    public void globalRedirect(boolean sessionmode, String newURL)
  -    throws IOException {
  -        if (environment instanceof EnvironmentWrapper) {
  -            ((EnvironmentWrapper)environment).globalRedirect(sessionmode, 
newURL);
  +        if ( !global ) {
  +            this.redirectURL = newURL;
           } else {
  -            environment.redirect(sessionmode,newURL);
  +            this.environment.redirect(newURL, global, permanent);
           }
       }
   
  
  
  
  1.15      +8 -18     
cocoon-2.2/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
  
  Index: HttpEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- HttpEnvironment.java      30 Oct 2003 12:20:45 -0000      1.14
  +++ HttpEnvironment.java      30 Oct 2003 12:31:05 -0000      1.15
  @@ -85,9 +85,6 @@
       /** Cache content type as there is no getContentType() in reponse object 
*/
       private String contentType;
   
  -    /** Did we redirect ? */
  -    private boolean hasRedirected = false;
  -
       /**
        * Constructs a HttpEnvironment object from a HttpServletRequest
        * and HttpServletResponse objects
  @@ -148,16 +145,13 @@
         }
       }
   
  -    public void redirect(String newURL, boolean permanent) throws 
IOException {
  -        doRedirect(newURL, permanent);
  -    }
  -
  -   /**
  -    *  Redirect the client to new URL 
  -    */
  -    private void doRedirect(String newURL, boolean permanent) throws 
IOException {
  -        this.hasRedirected = true;
  -
  +    /**
  +     *  Redirect the client to new URL 
  +     */
  +    public void redirect(String newURL, 
  +                         boolean global, 
  +                         boolean permanent) 
  +    throws IOException {
           // redirect
           String redirect = this.response.encodeRedirectURL(newURL);
   
  @@ -182,10 +176,6 @@
           } else {
               this.response.sendRedirect (redirect);
           }
  -    }
  -
  -    public boolean hasRedirected() {
  -        return this.hasRedirected;
       }
   
       /**
  
  
  

Reply via email to