View Javadoc
1 package org.apache.turbine.modules.navigations; 2 3 /* ==================================================================== 4 * The Apache Software License, Version 1.1 5 * 6 * Copyright (c) 2001 The Apache Software Foundation. All rights 7 * reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in 18 * the documentation and/or other materials provided with the 19 * distribution. 20 * 21 * 3. The end-user documentation included with the redistribution, 22 * if any, must include the following acknowledgment: 23 * "This product includes software developed by the 24 * Apache Software Foundation (http://www.apache.org/)." 25 * Alternately, this acknowledgment may appear in the software itself, 26 * if and wherever such third-party acknowledgments normally appear. 27 * 28 * 4. The names "Apache" and "Apache Software Foundation" and 29 * "Apache Turbine" must not be used to endorse or promote products 30 * derived from this software without prior written permission. For 31 * written permission, please contact apache@apache.org. 32 * 33 * 5. Products derived from this software may not be called "Apache", 34 * "Apache Turbine", nor may "Apache" appear in their name, without 35 * prior written permission of the Apache Software Foundation. 36 * 37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 39 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 40 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 44 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 48 * SUCH DAMAGE. 49 * ==================================================================== 50 * 51 * This software consists of voluntary contributions made by many 52 * individuals on behalf of the Apache Software Foundation. For more 53 * information on the Apache Software Foundation, please see 54 * <http://www.apache.org/>;. 55 */ 56 57 // Java Core Classes 58 import java.util.Enumeration; 59 import java.util.Hashtable; 60 import java.util.Iterator; 61 62 // Turbine Classes 63 import org.apache.turbine.modules.Navigation; 64 import org.apache.turbine.om.security.Permission; 65 import org.apache.turbine.om.security.Role; 66 import org.apache.turbine.util.DynamicURI; 67 import org.apache.turbine.util.RunData; 68 69 // ECS Classes 70 import org.apache.ecs.ConcreteElement; 71 import org.apache.ecs.ElementContainer; 72 import org.apache.ecs.HtmlColor; 73 import org.apache.ecs.AlignType; 74 import org.apache.ecs.html.B; 75 import org.apache.ecs.html.BR; 76 import org.apache.ecs.html.Font; 77 import org.apache.ecs.html.Form; 78 import org.apache.ecs.html.H4; 79 import org.apache.ecs.html.HR; 80 import org.apache.ecs.html.Input; 81 import org.apache.ecs.html.PRE; 82 import org.apache.ecs.html.Table; 83 import org.apache.ecs.html.TD; 84 import org.apache.ecs.html.TR; 85 86 87 /*** 88 * This is a sample navigation module. 89 * 90 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a> 91 * @version $Id: DefaultBottomNavigation.java,v 1.1.1.1 2001/08/16 05:08:35 jvanzyl Exp $ 92 * @deprecated The use of ECS for the view is deprecated. Use a templating solution. 93 */ 94 public class DefaultBottomNavigation extends Navigation 95 { 96 private static final boolean DEBUG = false; 97 private static String txt = 98 "Turbine - A Servlet Framework for building Secure Dynamic Websites."; 99 100 /*** 101 * Build the Navigation. 102 * 103 * @param data Turbine information. 104 * @return A ConcreteElement. 105 * @exception Exception, a generic exception. 106 */ 107 public ConcreteElement doBuild( RunData data ) 108 throws Exception 109 { 110 Form form; 111 form = new Form( 112 new DynamicURI(data,"DefaultScreen","LogoutUser",true).toString(), 113 Form.POST) 114 .addElement(new Input("SUBMIT", "Logout", "Logout")); 115 ElementContainer body = new ElementContainer() 116 .addElement(new HR().setSize(1).setNoShade(true)) 117 .addElement(new B().addElement( 118 new Font().setColor(HtmlColor.green).setSize(2).addElement(txt))) 119 .addElement(form); 120 121 if (DEBUG && data.getUser() != null) 122 { 123 TD perm = new TD().setVAlign(AlignType.TOP); 124 TD temp = new TD().setVAlign(AlignType.TOP); 125 java.util.Enumeration ePerm = 126 data.getUser().getPermStorage().keys(); 127 java.util.Enumeration eTemp = 128 data.getUser().getTempStorage().keys(); 129 130 perm.addElement("Perm values:").addElement( new BR() ); 131 temp.addElement("Temp values:").addElement( new BR() ); 132 while ( ePerm.hasMoreElements() ) 133 { 134 String key = (String) ePerm.nextElement(); 135 String value = data.getUser().getPerm(key).toString(); 136 perm.addElement( key + "=" + value ) 137 .addElement( new BR() ); 138 } 139 while ( eTemp.hasMoreElements() ) 140 { 141 String key = (String) eTemp.nextElement(); 142 String value = data.getUser().getTemp(key).toString(); 143 temp.addElement( key + "=" + value ) 144 .addElement( new BR() ); 145 } 146 body.addElement(new BR()).addElement(new BR()) 147 .addElement(new Table().setBorder(2).setCellPadding(10) 148 .addElement(new TR() 149 .addElement(perm).addElement(temp) )); 150 } 151 if (DEBUG) 152 { 153 // If there are GET/POST/PATH_INFO variables put them into 154 // a <PRE></PRE> tag so that they can be displayed on the 155 // page. This is of course only for example purposes. 156 PRE pre = new PRE(); 157 Enumeration keys = data.getParameters().keys(); 158 while ( keys.hasMoreElements() ) 159 { 160 String key = (String) keys.nextElement(); 161 String[] values = data.getParameters().getStrings(key); 162 if (values.length == 1) 163 pre.addElement(key + " = " + values[0] + "\n"); 164 else 165 { 166 pre.addElement(key + " = "); 167 for (int i=0; i<values.length; i++) 168 pre.addElement(values[i] + " "); 169 pre.addElement("\n"); 170 } 171 } 172 body.addElement( new B("Query/PathInfo Parameters") ) 173 .addElement( new BR() ) 174 .addElement(pre); 175 176 Table table2 = new Table().setBorder(0); 177 Hashtable varDebug = data.getVarDebug(); 178 keys = varDebug.keys(); 179 boolean hasValues2 = false; 180 while ( keys.hasMoreElements() ) 181 { 182 String key = (String) keys.nextElement(); 183 String value = varDebug.get(key).toString(); 184 TR tr = new TR() 185 .addElement ( new TD().addElement(new B(key)) ) 186 .addElement ( new TD().addElement(" = " + value ) ); 187 table2.addElement(tr); 188 hasValues2 = true; 189 } 190 if ( hasValues2 ) 191 { 192 body.addElement (new H4().addElement("Debugging Data:")); 193 body.addElement (table2); 194 } 195 } 196 197 if (DEBUG && data.getACL() != null) 198 { 199 // Print out user's permissions. 200 PRE pre = new PRE(); 201 Iterator rs = data.getACL().getRoles().elements(); 202 while ( rs.hasNext() ) 203 { 204 String roleName = ((Role)rs.next()).getName(); 205 pre.addElement(roleName + "\n"); 206 } 207 body 208 .addElement( new BR() ) 209 .addElement( new B("ROLES") ) 210 .addElement( new BR() ) 211 .addElement(pre); 212 213 pre = new PRE(); 214 Iterator ps = data.getACL().getPermissions().elements(); 215 while ( ps.hasNext() ) 216 { 217 String permissionName = ((Permission)ps.next()).getName(); 218 pre.addElement(permissionName + "\n"); 219 } 220 body 221 .addElement( new BR() ) 222 .addElement( new B("PERMISSIONS") ) 223 .addElement( new BR() ) 224 .addElement(pre); 225 226 } 227 228 return body; 229 } 230 }

This page was automatically generated by Maven