KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > exceptions > JahiaException


1 /*
2  * ____.
3  * __/\ ______| |__/\. _______
4  * __ .____| | \ | +----+ \
5  * _______| /--| | | - \ _ | : - \_________
6  * \\______: :---| : : | : | \________>
7  * |__\---\_____________:______: :____|____:_____\
8  * /_____|
9  *
10  * . . . i n j a h i a w e t r u s t . . .
11  *
12  *
13  *
14  * ----- BEGIN LICENSE BLOCK -----
15  * Version: JCSL 1.0
16  *
17  * The contents of this file are subject to the Jahia Community Source License
18  * 1.0 or later (the "License"); you may not use this file except in
19  * compliance with the License. You may obtain a copy of the License at
20  * http://www.jahia.org/license
21  *
22  * Software distributed under the License is distributed on an "AS IS" basis,
23  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
24  * for the rights, obligations and limitations governing use of the contents
25  * of the file. The Original and Upgraded Code is the Jahia CMS and Portal
26  * Server. The developer of the Original and Upgraded Code is JAHIA Ltd. JAHIA
27  * Ltd. owns the copyrights in the portions it created. All Rights Reserved.
28  *
29  * The Shared Modifications are Jahia View Helper.
30  *
31  * The Developer of the Shared Modifications is Jahia Solution Sarl.
32  * Portions created by the Initial Developer are Copyright (C) 2002 by the
33  * Initial Developer. All Rights Reserved.
34  *
35  * Contributor(s):
36  * 31-OCT-2000, Xo3 SA, Eric Vassalli : Initial version
37  * 08-JAN-2001, Xo3 SA, Fulco Houkes
38  * 15-SEP-2003, Jahia Solutions Sarl, Fulco Houkes
39  *
40  * ----- END LICENSE BLOCK -----
41  */

