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 1773378 2016-12-09 13:19:59Z 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 @Override
58 public void invoke(PipelineData pipelineData, ValveContext context)
59 throws IOException, TurbineException
60 {
61 try
62 {
63 cleanUp(pipelineData);
64 }
65 catch (Exception e)
66 {
67 throw new TurbineException(e);
68 }
69
70 // Pass control to the next Valve in the Pipeline
71 context.invokeNext(pipelineData);
72 }
73
74 /**
75 * Perform clean up after processing the request.
76 *
77 * @param pipelineData The run-time data.
78 */
79 protected void cleanUp(PipelineData pipelineData)
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 }