Source Code Cross Referenced for WebmanExceptionHandler.java in  » Content-Management-System » webman » com » teamkonzept » webman » mainint » 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 » Content Management System » webman » com.teamkonzept.webman.mainint 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.teamkonzept.webman.mainint;
002:
003:        import java.text.MessageFormat;
004:        import java.util.*;
005:        import java.sql.SQLException;
006:        import com.teamkonzept.lib.*;
007:        import org.apache.log4j.Category;
008:        import com.teamkonzept.db.*;
009:        import com.teamkonzept.web.*;
010:        import com.teamkonzept.webman.mainint.events.*;
011:        import com.teamkonzept.international.*;
012:
013:        /**
014:         Webman specific exception handler
015:         provides logging and output to the user
016:         * @author  $Author: alexandergrosse $
017:         * @version $Revision: 1.20.6.2 $
018:        
019:         */
020:        public class WebmanExceptionHandler extends DefaultExceptionHandler
021:                implements  TKEventHandler, ErrorCodes {
022:            /** Logging Category */
023:            private static Category cat = Category
024:                    .getInstance(WebmanExceptionHandler.class);
025:
026:            /** Logging Views */
027:            /*
028:            private final static String ALL = "AllErrors";
029:
030:            private final static String HIGH = "High";
031:            private final static String NORMAL = "Normal";
032:            private final static String USER = "Usr";
033:            private final static String TEMPORARY = "Temp";
034:             */
035:            private static final String CONTEXT = "ErrorCodes";
036:
037:            private static WebmanExceptionHandler instance = new WebmanExceptionHandler();
038:
039:            private WebmanExceptionHandler() {
040:                LanguageManager.registerContext("/" + CONTEXT, this );
041:            }
042:
043:            public static WebmanExceptionHandler getInstance() {
044:                return instance;
045:            }
046:
047:            /** Developer Mode means more detailled information on the web client */
048:            private static boolean developerMode = false;
049:
050:            /**
051:            	@return true, if the connections must be closed
052:             */
053:            public static boolean handleException(TKException e, TKEvent evt) {
054:                if (e != null) {
055:                    int code = e.getErrorCode();
056:                    try {
057:                        int sev = e.getSeverity();
058:                        Throwable t = e.getOriginalException();
059:
060:                        if (sev == HIGH_SEVERITY)
061:                            cat
062:                                    .fatal("caught HIGH_SEVERITY",
063:                                            t == null ? e : t);
064:                        else if (sev == NORMAL_SEVERITY)
065:                            cat.error("caught NORMAL", t == null ? e : t);
066:                        else if (sev == USER_SEVERITY)
067:                            cat.warn("caught USER", t == null ? e : t);
068:                        else if (sev == TEMPORARY_SEVERITY)
069:                            cat.warn("caught TEMPORARY", t == null ? e : t);
070:                        TKHTMLTemplate template = evt
071:                                .getPrepHTMLTemplate("error_message.tmpl");
072:                        String title;
073:                        if (e instanceof  TKDatabaseException) {
074:                            title = LanguageManager.getText(CONTEXT,
075:                                    "DatabaseError", null);
076:
077:                        } else if (e instanceof  TKUserException) {
078:                            title = LanguageManager.getText(CONTEXT,
079:                                    "UserError", null);
080:                        } else if (e instanceof  TKConfigurationException) {
081:                            title = LanguageManager.getText(CONTEXT,
082:                                    "ConfigurationError", null);
083:                        } else {
084:                            title = LanguageManager.getText(CONTEXT,
085:                                    "InternalError", null);
086:                        }
087:                        template.set("ERROR_TITLE", title);
088:                        template.set("ERROR_USER_TEXT", getErrorText(String
089:                                .valueOf(code), e.getArguments()));
090:                        if (developerMode || e.isPublic()) {
091:                            String text = /*"<pre>" + e.toString() + "</pre>" +*/e
092:                                    .getFullStackTrace();
093:                            template.set("ERROR_TEXT", text);
094:                        } else {
095:                            // eigentlich gar nichts machen
096:                            template.set("ERROR_TEXT", ""/*e.getMessage()*/);
097:                        }
098:                        evt.finishTemplate(template);
099:                    } catch (Throwable th) {
100:                        // was jetzt ? Hilfe !!!
101:                        cat.error("Fehler im EventHandler: ", th);
102:                        throw new Error(th.getMessage());
103:                    }
104:                    return (code & DATABASE) > 0;
105:                } else {
106:                    cat.error("Null Exception im ExceptionHandler !!!");
107:                    return true;
108:                }
109:            }
110:
111:            /** handles the event */
112:            public void handleEvent(TKEvent evt) throws TKException {
113:                String event = evt.getName();
114:                if (event.equalsIgnoreCase("TR_DEVELOPER"))
115:                    developerMode = true;
116:                else if (event.equalsIgnoreCase("TR_USER"))
117:                    developerMode = false;
118:                /*else if (event.equalsIgnoreCase("TR_CHANGELOG"))
119:                	;//changeLogMode(evt);     */
120:                else
121:                    throw new TKException("Invalid Event: " + event,
122:                            INVALID_EVENT, NORMAL_SEVERITY, false, null);
123:            }
124:
125:            /** returns true, if it wants to handle this event */
126:            public boolean isHandler(TKEvent evt) {
127:                return evt.getName().startsWith("TR");
128:            }
129:
130:            /**
131:            	no further event handling
132:             */
133:            public void addEventHandler(TKEventHandler handler) {
134:            }
135:
136:            /**
137:            	no further event handling
138:             */
139:            public void removeEventHandler(TKEventHandler handler) {
140:            }
141:
142:            public static String getErrorText(String code, Object[] arguments) {
143:                return LanguageManager.getText(CONTEXT, code, arguments);
144:            }
145:
146:            /** setzt die zu behandelnden Events*/
147:            public void setHandleEvents(TKEvent[] events) {
148:            }
149:
150:            /** liefert die zu behandelnden Events zurueck */
151:            public TKEvent[] getHandleEvents() {
152:                return null;
153:            }
154:
155:            /**
156:             * Creates an event object.
157:             *
158:             * @param http the responsible HTTP interface.
159:             * @return an event object.
160:             */
161:            public TKEvent createEvent(TKHttpInterface http) {
162:                return null;
163:            }
164:
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.