01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.sitemap;
18:
19: import org.apache.cocoon.environment.Environment;
20: import org.apache.cocoon.environment.Redirector;
21: import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
22:
23: import java.io.IOException;
24:
25: /**
26: * Wrapper for sitemap redirection
27: *
28: * @deprecated This class has been used by the old sitemap engine
29: *
30: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
31: * @version CVS $Id: SitemapRedirector.java 433543 2006-08-22 06:22:54Z crossley $
32: */
33: public class SitemapRedirector implements Redirector {
34: private boolean hasRedirected = false;
35: private Environment e;
36:
37: /**
38: * Constructor with environment--so redirection happens as expected
39: */
40: public SitemapRedirector(Environment e) {
41: this .e = e;
42: }
43:
44: /**
45: * Perform actual redirection
46: */
47: public void redirect(boolean sessionMode, String url)
48: throws IOException {
49: e.redirect(sessionMode, url);
50: this .hasRedirected = true;
51: }
52:
53: public void globalRedirect(boolean sessionMode, String url)
54: throws IOException {
55: if (e instanceof EnvironmentWrapper) {
56: ((EnvironmentWrapper) e).globalRedirect(sessionMode, url);
57: } else {
58: e.redirect(sessionMode, url);
59: }
60: this .hasRedirected = true;
61: }
62:
63: public void sendStatus(int sc) {
64: e.setStatus(sc);
65: this .hasRedirected = true;
66: }
67:
68: /**
69: * Perform check on whether redirection has occured or not
70: */
71: public boolean hasRedirected() {
72: return this.hasRedirected;
73: }
74: }
|