Coverage Report - org.apache.turbine.modules.screens.error.InvalidState
 
Classes in this File Line Coverage Branch Coverage Complexity
InvalidState
0%
0/15
N/A
1
 
 1  
 package org.apache.turbine.modules.screens.error;
 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 org.apache.ecs.ElementContainer;
 25  
 import org.apache.ecs.html.A;
 26  
 import org.apache.fulcrum.parser.ParameterParser;
 27  
 import org.apache.turbine.modules.Screen;
 28  
 import org.apache.turbine.pipeline.PipelineData;
 29  
 import org.apache.turbine.util.RunData;
 30  
 import org.apache.turbine.util.uri.TurbineURI;
 31  
 
 32  
 /**
 33  
  * Users will get this screen if the screen on their browser is in an
 34  
  * invalid state.  For example, if they hit "Back" or "Reload" and
 35  
  * then try to submit old form data.
 36  
  *
 37  
  * If you want one of your screens to check for invalid state
 38  
  * then add a hidden form field called "_session_access_counter"
 39  
  * with the value currently stored in the session.  The
 40  
  * SessionValidator action will check to see if it is an old
 41  
  * value and redirect you to this screen.
 42  
  *
 43  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 44  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 45  
  * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
 46  
  * @version $Id: InvalidState.java 1773378 2016-12-09 13:19:59Z tv $
 47  
  */
 48  0
 public class InvalidState
 49  
     extends Screen
 50  
 {
 51  
     /**
 52  
      * Build the Screen.
 53  
      *
 54  
      * @param pipelineData Turbine information.
 55  
      * @throws Exception a generic exception.
 56  
      */
 57  
     @Override
 58  
     public String doBuild(PipelineData pipelineData)
 59  
             throws Exception
 60  
     {
 61  0
         RunData data = getRunData(pipelineData);
 62  0
         ElementContainer body = new ElementContainer();
 63  0
         ElementContainer message = new ElementContainer();
 64  
 
 65  0
         StringBuilder sb = new StringBuilder();
 66  0
         sb.append("<b>There has been an error.</b>")
 67  
                 .append("<p>")
 68  
                 .append("- If you used the browser \"Back\" or \"Reload\"")
 69  
                 .append(" buttons please use the navigation buttons we provide")
 70  
                 .append(" within the screen.")
 71  
                 .append("<p>")
 72  
                 .append("Please click ");
 73  
 
 74  0
         message.addElement(sb.toString());
 75  
         ParameterParser pp;
 76  0
         pp = (ParameterParser) data.getUser().getTemp("prev_parameters");
 77  0
         pp.remove("_session_access_counter");
 78  
 
 79  0
         TurbineURI back = new TurbineURI(data,(String) data.getUser().getTemp("prev_screen"));
 80  0
         back.addPathInfo(pp);
 81  0
         message.addElement(new A().setHref(back.getRelativeLink()).addElement("here"));
 82  
 
 83  0
         message.addElement(" to return the the screen you were working on.");
 84  
 
 85  0
         body.addElement(message);
 86  0
         return body.toString();
 87  
     }
 88  
 }