KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > legacy > CmsLegacyException


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/legacy/CmsLegacyException.java,v $
3  * Date : $Date: 2005/09/11 13:27:06 $
4  * Version: $Revision: 1.13 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (C) 2002 - 2005 Alkacon Software (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package com.opencms.legacy;
33
34 import org.opencms.i18n.CmsMessageContainer;
35 import org.opencms.main.CmsException;
36 import org.opencms.main.I_CmsThrowable;
37
38 import java.util.Locale JavaDoc;
39
40 /**
41  * Exception to keep the legacy packages com.opencms.* and com.opencms.*
42  * with the old exception handling mechanism running.<p>
43  *
44  * @author Alexander Kandzior (a.kandzior@alkacon.com)
45  * @author Michael Emmerich (m.emmerich@alkacon.com)
46  * @author Michael Moossen (m.moossen@alkacon.com)
47  * @author Jan Baudisch (j.baudisch@alkacon.com)
48  *
49  * @version $Revision: 1.13 $
50  */

51 public class CmsLegacyException extends CmsException implements I_CmsThrowable {
52
53     /** Serial version UID required for safe serialization. */
54     private static final long serialVersionUID = -276358443570364537L;
55
56     /**
57      * MessageContainer with string-constructor, to be used only in this class.
58      * CmsLegacyMessageContainers are not localized. <p>
59      */

60     private static class CmsLegacyMessageContainer extends CmsMessageContainer {
61         
62         /**
63          * Creates a new message container with the specified message.<p>
64          *
65          * @param message the message to use
66          */

67         public CmsLegacyMessageContainer(String JavaDoc message) {
68
69             super(Messages.get(), message);
70         }
71         
72         /**
73          * Returns the message described by this container.<p>
74          *
75          * @return the message described by this container
76          */

77         public String JavaDoc key() {
78
79             return getKey();
80         }
81
82         /**
83          * Returns the message described by this container. The message is not localized and the locale argument will
84          * not be taken into account.<p>
85          *
86          * @param locale the locale to use
87          * @return the message described by this container
88          */

89         public String JavaDoc key(Locale JavaDoc locale) {
90
91             return getKey();
92         }
93
94     }
95     
96     /**
97      * This array provides descriptions for the error codes stored as
98      * constants in the CmsLegacyExeption class.
99      */

100     public static final String JavaDoc[] C_ERROR_DESCRIPTION = {
101     /* 0 */"Unknown exception",
102     /* 1 */"Access denied",
103     /* 2 */null,
104     /* 3 */"Bad name",
105     /* 4 */null,
106     /* 5 */null,
107     /* 6 */"Admin access required",
108     /* 7 */null,
109     /* 8 */"Unknown User Group",
110     /* 9 */"Group not empty",
111     /* 10 */"Unknown User",
112     /* 11 */"No removal from Default Group",
113     /* 12 */null,
114     /* 13 */"File not found exception",
115     /* 14 */"Filesystem exception",
116     /* 15 */"Internal use only",
117     /* 16 */"Deprecated exception: File-property is mandatory",
118     /* 17 */"Service unavailable",
119     /* 18 */"Unknown XML datablock",
120     /* 19 */"Corrupt internal structure",
121     /* 20 */"Wrong XML content type",
122     /* 21 */"XML parsing error",
123     /* 22 */"Could not process OpenCms special XML tag",
124     /* 23 */"Could not call user method",
125     /* 24 */"Could not call process method",
126     /* 25 */"XML tag missing",
127     /* 26 */"Wrong XML template class",
128     /* 27 */"No XML template class",
129     /* 28 */null,
130     /* 29 */"OpenCms class loader error",
131     /* 30 */"New password is too short",
132     /* 31 */null,
133     /* 32 */null,
134     /* 33 */"DriverManager init error",
135     /* 34 */"Registry error",
136     /* 35 */"Security Manager initialization error",
137     /* 36 */null,
138     /* 37 */"Wrong scheme for http resource",
139     /* 38 */"Wrong scheme for https resource",
140     /* 39 */"Error in Flex cache",
141     /* 40 */"Error in Flex loader",
142     /* 41 */"Group already exists",
143     /* 42 */"User already exists",
144     /* 43 */"Import error",
145     /* 44 */"Export error",
146     /* 45 */"Resource is not locked",
147     /* 46 */"Insufficient lock to edit content of resource",
148     /* 47 */"Resource locked by another user",
149     /* 48 */"Administrator priviledges are required to perform this operation",
150     /* 49 */"Project manager priviledges are required to perform this operation",
151     /* 50 */"Modify operation not allowed in 'Online' project",
152     /* 51 */"No permissions to perform this operation",
153     /* 52 */"Invalid password",
154     /* 53 */"OpenCms login validation failed",
155     /* 54 */"Error while loading invoking resource loader",
156     /* 55 */"Resource loader not template enabled",
157     /* 56 */"Unknown resource type requested!"};
158
159
160     /** Error code for unknown exception.*/
161     public static final int C_UNKNOWN_EXCEPTION = 0;
162
163     /** Error code for not found exception.*/
164     public static final int C_NOT_FOUND = 2;
165
166     /** Error code for bad name exception. */
167     public static final int C_BAD_NAME = 3;
168
169     /** Error code for sql exception.*/
170     public static final int C_SQL_ERROR = 4;
171
172     /** Error code for not empty exception.*/
173     public static final int C_NOT_EMPTY = 5;
174
175     /** Error code for no admin exception. */
176     public static final int C_NOT_ADMIN = 6;
177
178     /** Generic error code for loader errors. */
179     public static final int C_LOADER_GENERIC_ERROR = 54;
180
181     /** Error code for no group exception. */
182     public static final int C_NO_GROUP = 8;
183
184     /** Error code for no user exception. */
185     public static final int C_NO_USER = 10;
186
187     /** Error code service unavailable. */
188     public static final int C_SERVICE_UNAVAILABLE = 17;
189
190     /** Error code for unknown XML datablocks. */
191     public static final int C_XML_UNKNOWN_DATA = 18;
192
193     /** Error code for corrupt internal structure. */
194     public static final int C_XML_CORRUPT_INTERNAL_STRUCTURE = 19;
195
196     /** Error code for wrong XML content type. */
197     public static final int C_XML_WRONG_CONTENT_TYPE = 20;
198
199     /** Error code for XML process method not found. */
200     public static final int C_XML_NO_PROCESS_METHOD = 24;
201
202     /** Error code for XML parsing error. */
203     public static final int C_XML_PARSING_ERROR = 21;
204
205     /** Error code for XML processing error. */
206     public static final int C_XML_PROCESS_ERROR = 22;
207
208     /** Error code for XML user method not found. */
209     public static final int C_XML_NO_USER_METHOD = 23;
210
211     /** Error code for missing XML tag. */
212     public static final int C_XML_TAG_MISSING = 25;
213
214     /** Error code for wrong XML template class. */
215     public static final int C_XML_WRONG_TEMPLATE_CLASS = 26;
216
217     /** Error code for no XML template class. */
218     public static final int C_XML_NO_TEMPLATE_CLASS = 27;
219
220     /** Error code for ClassLoader errors. */
221     public static final int C_CLASSLOADER_ERROR = 29;
222
223     /** Error code for Registry exception. */
224     public static final int C_REGISTRY_ERROR = 34;
225
226     /** A resource is unlocked, but a particular action requires the resource to be locked. */
227     public static final int C_RESOURCE_UNLOCKED = 45;
228
229     /** A resource has a non-exclusive lock, but a particular action requires an exclusive lock. */
230     public static final int C_RESOURCE_LOCKED_NON_EXCLUSIVE = 46;
231
232     /** A resource is locked by a user different from the current user, but a particular action requires that the resource is locked by the current user. */
233     public static final int C_RESOURCE_LOCKED_BY_OTHER_USER = 47;
234
235     /** Invalid password (only for password change and validation of password). */
236     public static final int C_SECURITY_INVALID_PASSWORD = 52;
237
238     /** Stores the error code of the CmsLegacyException. */
239     protected int m_type;
240
241     /**
242      * Creates a new localized Exception.<p>
243      *
244      * @param message the localized message container to use
245      */

246     public CmsLegacyException(CmsMessageContainer message) {
247
248         super(message);
249     }
250
251     /**
252      * Creates a new localized Exception that also containes a root cause.<p>
253      *
254      * @param message the localized message container to use
255      * @param cause the Exception root cause
256      */

257     public CmsLegacyException(CmsMessageContainer message, Throwable JavaDoc cause) {
258
259         super(message, cause);
260     }
261
262     /**
263      * Creates a CmsLegacyException with the provided error code,
264      * the error codes used should be the constants from the CmsEception class or subclass.<p>
265      *
266      * @param type exception error code
267      */

268     public CmsLegacyException(int type) {
269
270         super(new CmsLegacyMessageContainer(CmsLegacyException.getErrorDescription(type)));
271         m_type = type;
272     }
273
274     /**
275      * Creates a CmsLegacyException with the provided error code and
276      * a given root cause.<p>
277      *
278      * The error codes used should be the constants from the CmsLegacyException class or subclass.<p>
279      *
280      * @param type exception error code
281      * @param cause root cause exception
282      */

283     public CmsLegacyException(int type, Throwable JavaDoc cause) {
284
285         super(new CmsLegacyMessageContainer(CmsLegacyException.getErrorDescription(type)));
286         initCause(cause);
287         m_type = type;
288     }
289
290     /**
291      * Creates a CmsLegacyException with the provided description message.<p>
292      *
293      * @param message the description message
294      */

295     public CmsLegacyException(String JavaDoc message) {
296
297         super(new CmsLegacyMessageContainer(message));
298     }
299
300     /**
301      * Creates a CmsLegacyException with the provided description message and error code.<p>
302      *
303      * @param message the description message
304      * @param type exception error code
305      */

306     public CmsLegacyException(String JavaDoc message, int type) {
307
308         super(new CmsLegacyMessageContainer(message));
309         m_type = type;
310     }
311
312     /**
313      * Creates a CmsLegacyException with the provided description message, error code and
314      * a given root cause.<p>
315      *
316      * @param message the description message
317      * @param type exception error code
318      * @param cause root cause exception
319      */

320     public CmsLegacyException(String JavaDoc message, int type, Throwable JavaDoc cause) {
321
322         super(new CmsLegacyMessageContainer(message));
323         initCause(cause);
324         m_type = type;
325     }
326
327     /**
328      * Construtcs a CmsLegacyException with the provided description message and
329      * a given root cause.<p>
330      *
331      * @param message the description message
332      * @param cause root cause exception
333      */

334     public CmsLegacyException(String JavaDoc message, Throwable JavaDoc cause) {
335
336         super(new CmsLegacyMessageContainer(message));
337         initCause(cause);
338     }
339
340     /**
341      * Creates a copied instance of this localized exception.<p>
342      *
343      * @param container the message container
344      * @param cause the root cause
345      *
346      * @return a copied instance of this localized exception
347      */

348     public CmsException createException(CmsMessageContainer container, Throwable JavaDoc cause) {
349
350         return new CmsLegacyException(container, cause);
351     }
352
353     /**
354      * Returns the type of the CmsLegacyException.<p>
355      *
356      * @return the type of the CmsLegacyException
357      */

358     public int getType() {
359
360         return m_type;
361     }
362
363     /**
364      * Returns the description String for the provided CmsLegacyException type, subclasses of
365      * CmsLegacyException should overwrite this method for the types they define.<p>
366      *
367      * @param type exception error code
368      * @return the description String for the provided CmsLegacyException type
369      */

370     protected static String JavaDoc getErrorDescription(int type) {
371
372         if ((type < CmsLegacyException.C_ERROR_DESCRIPTION.length) && (type > 0)) {
373             return CmsLegacyException.C_ERROR_DESCRIPTION[type];
374         } else {
375             return CmsLegacyException.class.getName();
376         }
377     }
378 }
Popular Tags