Source Code Cross Referenced for Action.java in  » Web-Framework » JAT » com » jat » presentation » controller » 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 » Web Framework » JAT » com.jat.presentation.controller 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.jat.presentation.controller;
002:
003:        import java.util.Enumeration;
004:        import java.util.Hashtable;
005:        import java.util.Vector;
006:        import javax.servlet.ServletException;
007:        import javax.servlet.http.HttpServletRequest;
008:        import javax.servlet.http.HttpServletResponse;
009:        import javax.servlet.http.HttpSession;
010:
011:        import com.jat.business.BusinessException;
012:        import com.jat.business.BusinessObjectProperties;
013:        import com.jat.business.JatUser;
014:        import com.jat.core.config.Config;
015:        import com.jat.core.log.LogManager;
016:        import com.jat.presentation.PresentationException;
017:        import com.jat.presentation.parameter.CheckParameterException;
018:        import com.jat.presentation.parameter.CheckParameterPlugin;
019:        import com.jat.presentation.parameter.DefaultCheckParameter;
020:        import com.jat.presentation.parameter.HttpRequestParameters;
021:        import com.jat.presentation.PresentationServlet;
022:
023:        /**
024:         * <p>Title: JAT</p>
025:         * <p>Description: </p>
026:         * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
027:         * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
028:         * @author stf
029:         * @version 1.0
030:         * @since 1.2
031:         */
032:
033:        public abstract class Action extends PresentationServlet {
034:
035:            public final static String ACTION_PARAMETER = "action";
036:            public final static String JAT_PAGES_FLOW = "JAT_PAGES_FLOW";
037:            public final static String CHECK_PARAMETERS_ERRORS = "CHECK_PARAMETERS_ERRORS";
038:            public final static String BUSINESS_OBJECT_LIST_RESULT = "BUSINESS_OBJECT_LIST_RESULT";
039:
040:            public final static String CHECK_PARAMETERS_DEFAULT_SECTION = "presentation";
041:            public final static String CHECK_PARAMETERS_SECTION_KEY = "section";
042:            public final static String CHECK_PARAMETERS_FIELDS_KEY = "fields_key";
043:
044:            //public abstract void doAction(HttpServletRequest request, HttpServletResponse response) throws PresentationException, ServletException;
045:
046:            public boolean isNavigable() {
047:                return false;
048:            }
049:
050:            public String getName() {
051:                return this .name;
052:            }
053:
054:            public void setName(String name) {
055:                this .name = name;
056:            }
057:
058:            public String getNextPage() {
059:                return this .nextPage;
060:            }
061:
062:            public void setNextPage(String nextPage) {
063:                this .nextPage = nextPage;
064:            }
065:
066:            public String getErrorPage() {
067:                return this .errorPage;
068:            }
069:
070:            public void setErrorPage(String errorPage) {
071:                this .errorPage = errorPage;
072:            }
073:
074:            public String getPrivilege() {
075:                return this .privilege;
076:            }
077:
078:            public void setPrivilege(String privilege) {
079:                this .privilege = privilege;
080:            }
081:
082:            public boolean isLogRequired() {
083:                return this .logRequired;
084:            }
085:
086:            public void setLogRequired(boolean logRequired) {
087:                this .logRequired = logRequired;
088:            }
089:
090:            public Vector getMethods() {
091:                return this .methods;
092:            }
093:
094:            public void addMethod(String method) {
095:                this .methods.addElement(method);
096:            }
097:
098:            public boolean removeMethod(String method) {
099:                return this .methods.remove(method);
100:            }
101:
102:            public Vector getPreviousPages() {
103:                return this .previousPages;
104:            }
105:
106:            public void addPreviousPages(String previousPage) {
107:                this .previousPages.addElement(previousPage);
108:            }
109:
110:            public boolean removePreviousPages(String previousPage) {
111:                return this .previousPages.remove(previousPage);
112:            }
113:
114:            public void setMethods(Vector methods) {
115:                this .methods = methods;
116:            }
117:
118:            public void setPreviousPages(Vector previousPages) {
119:                this .previousPages = previousPages;
120:            }
121:
122:            public BusinessObjectProperties checkParameters(
123:                    HttpServletRequest request) throws CheckParameterException,
124:                    Exception {
125:                // CHECK_PARAMETERS_FIELDS_KEY is mandatory
126:                String fieldsKey = request
127:                        .getParameter(CHECK_PARAMETERS_FIELDS_KEY);
128:                if (fieldsKey == null || fieldsKey.equals(""))
129:                    throw new PresentationException("Parameter '"
130:                            + CHECK_PARAMETERS_FIELDS_KEY
131:                            + "' not found in request");
132:                // CHECK_PARAMETERS_SECTION_KEY is optional
133:                String section = request
134:                        .getParameter(CHECK_PARAMETERS_SECTION_KEY);
135:                if (section == null || section.equals(""))
136:                    section = CHECK_PARAMETERS_DEFAULT_SECTION;
137:
138:                HttpRequestParameters parameters = new HttpRequestParameters(
139:                        request, null);
140:                Hashtable errors = parameters.checkParameters(section,
141:                        fieldsKey);
142:                if (errors.size() > 0) {
143:                    request.setAttribute(CHECK_PARAMETERS_ERRORS, errors);
144:                    throw new CheckParameterException(errors);
145:                }
146:                return parameters.getProperties();
147:            }
148:
149:            public String toString() {
150:                String ret = this .getClass().getName() + "{";
151:                ret += "[name=" + this .getName() + "],";
152:                ret += "[next_page=" + this .getNextPage() + "],";
153:                ret += "[error_page=" + this .getErrorPage() + "],";
154:                ret += "[log_required=" + this .isLogRequired() + "],";
155:                ret += "[privilege=" + this .getPrivilege() + "],";
156:                ret += "[methods:{" + methods + "}],";
157:                ret += "[previous_pages:{" + previousPages + "}]";
158:                return ret + "}";
159:            }
160:
161:            protected boolean checkMethod(HttpServletRequest request) {
162:                if (this .methods.size() < 1)
163:                    return true;
164:                String method = request.getMethod();
165:                return methods.contains(method.toUpperCase());
166:            }
167:
168:            protected boolean checkFlow(HttpSession session) {
169:                if (previousPages.size() < 1)
170:                    return true;
171:                String previousPage = (String) session
172:                        .getAttribute(JAT_PAGES_FLOW);
173:                return this .previousPages.contains(previousPage);
174:            }
175:
176:            protected boolean checkUserLogged(HttpSession session)
177:                    throws PrivilegeException {
178:                if (!this .isLogRequired())
179:                    return true;
180:                JatUser user = (JatUser) session.getAttribute(JatUser.JAT_USER);
181:                if (user == null)
182:                    return false;
183:                if (this .getPrivilege() == null)
184:                    return true;
185:                try {
186:                    return user.hasPrivilege(this .getPrivilege(), null);
187:                } catch (BusinessException ex) {
188:                    throw new PrivilegeException("User " + user.getUsername()
189:                            + "has no privileges to access to "
190:                            + this .getPrivilege());
191:                }
192:            }
193:
194:            private String name;
195:            private String nextPage;
196:            private String errorPage;
197:            private String privilege;
198:            private boolean logRequired;
199:            private Vector methods = new Vector();
200:            private Vector previousPages = new Vector();
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.