1 package org.apache.turbine.modules.navigations; 2 3 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 54 public class DefaultBottomNavigation extends Navigation 55 { 56 57 private static final boolean DEBUG = false; 58 59 private static String txt = 60 "Turbine - A Servlet Framework for building Secure Dynamic Websites."; 61 62 69 public ConcreteElement doBuild(RunData data) throws Exception 70 { 71 Form form; 72 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 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(new BR()).addElement( 112 new Table().setBorder(2).setCellPadding(10).addElement( 113 new TR().addElement(perm).addElement(temp))); 114 } 115 if (DEBUG) 116 { 117 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(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 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 return body; 201 } 202 } 203 | Popular Tags |