42
43
44 package org.jahia.exceptions;
45
46 import java.io.PrintStream JavaDoc;
47 import java.io.PrintWriter JavaDoc;
48
49 public class JahiaException extends Exception JavaDoc
50 {
51     private static org.apache.log4j.Logger logger =
52             org.apache.log4j.Logger.getLogger(JahiaException.class);
53
54     public static final int WARNING_SEVERITY = 1;
55     public static final int ERROR_SEVERITY = 2;
56     public static final int CRITICAL_SEVERITY = 3;
57     public static final int KISSYOURASSGOODBYE_SEVERITY = 4;
58
59     public static final int INITIALIZATION_ERROR = 0;
60     public static final int DATABASE_ERROR = 1;
61     public static final int FILE_ERROR = 2;
62     public static final int DATA_ERROR = 3;
63     public static final int TEMPLATE_ERROR = 4;
64     public static final int PERSISTENCE_ERROR = 5;
65
66
67     /** User error code */
68     public static final int USER_ERROR = 5;
69
70     /** Page error code */
71     public static final int PAGE_ERROR = 6;
72
73     public static final int WINDOW_ERROR = 7;
74     public static final int PARAMETER_ERROR = 8;
75     public static final int APPLICATION_ERROR = 9;
76     public static final int NEWSFEED_ERROR = 10;
77     public static final int CONFIG_ERROR = 11;
78     public static final int SERVICE_ERROR = 12;
79     public static final int REGISTRY_ERROR = 13;
80     public static final int SERVLET_ERROR = 14;
81     public static final int LISTENER_ERROR = 15;
82
83     /** Security error code (Access denied) */
84     public static final int SECURITY_ERROR = 16;
85
86     /** Access Control List error code */
87     public static final int ACL_ERROR = 17;
88
89     public static final int CACHE_ERROR = 18;
90     public static final int OBJECT_ERROR = 19;
91     public static final int ENGINE_ERROR = 20;
92
93     /** Lock error code */
94     public static final int LOCK_ERROR = 21;
95
96     /** Session error code */
97     public static final int SESSION_ERROR = 22;
98
99     /** Accounts error code */
100     protected static final int ACCOUNTS_ERROR = 23;
101
102     /** License error code */
103     protected static final int LICENSE_ERROR = 24;
104
105     /** Jef file error code */
106     public static final int JEF_ERROR = 25;
107
108     /** Java Security ERROR */
109     public static final int JAVASECURITY_ERROR = 26;
110
111     /** Engine Validation Errors */
112     public static final int ENGINE_VALIDATION_ERROR = 27;
113     
114     /** Service unavailable ERROR */
115     public static final int UNAVAILABLE_ERROR = 28;
116
117     /** Archive File error code **/
118     public static final int ENTRY_NOT_FOUND = 30;
119
120     /** Site not found **/
121     public static final int SITE_NOT_FOUND = 40;
122
123
124     protected String JavaDoc mUserErrorMsg;
125     protected String JavaDoc mJahiaErrorMsg;
126     protected int mErrorCode;
127     protected int mErrorSeverity;
128     protected Throwable JavaDoc mRootCauseException;
129
130
131
132     //-------------------------------------------------------------------------
133
/**
134      * constructor
135      * EV 31.10.2000
136      *
137      */

138     public JahiaException (String JavaDoc userErrorMsg,
139                             String JavaDoc jahiaErrorMsg,
140                             int errorCode,
141                             int errorSeverity)
142     {
143         super (userErrorMsg + ", " + jahiaErrorMsg);
144
145         mUserErrorMsg = userErrorMsg;
146         mJahiaErrorMsg = jahiaErrorMsg;
147         mErrorCode = errorCode;
148         mErrorSeverity = errorSeverity;
149
150     } // end constructor
151

152     /**
153      * This exception constructor allows us to keep the original exception information
154      * so that we may display it and access more details about the real cause
155      * of the exception. Hopefully the need for this will disappear with the
156      * introduction of exception chaining in JDK 1.4
157      */

158     public JahiaException (String JavaDoc userErrorMsg,
159                             String JavaDoc jahiaErrorMsg,
160                             int errorCode,
161                             int errorSeverity,
162                             Throwable JavaDoc t)
163     {
164         super (userErrorMsg + ", " + jahiaErrorMsg + ", root cause:" + ((t == null) ? "null" : t.getMessage()));
165
166         mUserErrorMsg = userErrorMsg;
167         mJahiaErrorMsg = jahiaErrorMsg;
168         mErrorCode = errorCode;
169         mErrorSeverity = errorSeverity;
170         mRootCauseException = t;
171
172     }
173
174
175     //-------------------------------------------------------------------------
176
/**
177      * getSeverity
178      * EV 31.10.2000
179      *
180      */

181     public int getSeverity()
182     {
183         return mErrorSeverity;
184     } // end getSeverity
185

186
187     //-------------------------------------------------------------------------
188
// FH 8 Jan. 20001
189
/**
190      * Return a string holding the user readeable error message.
191      *
192      * @return Return a string of the user error message.
193      */

194     public final String JavaDoc getUserErrorMsg ()
195     {
196         return mUserErrorMsg;
197     }
198
199
200     //-------------------------------------------------------------------------
201
// FH 8 Jan. 20001
202
/**
203      * Return a string holding the internal (jahia) error message.
204      *
205      * @return Return a string of the internal error message.
206      */

207     public final String JavaDoc getJahiaErrorMsg ()
208     {
209         return mJahiaErrorMsg;
210     }
211
212
213     //-------------------------------------------------------------------------
214
// FH 8 Jan. 20001
215
/**
216      * Return the error code.
217      *
218      * @return Return the error code.
219      */

220     public final int getErrorCode ()
221     {
222         return mErrorCode;
223     }
224
225     /**
226      * Accessor method for the root cause exception.
227      * @return Throwable the return value is an exception OR can be null in
228      * which case this signifies we didn't specify at creation the original source
229      * of the exception (or that this was an original exception we generated and
230      * didn't need to catch).
231      */

232     public final Throwable JavaDoc getRootCause() {
233         return mRootCauseException;
234     }
235
236     // the following methods exists so that we always print out details
237
// about the root cause if there is one.
238

239     public String JavaDoc toString() {
240         logger.debug("called.");
241         StringBuffer JavaDoc result = new StringBuffer JavaDoc();
242         result.append(super.toString());
243         if (getRootCause() != null) {
244             result.append(" root cause=");
245             result.append(getRootCause().toString());
246         }
247         return result.toString();
248     }
249
250     public void printStackTrace(PrintWriter JavaDoc s) {
251         logger.debug("(PrintWriter s) called.");
252         super.printStackTrace(s);
253         /*
254         if (getRootCause() != null) {
255             getRootCause().printStackTrace(s);
256         }
257         */

258     }
259
260     public void printStackTrace(PrintStream JavaDoc s) {
261         logger.debug("(PrintStream s) called.");
262         super.printStackTrace(s);
263         /*
264         if (getRootCause() != null) {
265             getRootCause().printStackTrace(s);
266         }
267         */

268     }
269
270     public void printStackTrace() {
271         logger.debug("() called.");
272         super.printStackTrace();
273         /*
274         if (getRootCause() != null) {
275             getRootCause().printStackTrace();
276         }
277         */

278     }
279
280 } // end JahiaException
281

282
283
Popular Tags