1 package org.apache.turbine.pipeline;
2
3
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 */
22
23
24 import java.io.IOException;
25
26 import org.apache.turbine.TurbineConstants;
27 import org.apache.turbine.util.RunData;
28 import org.apache.turbine.util.TurbineException;
29
30 /**
31 * Implements the RunData target portion of the "Turbine classic"
32 * processing pipeline (from the Turbine 2.x series).
33 *
34 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
35 * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
36 * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
37 * @author <a href="mailto:mikeh@apache.org">Mike Haberman</a>
38 * @author <a href="mailto:james@jamestaylor.org">James Taylor</a>
39 * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
40 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
41 * @version $Id: CleanUpValve.java 1706239 2015-10-01 13:18:35Z tv $
42 */
43 public class CleanUpValve
44 extends AbstractValve
45 {
46 /**
47 * Creates a new instance.
48 */
49 public CleanUpValve()
50 {
51 // empty constructor
52 }
53
54 /**
55 * @see org.apache.turbine.pipeline.Valve#invoke(PipelineData, ValveContext)
56 */
57 public void invoke(PipelineData pipelineData, ValveContext context)
58 throws IOException, TurbineException
59 {
60 try
61 {
62 cleanUp(pipelineData);
63 }
64 catch (Exception e)
65 {
66 throw new TurbineException(e);
67 }
68
69 // Pass control to the next Valve in the Pipeline
70 context.invokeNext(pipelineData);
71 }
72
73 /**
74 * Perform clean up after processing the request.
75 *
76 * @param pipelineData The run-time data.
77 */
78 protected void cleanUp(PipelineData pipelineData)
79 throws Exception
80 {
81 RunData data = getRunData(pipelineData);
82 // If a module has set data.acl = null, remove acl from
83 // the session.
84 if (data.getACL() == null)
85 {
86 try
87 {
88 data.getSession().removeAttribute
89 (TurbineConstants.ACL_SESSION_KEY);
90 }
91 catch (IllegalStateException invalidatedSession)
92 {
93 // Web was used to shut us down. Trying to clean up
94 // our stuff, but it's already been done for us.
95 }
96 }
97 }
98 }