Coverage report

  %line %branch
org.apache.turbine.modules.navigations.DefaultBottomNavigation
0% 
0% 

 1  
 package org.apache.turbine.modules.navigations;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License")
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import java.util.Iterator;
 20  
 import java.util.Map;
 21  
 
 22  
 import org.apache.ecs.AlignType;
 23  
 import org.apache.ecs.ConcreteElement;
 24  
 import org.apache.ecs.ElementContainer;
 25  
 import org.apache.ecs.HtmlColor;
 26  
 import org.apache.ecs.html.B;
 27  
 import org.apache.ecs.html.BR;
 28  
 import org.apache.ecs.html.Font;
 29  
 import org.apache.ecs.html.Form;
 30  
 import org.apache.ecs.html.H4;
 31  
 import org.apache.ecs.html.HR;
 32  
 import org.apache.ecs.html.Input;
 33  
 import org.apache.ecs.html.PRE;
 34  
 import org.apache.ecs.html.TD;
 35  
 import org.apache.ecs.html.TR;
 36  
 import org.apache.ecs.html.Table;
 37  
 
 38  
 import org.apache.turbine.TurbineConstants;
 39  
 import org.apache.turbine.modules.Navigation;
 40  
 import org.apache.turbine.om.security.Permission;
 41  
 import org.apache.turbine.om.security.Role;
 42  
 import org.apache.turbine.util.RunData;
 43  
 import org.apache.turbine.util.uri.TurbineURI;
 44  
 
 45  
 /**
 46  
  * This is a sample navigation module.
 47  
  *
 48  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 49  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 50  
  * @version $Id: DefaultBottomNavigation.java 264148 2005-08-29 14:21:04Z henning $
 51  
  * @deprecated The use of ECS for the view is deprecated.
 52  
  * Use a templating solution.
 53  
  */
 54  0
 public class DefaultBottomNavigation extends Navigation
 55  
 {
 56  
     /** Specify whether to output detailed information */
 57  
     private static final boolean DEBUG = false;
 58  
     /** The string to display */
 59  0
     private static String txt =
 60  
         "Turbine - A Servlet Framework for building Secure Dynamic Websites.";
 61  
 
 62  
     /**
 63  
      * Build the Navigation.
 64  
      *
 65  
      * @param data Turbine information.
 66  
      * @return A ConcreteElement.
 67  
      * @throws Exception a generic exception.
 68  
      */
 69  
     public ConcreteElement doBuild(RunData data) throws Exception
 70  
     {
 71  
         Form form;
 72  0
         form = new Form(
 73  
             new TurbineURI(data,
 74  
                            TurbineConstants.SCREEN_DEFAULT_DEFAULT,
 75  
                            TurbineConstants.ACTION_LOGOUT_DEFAULT,
 76  
                            true).getRelativeLink(),
 77  
             Form.POST).addElement(new Input("SUBMIT", "Logout", "Logout"));
 78  
 
 79  0
         ElementContainer body = new ElementContainer()
 80  
                 .addElement(new HR().setSize(1).setNoShade(true))
 81  
                 .addElement(
 82  
                     new B().addElement(
 83  
                         new Font().setColor(HtmlColor.green).setSize(
 84  
                             2).addElement(
 85  
                             txt)))
 86  
                 .addElement(form);
 87  
 
 88  
         if (DEBUG && data.getUser() != null)
 89  
         {
 90  
             TD perm = new TD().setVAlign(AlignType.TOP);
 91  
             TD temp = new TD().setVAlign(AlignType.TOP);
 92  
 
 93  
             perm.addElement("Perm values:").addElement(new BR());
 94  
             for (Iterator it = data.getUser().getPermStorage().keySet().iterator();
 95  
                  it.hasNext();)
 96  
             {
 97  
                 String key = (String) it.next();
 98  
                 String value = data.getUser().getPerm(key).toString();
 99  
                 perm.addElement(key + "=" + value).addElement(new BR());
 100  
             }
 101  
 
 102  
             temp.addElement("Temp values:").addElement(new BR());
 103  
             for (Iterator it = data.getUser().getTempStorage().keySet().iterator();
 104  
                  it.hasNext();)
 105  
             {
 106  
                 String key = (String) it.next();
 107  
                 String value = data.getUser().getTemp(key).toString();
 108  
                 temp.addElement(key + "=" + value).addElement(new BR());
 109  
             }
 110  
 
 111  
             body.addElement(new BR()).addElement(class="keyword">new BR()).addElement(
 112  
                 new Table().setBorder(2).setCellPadding(10).addElement(
 113  
                     new TR().addElement(perm).addElement(temp)));
 114  
         }
 115  
         if (DEBUG)
 116  
         {
 117  
             // If there are GET/POST/PATH_INFO variables put them into
 118  
             // a <PRE></PRE> tag so that they can be displayed on the
 119  
             // page. This is of course only for example purposes.
 120  
             PRE pre = new PRE();
 121  
 
 122  
             for (Iterator it = data.getParameters().keySet().iterator();
 123  
                  it.hasNext();)
 124  
             {
 125  
                 String key = (String) it.next();
 126  
                 String[] values = data.getParameters().getStrings(key);
 127  
                 if (values.length == 1)
 128  
                 {
 129  
                     pre.addElement(key + " = " + values[0] + "\n");
 130  
                 }
 131  
                 else
 132  
                 {
 133  
                     pre.addElement(key + " = ");
 134  
                     for (int i = 0; i < values.length; i++)
 135  
                     {
 136  
                         pre.addElement(values[i] + " ");
 137  
                     }
 138  
                     pre.addElement("\n");
 139  
                 }
 140  
             }
 141  
             body
 142  
                 .addElement(new B("Query/PathInfo Parameters"))
 143  
                 .addElement(new BR())
 144  
                 .addElement(pre);
 145  
 
 146  
             Table table2 = new Table().setBorder(0);
 147  
             Map varDebug = data.getDebugVariables();
 148  
 
 149  
             boolean hasValues2 = false;
 150  
 
 151  
             for (Iterator i = varDebug.keySet().iterator(); i.hasNext();)
 152  
             {
 153  
                 String key = (String) i.next();
 154  
                 String value = varDebug.get(key).toString();
 155  
                 TR tr =
 156  
                     new TR().addElement(
 157  
                         new TD().addElement(class="keyword">new B(key))).addElement(
 158  
                         new TD().addElement(" = " + value));
 159  
                 table2.addElement(tr);
 160  
                 hasValues2 = true;
 161  
             }
 162  
             if (hasValues2)
 163  
             {
 164  
                 body.addElement(new H4().addElement("Debugging Data:"));
 165  
                 body.addElement(table2);
 166  
             }
 167  
         }
 168  
 
 169  
         if (DEBUG && data.getACL() != null)
 170  
         {
 171  
             // Print out user's permissions.
 172  
             PRE pre = new PRE();
 173  
             for (Iterator rs = data.getACL().getRoles().iterator();
 174  
                 rs.hasNext();
 175  
                 )
 176  
             {
 177  
                 String roleName = ((Role) rs.next()).getName();
 178  
                 pre.addElement(roleName + "\n");
 179  
             }
 180  
             body
 181  
                 .addElement(new BR())
 182  
                 .addElement(new B("ROLES"))
 183  
                 .addElement(new BR())
 184  
                 .addElement(pre);
 185  
 
 186  
             pre = new PRE();
 187  
             for (Iterator ps = data.getACL().getPermissions().iterator();
 188  
                 ps.hasNext();
 189  
                 )
 190  
             {
 191  
                 String permissionName = ((Permission) ps.next()).getName();
 192  
                 pre.addElement(permissionName + "\n");
 193  
             }
 194  
             body
 195  
                 .addElement(new BR())
 196  
                 .addElement(new B("PERMISSIONS"))
 197  
                 .addElement(new BR())
 198  
                 .addElement(pre);
 199  
         }
 200  0
         return body;
 201  
     }
 202  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.