Source Code Cross Referenced for NavOption.java in  » J2EE » Jaffa » org » jaffa » components » navigation » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Jaffa » org.jaffa.components.navigation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ====================================================================
003:         * JAFFA - Java Application Framework For All
004:         *
005:         * Copyright (C) 2002 JAFFA Development Group
006:         *
007:         *     This library is free software; you can redistribute it and/or
008:         *     modify it under the terms of the GNU Lesser General Public
009:         *     License as published by the Free Software Foundation; either
010:         *     version 2.1 of the License, or (at your option) any later version.
011:         *
012:         *     This library is distributed in the hope that it will be useful,
013:         *     but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *     Lesser General Public License for more details.
016:         *
017:         *     You should have received a copy of the GNU Lesser General Public
018:         *     License along with this library; if not, write to the Free Software
019:         *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         *
021:         * Redistribution and use of this software and associated documentation ("Software"),
022:         * with or without modification, are permitted provided that the following conditions are met:
023:         * 1.	Redistributions of source code must retain copyright statements and notices.
024:         *         Redistributions must also contain a copy of this document.
025:         * 2.	Redistributions in binary form must reproduce the above copyright notice,
026:         * 	this list of conditions and the following disclaimer in the documentation
027:         * 	and/or other materials provided with the distribution.
028:         * 3.	The name "JAFFA" must not be used to endorse or promote products derived from
029:         * 	this Software without prior written permission. For written permission,
030:         * 	please contact mail to: jaffagroup@yahoo.com.
031:         * 4.	Products derived from this Software may not be called "JAFFA" nor may "JAFFA"
032:         * 	appear in their names without prior written permission.
033:         * 5.	Due credit should be given to the JAFFA Project (http://jaffa.sourceforge.net).
034:         *
035:         * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
036:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
039:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046:         * SUCH DAMAGE.
047:         * ====================================================================
048:         */
049:
050:        /*
051:         * NavOptions.java
052:         *
053:         * Created on October 20, 2003, 3:29 PM
054:         */
055:
056:        package org.jaffa.components.navigation;
057:
058:        import java.util.List;
059:        import org.jaffa.components.navigation.NavAccessor;
060:        import org.jaffa.components.navigation.domain.MenuOption;
061:        import java.util.ArrayList;
062:        import org.jaffa.components.navigation.domain.ComponentAction;
063:        import java.util.Iterator;
064:        import org.apache.log4j.Logger;
065:        import org.jaffa.security.SecurityManager;
066:
067:        /** This object represents a node in the menu structure
068:         * @author JonnyR
069:         */
070:        public class NavOption {
071:
072:            private static final Logger log = Logger.getLogger(NavOption.class);
073:
074:            public static final String TYPE_COMPONENT = "component";
075:            public static final String TYPE_DESKTOP = "desktop";
076:            public static final String TYPE_URL = "url";
077:            public static final String TYPE_SUB_MENU = "sub menu";
078:
079:            private String m_label = null;
080:            private String m_component = null;
081:            private String m_type = null;
082:            private String m_strutsTileTemplate = null;
083:            private String m_params = null;
084:            private List m_children = null;
085:            private String m_desktopId = null;
086:            private String m_url = null;
087:            private boolean m_urlFinal;
088:
089:            /** Creates a new instance of NavOption from a menu option.
090:             * @throws SecurityException if the user should not have access to this option
091:             */
092:            public NavOption(NavAccessor nav, MenuOption mOpt)
093:                    throws SecurityException {
094:                m_label = mOpt.getLabel();
095:                if (mOpt.getSubMenu() != null) {
096:                    m_type = TYPE_SUB_MENU;
097:                    m_children = new ArrayList();
098:                    if (nav.parseMenuOptions(mOpt.getSubMenu().getMenuOption(),
099:                            m_children) == 0)
100:                        throw new SecurityException(
101:                                "All Options Unavailable. No Access To Sub-Menu "
102:                                        + m_label);
103:                } else if (mOpt.getDesktopMenu() != null) {
104:                    m_type = TYPE_DESKTOP;
105:                    m_desktopId = "" + nav.getNextDesktopId();
106:                    m_strutsTileTemplate = mOpt.getDesktopMenu()
107:                            .getStrutsTileTemplate();
108:                    m_children = new ArrayList();
109:                    if (nav.parseMenuOptions(mOpt.getDesktopMenu()
110:                            .getMenuOption(), m_children) == 0)
111:                        throw new SecurityException(
112:                                "All Options Unavailable. No Access To Desktop "
113:                                        + m_label);
114:                    nav.addDesktopNavOption(m_desktopId, this );
115:                } else if (mOpt.getComponentAction() != null) {
116:                    m_type = TYPE_COMPONENT;
117:                    m_component = mOpt.getComponentAction().getComponentName();
118:                    if (!SecurityManager.checkComponentAccess(mOpt
119:                            .getComponentAction().getComponentName()))
120:                        throw new SecurityException(
121:                                "No User Access to Component " + m_component);
122:                    m_url = mOpt.getComponentAction().getUrlSuffix();
123:                    if (mOpt.getComponentAction().getParam() != null) {
124:                        // build up the parameter list...
125:                        for (Iterator it = mOpt.getComponentAction().getParam()
126:                                .iterator(); it.hasNext();) {
127:                            ComponentAction.ParamType p = (ComponentAction.ParamType) it
128:                                    .next();
129:                            m_params = (m_params == null ? "" : m_params + "&")
130:                                    + p.getName() + "=" + p.getValue();
131:                        }
132:                    }
133:                } else if (mOpt.getUrlAction() != null) {
134:                    m_type = TYPE_URL;
135:                    m_url = mOpt.getUrlAction().getUrl().getValue();
136:                    m_urlFinal = mOpt.getUrlAction().getUrl().isAppendFinal();
137:
138:                    if (mOpt.getUrlAction().getRequiresComponentAccess() != null)
139:                        for (Iterator it = mOpt.getUrlAction()
140:                                .getRequiresComponentAccess().iterator(); it
141:                                .hasNext();) {
142:                            String comp = (String) it.next();
143:                            if (!SecurityManager.checkComponentAccess(comp))
144:                                throw new SecurityException(
145:                                        "No Access to Component " + comp
146:                                                + " for option " + m_label);
147:                        }
148:
149:                    if (mOpt.getUrlAction().getRequiresFunctionAccess() != null)
150:                        for (Iterator it = mOpt.getUrlAction()
151:                                .getRequiresFunctionAccess().iterator(); it
152:                                .hasNext();) {
153:                            String func = (String) it.next();
154:                            if (!SecurityManager.checkFunctionAccess(func))
155:                                throw new SecurityException(
156:                                        "No Access to Function " + func
157:                                                + " for option " + m_label);
158:                        }
159:
160:                } else {
161:                    throw new SecurityException("Unknown Option Type for "
162:                            + m_label);
163:                }
164:
165:            }
166:
167:            /** Returns a list of children (navOptions) that are under this node in the structure
168:             * @return List continaing navOption objects
169:             */
170:            public List getChildren() {
171:                if (TYPE_DESKTOP.equals(m_type) || TYPE_SUB_MENU.equals(m_type))
172:                    return m_children;
173:                else
174:                    throw new UnsupportedOperationException("Option Type "
175:                            + m_type + " does not support getChildren()");
176:            }
177:
178:            /** Method returns the String for the menu option
179:             * @return String that is the text to be displayed on the menu
180:             */
181:            public String getLabel() {
182:                return m_label;
183:            }
184:
185:            /** Returns a URL that will either be complete or partial.
186:             * @return The String to build the URL on the HTML page.
187:             */
188:            public String getURL() {
189:                return m_url;
190:            }
191:
192:            /** Returns a string of any parameters necessary for the URL.
193:             * @return Returns a string that is any paramaters necessary for the URL.
194:             */
195:            public String getParameters() {
196:                return m_params;
197:            }
198:
199:            /** Returns the component's ID in case the URL has to be built my hand.
200:             * @return Returns a string that is the component's ID
201:             */
202:            public String getComponent() {
203:                return m_component;
204:            }
205:
206:            /** Returns the unique Id assigned to this desktop.
207:             * @return Returns a string that is the desktop's ID
208:             */
209:            public String getDesktopId() {
210:                return m_desktopId;
211:            }
212:
213:            /** Returns the menu type
214:             * @return Returns the type of menu option
215:             */
216:            public String getType() {
217:                return m_type;
218:            }
219:
220:            /** Returns the StrutsTileTemplate
221:             * @return Returns the StrutsTileTemplate of menu option
222:             */
223:            public String getStrutsTileTemplate() {
224:                return m_strutsTileTemplate;
225:            }
226:
227:            /** Returns the menu type
228:             * @return Returns true if this is a desktop
229:             */
230:            public boolean isDesktop() {
231:                return TYPE_DESKTOP.equals(m_type);
232:            }
233:
234:            /** Returns the menu type
235:             * @return Returns true if this is a sub menu, either in the Global or Desktop menu
236:             */
237:            public boolean isSubMenu() {
238:                return TYPE_SUB_MENU.equals(m_type);
239:            }
240:
241:            /** Returns the menu type
242:             * @return Returns true if this is a component action
243:             */
244:            public boolean isComponent() {
245:                return TYPE_COMPONENT.equals(m_type);
246:            }
247:
248:            /** Returns the menu type
249:             * @return Returns true if this is a url action
250:             */
251:            public boolean isURL() {
252:                return TYPE_URL.equals(m_type);
253:            }
254:
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.