Source Code Cross Referenced for ClarosBaseException.java in  » Chat » claros-intouch » org » claros » commons » exception » 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 » Chat » claros intouch » org.claros.commons.exception 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.claros.commons.exception;
002:
003:        import java.io.ByteArrayOutputStream;
004:        import java.io.IOException;
005:        import java.io.PrintStream;
006:
007:        import javax.servlet.ServletException;
008:
009:        import org.apache.commons.configuration.Configuration;
010:        import org.apache.commons.configuration.PropertiesConfiguration;
011:        import org.apache.commons.logging.Log;
012:        import org.apache.commons.logging.LogFactory;
013:        import org.claros.commons.configuration.Paths;
014:        import org.claros.commons.configuration.PropertyFile;
015:        import org.claros.commons.utility.Utility;
016:
017:        /**
018:         * @author Umut Gokbayrak
019:         */
020:        public class ClarosBaseException extends ServletException {
021:            private static final long serialVersionUID = -2268010989574881830L;
022:            private static Log log = LogFactory
023:                    .getLog(ClarosBaseException.class);
024:            private String errorKey;
025:            private String userMessage;
026:            private String systemMessage;
027:            private Exception nestedException;
028:            private static Configuration msgs;
029:
030:            public ClarosBaseException() {
031:                super ();
032:            }
033:
034:            public ClarosBaseException(String errorKey) {
035:                this .errorKey = errorKey;
036:                this .userMessage = msgs.getString(this .errorKey);
037:                log.error("An exception is created. Message: " + userMessage);
038:            }
039:
040:            public ClarosBaseException(Exception nestedException,
041:                    String errorKey) {
042:                this .nestedException = nestedException;
043:
044:                ByteArrayOutputStream bOut = new ByteArrayOutputStream();
045:                PrintStream out = new PrintStream(bOut);
046:                this .nestedException.printStackTrace(out);
047:                this .systemMessage = bOut.toString();
048:                try {
049:                    bOut.close();
050:                } catch (IOException e) {
051:                }
052:                this .errorKey = errorKey;
053:                this .userMessage = msgs.getString(errorKey);
054:                log.error("An exception is created. Message: " + userMessage);
055:            }
056:
057:            public ClarosBaseException(Exception nestedException) {
058:                this .nestedException = nestedException;
059:
060:                ByteArrayOutputStream bOut = new ByteArrayOutputStream();
061:                PrintStream out = new PrintStream(bOut);
062:                this .nestedException.printStackTrace(out);
063:                this .systemMessage = bOut.toString();
064:                log.error("An exception is created. System Message: "
065:                        + this .systemMessage);
066:                try {
067:                    bOut.close();
068:                } catch (IOException e) {
069:                }
070:            }
071:
072:            static {
073:                try {
074:                    String configPath = "/config/config.xml";
075:                    Configuration configXml = PropertyFile
076:                            .getConfiguration(configPath);
077:                    String resourceType = configXml
078:                            .getString("error-handling.resource-type");
079:                    if (resourceType != null) {
080:                        if (resourceType.equals("FILE")) {
081:                            log
082:                                    .debug("Error messages are read from FILE resource");
083:                            String resourceFile = configXml
084:                                    .getString("error-handling.resource-path");
085:                            if (resourceFile != null) {
086:                                if (resourceFile.indexOf("%respath%") >= 0) {
087:                                    resourceFile = Utility
088:                                            .replaceAllOccurances(resourceFile,
089:                                                    "%respath%", Paths
090:                                                            .getResFolder());
091:                                }
092:                                log.debug("Error messages are read from path: "
093:                                        + resourceFile);
094:                                msgs = new PropertiesConfiguration(resourceFile);
095:                                log
096:                                        .debug("Error messages file initialized successfully");
097:                            }
098:                        } else if (resourceType.equals("DB")) {
099:                            // TODO: not implemented yet
100:                        }
101:                    } else {
102:                        //				log.fatal("Could not initialize error messages file. Check the config-error statements in config.xml file. resource-type can not be read.");
103:                    }
104:                } catch (Exception e) {
105:                    //			log.fatal("Could not initialize error messages file. Check the config-error statements in config.xml file", e);
106:                }
107:            }
108:
109:            public String getErrorKey() {
110:                return errorKey;
111:            }
112:
113:            public void setErrorKey(String errorKey) {
114:                this .errorKey = errorKey;
115:            }
116:
117:            public String getUserMessage() {
118:                return userMessage;
119:            }
120:
121:            public void setUserMessage(String userMessage) {
122:                this .userMessage = userMessage;
123:            }
124:
125:            public String getSystemMessage() {
126:                return systemMessage;
127:            }
128:
129:            public void setSystemMessage(String systemMessage) {
130:                this.systemMessage = systemMessage;
131:            }
132:
133:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.