001 package org.apache.turbine.pipeline;
002
003
004 /*
005 * Licensed to the Apache Software Foundation (ASF) under one
006 * or more contributor license agreements. See the NOTICE file
007 * distributed with this work for additional information
008 * regarding copyright ownership. The ASF licenses this file
009 * to you under the Apache License, Version 2.0 (the
010 * "License"); you may not use this file except in compliance
011 * with the License. You may obtain a copy of the License at
012 *
013 * http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing,
016 * software distributed under the License is distributed on an
017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
018 * KIND, either express or implied. See the License for the
019 * specific language governing permissions and limitations
020 * under the License.
021 */
022
023
024 import java.io.IOException;
025
026 import org.apache.turbine.util.RunData;
027 import org.apache.turbine.util.TurbineException;
028 import org.apache.turbine.util.security.AccessControlList;
029
030 /**
031 * Implements the RunData target portion of the "Turbine classic"
032 * processing pipeline (from the Turbine 2.x series).
033 *
034 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
035 * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
036 * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
037 * @author <a href="mailto:mikeh@apache.org">Mike Haberman</a>
038 * @author <a href="mailto:james@jamestaylor.org">James Taylor</a>
039 * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
040 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
041 * @version $Id: CleanUpValve.java 757213 2009-03-22 16:43:31Z tv $
042 */
043 public class CleanUpValve
044 extends AbstractValve
045 {
046 /**
047 * Creates a new instance.
048 */
049 public CleanUpValve()
050 {
051 // empty constructor
052 }
053
054 /**
055 * @see org.apache.turbine.Valve#invoke(RunData, ValveContext)
056 */
057 public void invoke(PipelineData pipelineData, ValveContext context)
058 throws IOException, TurbineException
059 {
060 try
061 {
062 cleanUp(pipelineData);
063 }
064 catch (Exception e)
065 {
066 throw new TurbineException(e);
067 }
068
069 // Pass control to the next Valve in the Pipeline
070 context.invokeNext(pipelineData);
071 }
072
073 /**
074 * Perform clean up after processing the request.
075 *
076 * @param data The run-time data.
077 */
078 protected void cleanUp(PipelineData pipelineData)
079 throws Exception
080 {
081 RunData data = getRunData(pipelineData);
082 // If a module has set data.acl = null, remove acl from
083 // the session.
084 if (data.getACL() == null)
085 {
086 try
087 {
088 data.getSession().removeAttribute
089 (AccessControlList.SESSION_KEY);
090 }
091 catch (IllegalStateException invalidatedSession)
092 {
093 // Web was used to shut us down. Trying to clean up
094 // our stuff, but it's already been done for us.
095 }
096 }
097 }
098 }