001package 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
024import java.io.IOException;
025
026import org.apache.commons.configuration.Configuration;
027import org.apache.turbine.TurbineConstants;
028import org.apache.turbine.annotation.TurbineConfiguration;
029import org.apache.turbine.annotation.TurbineLoader;
030import org.apache.turbine.modules.Action;
031import org.apache.turbine.modules.ActionLoader;
032import org.apache.turbine.util.TurbineException;
033
034/**
035 * Implements the action portion of the "Turbine classic" processing
036 * pipeline (from the Turbine 2.x series).
037 *
038 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
039 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
040 * @version $Id: DefaultACLCreationValve.java 1706239 2015-10-01 13:18:35Z tv $
041 */
042public class DefaultACLCreationValve
043    extends AbstractValve
044{
045    /** Injected loader instance */
046    @TurbineLoader( Action.class )
047    private ActionLoader actionLoader;
048
049    /** Injected configuration instance */
050    @TurbineConfiguration
051    private Configuration config;
052
053    /**
054     * @see org.apache.turbine.pipeline.Valve#invoke(PipelineData, ValveContext)
055     */
056    @Override
057    public void invoke(PipelineData pipelineData, ValveContext context)
058        throws IOException, TurbineException
059    {
060        try
061        {
062            // Put the Access Control List into the RunData object, so
063            // it is easily available to modules.  It is also placed
064            // into the session for serialization.  Modules can null
065            // out the ACL to force it to be rebuilt based on more
066            // information.
067            actionLoader.exec(
068                    pipelineData, config.getString(
069                            TurbineConstants.ACTION_ACCESS_CONTROLLER_KEY,
070                            TurbineConstants.ACTION_ACCESS_CONTROLLER_DEFAULT));
071        }
072        catch (Exception e)
073        {
074            throw new TurbineException(e);
075        }
076
077        // Pass control to the next Valve in the Pipeline
078        context.invokeNext(pipelineData);
079    }
080}