Source Code Cross Referenced for RequestManager.java in  » ERP-CRM-Financial » SourceTap-CRM » org » ofbiz » content » webapp » control » 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 » ERP CRM Financial » SourceTap CRM » org.ofbiz.content.webapp.control 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: RequestManager.java,v 1.4 2004/02/05 23:13:13 ajzeneski Exp $
003:         *
004:         * Copyright (c) 2001-2003 The Open For Business Project - www.ofbiz.org
005:         *
006:         * Permission is hereby granted, free of charge, to any person obtaining a
007:         * copy of this software and associated documentation files (the "Software"),
008:         * to deal in the Software without restriction, including without limitation
009:         * the rights to use, copy, modify, merge, publish, distribute, sublicense,
010:         * and/or sell copies of the Software, and to permit persons to whom the
011:         * Software is furnished to do so, subject to the following conditions:
012:         *
013:         * The above copyright notice and this permission notice shall be included
014:         * in all copies or substantial portions of the Software.
015:         *
016:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
017:         * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
018:         * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
019:         * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
020:         * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
021:         * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
022:         * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
023:         *
024:         */
025:        package org.ofbiz.content.webapp.control;
026:
027:        import java.io.Serializable;
028:        import java.net.URL;
029:        import java.util.Collection;
030:        import java.util.Map;
031:
032:        import javax.servlet.ServletContext;
033:
034:        import org.ofbiz.base.util.Debug;
035:
036:        /**
037:         * RequestManager - Manages request, config and view mappings.
038:         *
039:         * @author     <a href="mailto:jaz@ofbiz.org">Andy Zeneski</a>
040:         * @version    $Revision: 1.4 $
041:         * @since      2.0
042:         */
043:        public class RequestManager implements  Serializable {
044:
045:            public static final String module = RequestManager.class.getName();
046:            public static final int VIEW_HANDLER_KEY = 1;
047:            public static final int EVENT_HANDLER_KEY = 0;
048:
049:            private URL configFileUrl;
050:
051:            public RequestManager(ServletContext context) {
052:
053:                /** Loads the site configuration from servlet context parameter. */
054:                try {
055:                    configFileUrl = context
056:                            .getResource("/WEB-INF/controller.xml");
057:                } catch (Exception e) {
058:                    Debug.logError(e,
059:                            "[RequestManager.constructor] Error Finding XML Config File: "
060:                                    + "/WEB-INF/controller.xml", module);
061:                }
062:                // do quick inits:
063:                ConfigXMLReader.getConfigMap(configFileUrl);
064:                ConfigXMLReader.getHandlerMap(configFileUrl);
065:                ConfigXMLReader.getRequestMap(configFileUrl);
066:                ConfigXMLReader.getViewMap(configFileUrl);
067:            }
068:
069:            /** Gets the entire handler mapping */
070:            public Map getHandlerMap() {
071:                return (Map) ConfigXMLReader.getHandlerMap(configFileUrl);
072:            }
073:
074:            /** Gets the class name of the named handler */
075:            public String getHandlerClass(String name, int type) {
076:                Map map = getHandlerMap();
077:                Map hMap = null;
078:
079:                if (type == 1)
080:                    hMap = (Map) map.get("view");
081:                else
082:                    hMap = (Map) map.get("event");
083:                if (!hMap.containsKey(name))
084:                    return null;
085:                else
086:                    return (String) hMap.get(name);
087:            }
088:
089:            public Map getRequestMapMap(String uriStr) {
090:                return (Map) ConfigXMLReader.getRequestMap(configFileUrl).get(
091:                        uriStr);
092:            }
093:
094:            public String getRequestAttribute(String uriStr, String attribute) {
095:                Map uri = getRequestMapMap(uriStr);
096:
097:                if (uri != null)
098:                    return (String) uri.get(attribute);
099:                else {
100:                    Debug.logWarning(
101:                            "[RequestManager.getRequestAttribute] Value for attribute \""
102:                                    + attribute + "\" of uri \"" + uriStr
103:                                    + "\" not found", module);
104:                    return null;
105:                }
106:            }
107:
108:            /** Gets the event class from the requestMap */
109:            public String getEventPath(String uriStr) {
110:                Map uri = getRequestMapMap(uriStr);
111:
112:                if (uri != null)
113:                    return (String) uri.get(ConfigXMLReader.EVENT_PATH);
114:                else {
115:                    Debug.logWarning(
116:                            "[RequestManager.getEventPath] Path of event for request \""
117:                                    + uriStr + "\" not found", module);
118:                    return null;
119:                }
120:            }
121:
122:            /** Gets the event type from the requestMap */
123:            public String getEventType(String uriStr) {
124:                Map uri = getRequestMapMap(uriStr);
125:
126:                if (uri != null)
127:                    return (String) uri.get(ConfigXMLReader.EVENT_TYPE);
128:                else {
129:                    Debug.logWarning(
130:                            "[RequestManager.getEventType] Type of event for request \""
131:                                    + uriStr + "\" not found", module);
132:                    return null;
133:                }
134:            }
135:
136:            /** Gets the event method from the requestMap */
137:            public String getEventMethod(String uriStr) {
138:                Map uri = getRequestMapMap(uriStr);
139:
140:                if (uri != null) {
141:                    return (String) uri.get(ConfigXMLReader.EVENT_METHOD);
142:                } else {
143:                    Debug.logWarning(
144:                            "[RequestManager.getEventMethod] Method of event for request \""
145:                                    + uriStr + "\" not found", module);
146:                    return null;
147:                }
148:            }
149:
150:            /** Gets the view name from the requestMap */
151:            public String getViewName(String uriStr) {
152:                Map uri = getRequestMapMap(uriStr);
153:
154:                if (uri != null)
155:                    return (String) uri.get(ConfigXMLReader.NEXT_PAGE);
156:                else {
157:                    Debug.logWarning(
158:                            "[RequestManager.getViewName] View name for uri \""
159:                                    + uriStr + "\" not found", module);
160:                    return null;
161:                }
162:            }
163:
164:            /** Gets the next page (jsp) from the viewMap */
165:            public String getViewPage(String viewStr) {
166:                if (viewStr != null && viewStr.startsWith("view:"))
167:                    viewStr = viewStr.substring(viewStr.indexOf(':') + 1);
168:                Map page = (Map) ConfigXMLReader.getViewMap(configFileUrl).get(
169:                        viewStr);
170:
171:                if (page != null) {
172:                    return (String) page.get(ConfigXMLReader.VIEW_PAGE);
173:                } else {
174:                    Debug.logWarning(
175:                            "[RequestManager.getViewPage] View with name \""
176:                                    + viewStr + "\" not found", module);
177:                    return null;
178:                }
179:            }
180:
181:            /** Gets the type of this view */
182:            public String getViewType(String viewStr) {
183:                Map view = (Map) ConfigXMLReader.getViewMap(configFileUrl).get(
184:                        viewStr);
185:
186:                if (view != null) {
187:                    return (String) view.get(ConfigXMLReader.VIEW_TYPE);
188:                } else {
189:                    Debug.logWarning(
190:                            "[RequestManager.getViewType] View with name \""
191:                                    + viewStr + "\" not found", module);
192:                    return null;
193:                }
194:            }
195:
196:            /** Gets the info of this view */
197:            public String getViewInfo(String viewStr) {
198:                Map view = (Map) ConfigXMLReader.getViewMap(configFileUrl).get(
199:                        viewStr);
200:
201:                if (view != null) {
202:                    return (String) view.get(ConfigXMLReader.VIEW_INFO);
203:                } else {
204:                    Debug.logWarning(
205:                            "[RequestManager.getViewInfo] View with name \""
206:                                    + viewStr + "\" not found", module);
207:                    return null;
208:                }
209:            }
210:
211:            /** Gets the content-type of this view */
212:            public String getViewContentType(String viewStr) {
213:                Map view = (Map) ConfigXMLReader.getViewMap(configFileUrl).get(
214:                        viewStr);
215:
216:                if (view != null) {
217:                    return (String) view.get(ConfigXMLReader.VIEW_CONTENT_TYPE);
218:                } else {
219:                    Debug.logWarning(
220:                            "[RequestManager.getViewInfo] View with name \""
221:                                    + viewStr + "\" not found", module);
222:                    return null;
223:                }
224:            }
225:
226:            /** Gets the content-type of this view */
227:            public String getViewEncoding(String viewStr) {
228:                Map view = (Map) ConfigXMLReader.getViewMap(configFileUrl).get(
229:                        viewStr);
230:
231:                if (view != null) {
232:                    return (String) view.get(ConfigXMLReader.VIEW_ENCODING);
233:                } else {
234:                    Debug.logWarning(
235:                            "[RequestManager.getViewInfo] View with name \""
236:                                    + viewStr + "\" not found", module);
237:                    return null;
238:                }
239:            }
240:
241:            /** Gets the error page from the requestMap, if none uses the default */
242:            public String getErrorPage(String uriStr) {
243:                //Debug.logInfo("uriStr is: " + uriStr, module);
244:                Map uri = getRequestMapMap(uriStr);
245:                //Debug.logInfo("RequestMapMap is: " + uri, module);
246:
247:                if (uri != null) {
248:                    String errorViewUri = (String) uri
249:                            .get(ConfigXMLReader.ERROR_PAGE);
250:                    //Debug.logInfo("errorViewUri is: " + errorViewUri, module);
251:                    String returnPage = getViewPage(errorViewUri);
252:                    //Debug.logInfo("Got returnPage for ErrorPage: " + returnPage, module);
253:
254:                    if (returnPage != null) {
255:                        return returnPage;
256:                    } else {
257:                        return getDefaultErrorPage();
258:                    }
259:                } else {
260:                    return getDefaultErrorPage();
261:                }
262:            }
263:
264:            /** Gets the default error page from the configMap or static site default */
265:            public String getDefaultErrorPage() {
266:                String errorPage = null;
267:                errorPage = (String) ConfigXMLReader
268:                        .getConfigMap(configFileUrl).get(
269:                                ConfigXMLReader.DEFAULT_ERROR_PAGE);
270:                //Debug.logInfo("For DefaultErrorPage got errorPage: " + errorPage, module);
271:                if (errorPage != null)
272:                    return errorPage;
273:                return "/error/error.jsp";
274:            }
275:
276:            public boolean requiresAuth(String uriStr) {
277:                Map uri = getRequestMapMap(uriStr);
278:
279:                if (uri != null) {
280:                    String value = (String) uri
281:                            .get(ConfigXMLReader.SECURITY_AUTH);
282:
283:                    //if (Debug.verboseOn()) Debug.logVerbose("Require Auth: " + value, module);
284:                    if ("true".equalsIgnoreCase(value))
285:                        return true;
286:                    else
287:                        return false;
288:                } else
289:                    return false;
290:            }
291:
292:            public boolean requiresHttps(String uriStr) {
293:                Map uri = getRequestMapMap(uriStr);
294:
295:                if (uri != null) {
296:                    String value = (String) uri
297:                            .get(ConfigXMLReader.SECURITY_HTTPS);
298:
299:                    //if (Debug.verboseOn()) Debug.logVerbose("Requires HTTPS: " + value, module);
300:                    if ("true".equalsIgnoreCase(value))
301:                        return true;
302:                    else
303:                        return false;
304:                } else
305:                    return false;
306:            }
307:
308:            public boolean allowExtView(String uriStr) {
309:                Map uri = getRequestMapMap(uriStr);
310:
311:                if (uri != null) {
312:                    String value = (String) uri
313:                            .get(ConfigXMLReader.SECURITY_EXTVIEW);
314:
315:                    //if (Debug.verboseOn()) Debug.logVerbose("Allow External View: " + value, module);
316:                    if ("false".equalsIgnoreCase(value))
317:                        return false;
318:                    else
319:                        return true;
320:                } else
321:                    return true;
322:            }
323:
324:            public boolean allowDirectRequest(String uriStr) {
325:                Map uri = getRequestMapMap(uriStr);
326:
327:                if (uri != null) {
328:                    String value = (String) uri
329:                            .get(ConfigXMLReader.SECURITY_DIRECT);
330:
331:                    //if (Debug.verboseOn()) Debug.logVerbose("Allow Direct Request: " + value, module);
332:                    if ("false".equalsIgnoreCase(value))
333:                        return false;
334:                    else
335:                        return true;
336:                } else
337:                    return false;
338:            }
339:
340:            public Collection getFirstVisitEvents() {
341:                Collection c = (Collection) ConfigXMLReader.getConfigMap(
342:                        configFileUrl).get(ConfigXMLReader.FIRSTVISIT);
343:                return c;
344:            }
345:
346:            public Collection getPreProcessor() {
347:                Collection c = (Collection) ConfigXMLReader.getConfigMap(
348:                        configFileUrl).get(ConfigXMLReader.PREPROCESSOR);
349:                return c;
350:            }
351:
352:            public Collection getPostProcessor() {
353:                Collection c = (Collection) ConfigXMLReader.getConfigMap(
354:                        configFileUrl).get(ConfigXMLReader.POSTPROCESSOR);
355:                return c;
356:            }
357:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.