    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.Turbine;
    027    import org.apache.turbine.TurbineConstants;
    028    import org.apache.turbine.modules.Action;
    029    import org.apache.turbine.modules.ActionLoader;
    030    import org.apache.turbine.services.assemblerbroker.TurbineAssemblerBroker;
    031    import org.apache.turbine.util.TurbineException;
    032
    033    /**
    034     * Implements the action portion of the "Turbine classic" processing
    035     * pipeline (from the Turbine 2.x series).
    036     *
    037     * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    038     * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
    039     * @version $Id: DefaultACLCreationValve.java 758254 2009-03-25 13:41:02Z tv $
    040     */
    041    public class DefaultACLCreationValve
    042        extends AbstractValve
    043    {
    044        private ActionLoader actionLoader;
    045
    046        /**
    047         * Here we can setup objects that are thread safe and can be
    048         * reused. We setup the session validator and the access
    049         * controller.
    050         */
    051        public DefaultACLCreationValve()
    052            throws Exception
    053        {
    054            // empty constructor
    055        }
    056
    057        /**
    058         * Initialize this valve for use in a pipeline.
    059         *
    060         * @see org.apache.turbine.pipeline.AbstractValve#initialize()
    061         */
    062        public void initialize() throws Exception
    063        {
    064            super.initialize();
    065
    066            this.actionLoader = (ActionLoader)TurbineAssemblerBroker.getLoader(Action.NAME);
    067        }
    068
    069        /**
    070         * @see org.apache.turbine.Valve#invoke(RunData, ValveContext)
    071         */
    072        public void invoke(PipelineData pipelineData, ValveContext context)
    073            throws IOException, TurbineException
    074        {
    075            try
    076            {
    077                // Put the Access Control List into the RunData object, so
    078                // it is easily available to modules.  It is also placed
    079                // into the session for serialization.  Modules can null
    080                // out the ACL to force it to be rebuilt based on more
    081                // information.
    082                actionLoader.exec(
    083                        pipelineData, Turbine.getConfiguration().getString(
    084                                TurbineConstants.ACTION_ACCESS_CONTROLLER_KEY,
    085                                TurbineConstants.ACTION_ACCESS_CONTROLLER_DEFAULT));
    086            }
    087            catch (Exception e)
    088            {
    089                throw new TurbineException(e);
    090            }
    091
    092            // Pass control to the next Valve in the Pipeline
    093            context.invokeNext(pipelineData);
    094        }
    095    }