Coverage Report - org.apache.turbine.pipeline.DefaultSessionValidationValve
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultSessionValidationValve
81%
9/11
N/A
1,667
 
 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.Turbine;
 27  
 import org.apache.turbine.TurbineConstants;
 28  
 import org.apache.turbine.modules.Action;
 29  
 import org.apache.turbine.modules.ActionLoader;
 30  
 import org.apache.turbine.services.assemblerbroker.TurbineAssemblerBroker;
 31  
 import org.apache.turbine.util.TurbineException;
 32  
 
 33  
 /**
 34  
  * Implements the action portion of the "Turbine classic" processing
 35  
  * pipeline (from the Turbine 2.x series).
 36  
  *
 37  
  * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>\
 38  
  * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
 39  
  * @version $Id: DefaultSessionValidationValve.java 758254 2009-03-25 13:41:02Z tv $
 40  
  */
 41  
 public class DefaultSessionValidationValve
 42  
     extends AbstractValve
 43  
 {
 44  
     private ActionLoader actionLoader;
 45  
 
 46  
     public DefaultSessionValidationValve()
 47  
         throws Exception
 48  4
     {
 49  
         // empty constructor
 50  4
     }
 51  
 
 52  
     /**
 53  
      * Initialize this valve for use in a pipeline.
 54  
      * 
 55  
      * @see org.apache.turbine.pipeline.AbstractValve#initialize()
 56  
      */
 57  
     public void initialize() throws Exception
 58  
     {
 59  98
         super.initialize();
 60  
         
 61  98
         this.actionLoader = (ActionLoader)TurbineAssemblerBroker.getLoader(Action.NAME);
 62  98
     }
 63  
 
 64  
     /**
 65  
      * @see org.apache.turbine.Valve#invoke(RunData, ValveContext)
 66  
      */
 67  
     public void invoke(PipelineData pipelineData, ValveContext context)
 68  
         throws IOException, TurbineException
 69  
     {
 70  
         try
 71  
         {
 72  
             // This is where the validation of the Session information
 73  
             // is performed if the user has not logged in yet, then
 74  
             // the screen is set to be Login. This also handles the
 75  
             // case of not having a screen defined by also setting the
 76  
             // screen to Login. If you want people to go to another
 77  
             // screen other than Login, you need to change that within
 78  
             // TurbineResources.properties...screen.homepage; or, you
 79  
             // can specify your own SessionValidator action.
 80  6
             actionLoader.exec(pipelineData,
 81  
                     Turbine.getConfiguration().getString(
 82  
                             TurbineConstants.ACTION_SESSION_VALIDATOR_KEY,
 83  
                             TurbineConstants.ACTION_SESSION_VALIDATOR_DEFAULT));
 84  
         }
 85  0
         catch (Exception e)
 86  
         {
 87  0
             throw new TurbineException(e);
 88  6
         }
 89  
 
 90  
         // Pass control to the next Valve in the Pipeline
 91  6
         context.invokeNext(pipelineData);
 92  4
     }
 93  
 }