KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > sitemap > SitemapRedirector


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.sitemap;
17
18 import org.apache.cocoon.environment.Environment;
19 import org.apache.cocoon.environment.Redirector;
20 import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
21
22 import java.io.IOException JavaDoc;
23
24 /**
25  * Wrapper for sitemap redirection
26  *
27  * @deprecated This class has been used by the old sitemap engine
28  *
29  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
30  * @version CVS $Id: SitemapRedirector.java 30932 2004-07-29 17:35:38Z vgritsenko $
31  */

32 public class SitemapRedirector implements Redirector {
33     private boolean hasRedirected = false;
34     private Environment e;
35
36     /**
37      * Constructor with environment--so redirection happens as expected
38      */

39     public SitemapRedirector(Environment e) {
40         this.e = e;
41     }
42
43     /**
44      * Perform actual redirection
45      */

46     public void redirect(boolean sessionMode, String JavaDoc url) throws IOException JavaDoc {
47         e.redirect(sessionMode, url);
48         this.hasRedirected = true;
49     }
50     
51     public void globalRedirect(boolean sessionMode, String JavaDoc url) throws IOException JavaDoc {
52         if (e instanceof EnvironmentWrapper) {
53             ((EnvironmentWrapper)e).globalRedirect(sessionMode,url);
54         } else {
55             e.redirect(sessionMode, url);
56         }
57         this.hasRedirected = true;
58     }
59
60     public void sendStatus(int sc) {
61         e.setStatus(sc);
62         this.hasRedirected = true;
63     }
64
65     /**
66      * Perform check on whether redirection has occured or not
67      */

68     public boolean hasRedirected() {
69         return this.hasRedirected;
70     }
71 }
72
Popular Tags