Coverage Report - org.apache.turbine.modules.screens.Error
 
Classes in this File Line Coverage Branch Coverage Complexity
Error
0%
0/35
0%
0/10
3,5
 
 1  
 package org.apache.turbine.modules.screens;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.util.Iterator;
 23  
 import java.util.Map;
 24  
 
 25  
 import org.apache.ecs.ConcreteElement;
 26  
 import org.apache.ecs.html.B;
 27  
 import org.apache.ecs.html.H3;
 28  
 import org.apache.ecs.html.H4;
 29  
 import org.apache.ecs.html.PRE;
 30  
 import org.apache.ecs.html.TD;
 31  
 import org.apache.ecs.html.TR;
 32  
 import org.apache.ecs.html.Table;
 33  
 import org.apache.turbine.modules.Screen;
 34  
 import org.apache.turbine.pipeline.PipelineData;
 35  
 import org.apache.turbine.util.RunData;
 36  
 
 37  
 /**
 38  
  * This is a sample Error Screen module.
 39  
  *
 40  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 41  
  * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
 42  
  * @version $Id: Error.java 938645 2010-04-27 20:57:51Z tv $
 43  
  */
 44  0
 public class Error extends Screen
 45  
 {
 46  
     /**
 47  
      * Build screen.
 48  
      *
 49  
      * @deprecated Use PipelineData version instead.
 50  
      * @param data Turbine information.
 51  
      * @return ConcreteElement the page with all the error information.
 52  
      * @throws Exception a generic exception.
 53  
      */
 54  
     public ConcreteElement doBuild(RunData data) throws Exception
 55  
     {
 56  0
         data.setTitle("There has been an error!");
 57  
 
 58  0
         Table table = new Table().setBorder(0);
 59  0
         boolean hasValues = false;
 60  0
         for (Iterator it = data.getParameters().keySet().iterator();
 61  0
              it.hasNext();)
 62  
         {
 63  0
             String key = (String) it.next();
 64  0
             String value = data.getParameters().getString(key);
 65  0
             TR tr =
 66  
                 new TR().addElement(
 67  
                     new TD().addElement(new B(key))).addElement(
 68  
                     new TD().addElement(" = " + value));
 69  0
             table.addElement(tr);
 70  0
             hasValues = true;
 71  0
         }
 72  
 
 73  0
         Table table2 = new Table().setBorder(0);
 74  0
         Map varDebug = data.getDebugVariables();
 75  
 
 76  0
         boolean hasValues2 = false;
 77  0
         for (Iterator i = varDebug.keySet().iterator(); i.hasNext();)
 78  
         {
 79  0
             String key = (String) i.next();
 80  0
             String value = varDebug.get(key).toString();
 81  0
             TR tr =
 82  
                 new TR().addElement(
 83  
                     new TD().addElement(new B(key))).addElement(
 84  
                     new TD().addElement(" = " + value));
 85  0
             table2.addElement(tr);
 86  0
             hasValues2 = true;
 87  0
         }
 88  
 
 89  0
         data.getPage().getBody().addElement(
 90  
             new H3(
 91  
                 data.getTitle()
 92  
                     + " Please review the exception below "
 93  
                     + "for more information."));
 94  
 
 95  0
         if (hasValues)
 96  
         {
 97  0
             data.getPage().getBody().addElement(
 98  
                 new H4().addElement("Get/Post Data:"));
 99  0
             data.getPage().getBody().addElement(table);
 100  
         }
 101  
 
 102  0
         if (hasValues2)
 103  
         {
 104  0
             data.getPage().getBody().addElement(
 105  
                 new H4().addElement("Debugging Data:"));
 106  0
             data.getPage().getBody().addElement(table2);
 107  
         }
 108  
 
 109  0
         String trace = data.getStackTrace();
 110  0
         if (trace != null)
 111  
         {
 112  0
             data
 113  
                 .getPage()
 114  
                 .getBody()
 115  
                 .addElement(new H4().addElement("The exception is:"))
 116  
                 .addElement(new PRE(trace))
 117  
                 .addElement(new PRE(data.getStackTraceException().toString()));
 118  
         }
 119  0
         return null;
 120  
     }
 121  
 
 122  
 
 123  
     /**
 124  
      * Build screen.
 125  
      *
 126  
      * @param data Turbine information.
 127  
      * @return ConcreteElement the page with all the error information.
 128  
      * @throws Exception a generic exception.
 129  
      */
 130  
     public ConcreteElement doBuild(PipelineData pipelineData) throws Exception
 131  
     {
 132  0
         RunData data = getRunData(pipelineData);
 133  0
         return doBuild(data);
 134  
     }
 135  
 }