KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > extensions > ExtensionException


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.extensions;
21
22 import javax.servlet.http.HttpSession JavaDoc;
23
24 import org.apache.struts.util.MessageResources;
25 import org.apache.struts.util.MessageResourcesFactory;
26 import org.apache.struts.util.PropertyMessageResources;
27
28 import com.sslexplorer.core.CoreException;
29 import com.sslexplorer.core.CoreServlet;
30
31 /**
32  * Specialisation of {@link CoreException} for exceptions generate during use of
33  * <i>Extensions</i>.
34  *
35  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
36  */

37 public class ExtensionException extends CoreException {
38     /**
39      * Extension requires agent which is not available
40      */

41     public final static int NO_AGENT = 1;
42
43     /**
44      * The agent refused to launch the application
45      */

46     public final static int AGENT_REFUSED_LAUNCH = 2;
47
48     /**
49      * Generic failed to launch error
50      */

51     public final static int FAILED_TO_LAUNCH = 3;
52
53     /**
54      * A request for an unknown application extension has been made.
55      */

56     public final static int INVALID_EXTENSION = 4;
57
58     /**
59      * Generic internal error processing an extension.
60      */

61     public static final int INTERNAL_ERROR = 5;
62
63     /**
64      * Failed to parse descriptor. The XML descriptor could not be parsed
65      * because something is fundamentally wrong with the format of the file.
66      */

67     public static final int FAILED_TO_PARSE_DESCRIPTOR = 6;
68
69     /**
70      * Unknown extension type. Arg0 is the requested type, Arg1 is the id of the
71      * extension bundle attempting to use the type
72      */

73     public static final int UNKNOWN_EXTENSION_TYPE = 7;
74
75     /**
76      * The descriptor was passed but contains invalid details.
77      */

78     public static final int FAILED_TO_PROCESS_DESCRIPTOR = 8;
79
80     /**
81      * The version of SSL-Explorer hosting the plugin is not sufficient. Arg0 is
82      * the plugin name, Arg1 is the required version
83      */

84     public static final int INSUFFICIENT_SSLEXPLORER_HOST_VERSION = 9;
85
86     /**
87      * The plugin instance could not be created for some reason. Arg0 will be
88      * the plugin name, Arg1 will be the plugin class name and Arg2 will be the
89      * error text.
90      */

91     public static final int FAILED_TO_CREATE_PLUGIN_INSTANCE = 10;
92
93     /**
94      * The bundle is not in the required state for the requested operation. Arg0
95      * will contain the bundle name and Arg1 will contain any additional
96      * information.
97      */

98     public static final int INVALID_EXTENSION_BUNDLE_STATUS = 11;
99
100     /**
101      * Unknown plugin. Arg0 is the plugin id
102      */

103     public static final int UNKNOWN_PLUGIN = 12;
104
105     /**
106      * An attempt was made to start an extension that requires a dependency that
107      * is not installed. Arg0 is the dependency name required, Arg1 is the
108      * bundle that requries the dependency.
109      */

110     public static final int DEPENDENCY_NOT_INSTALLED = 13;
111
112     /**
113      * An attempt was made to start an extension that requires a dependency that
114      * is not started. Arg0 is the dependency name required, Arg1 is the bundle
115      * that requries the dependency.
116      */

117     public static final int DEPENDENCY_NOT_STARTED = 14;
118
119     /**
120      * Licensing error. Arg0 is the message.
121      */

122     public static final int LICENSE_ERROR = 15;
123
124     /**
125      * Attempt to load an extension that replaces a <i>devExtens</i>
126      */

127     public static final int CANNOT_REPLACE_DEV_EXTENSION = 16;
128
129     /**
130      * Error category
131      */

132     public final static String JavaDoc ERROR_CATEGORY = "extensions";
133
134     /**
135      * Constructor.
136      *
137      * @param code
138      */

139     public ExtensionException(int code) {
140         super(code, ERROR_CATEGORY);
141     }
142
143     /**
144      * Constructor.
145      *
146      * @param code
147      * @param bundle
148      * @param cause
149      * @param arg0
150      * @param arg1
151      * @param arg2
152      * @param arg3
153      */

154     public ExtensionException(int code, String JavaDoc bundle, Throwable JavaDoc cause, String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2, String JavaDoc arg3) {
155         super(code, ERROR_CATEGORY, bundle, cause, arg0, arg1, arg2, arg3);
156     }
157
158     /**
159      * Constructor.
160      *
161      * @param code
162      * @param bundle
163      * @param cause
164      * @param arg0
165      */

166     public ExtensionException(int code, String JavaDoc bundle, Throwable JavaDoc cause, String JavaDoc arg0) {
167         super(code, ERROR_CATEGORY, bundle, cause, arg0);
168     }
169
170     /**
171      * Constructor.
172      *
173      * @param code
174      * @param bundle
175      * @param cause
176      */

177     public ExtensionException(int code, String JavaDoc bundle, Throwable JavaDoc cause) {
178         super(code, ERROR_CATEGORY, bundle, cause);
179     }
180
181     /**
182      * Constructor.
183      *
184      * @param code
185      * @param arg0
186      */

187     public ExtensionException(int code, String JavaDoc arg0) {
188         super(code, ERROR_CATEGORY, arg0);
189     }
190
191     /**
192      * Constructor.
193      *
194      * @param code
195      * @param arg0
196      * @param arg1
197      */

198     public ExtensionException(int code, String JavaDoc arg0, String JavaDoc arg1) {
199         super(code, ERROR_CATEGORY, DEFAULT_BUNDLE, null, arg0, arg1, null, null);
200     }
201
202     /**
203      * Constructor.
204      *
205      * @param code
206      * @param cause
207      */

208     public ExtensionException(int code, Throwable JavaDoc cause) {
209         super(code, ERROR_CATEGORY, DEFAULT_BUNDLE, cause, cause.getMessage());
210     }
211
212     /**
213      * Constructor.
214      *
215      * @param code
216      * @param cause
217      * @param arg0
218      */

219     public ExtensionException(int code, Throwable JavaDoc cause, String JavaDoc arg0) {
220         super(code, ERROR_CATEGORY, DEFAULT_BUNDLE, cause, arg0);
221     }
222
223     /**
224      * Constructor.
225      *
226      * @param code
227      * @param arg0
228      * @param arg1
229      * @param arg2
230      * @param cause
231      */

232     public ExtensionException(int code, String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2, Throwable JavaDoc cause) {
233         super(code, ERROR_CATEGORY, DEFAULT_BUNDLE, cause, arg0, arg1, arg2, null);
234     }
235
236     protected MessageResources getMessageResources(String JavaDoc bundleName) {
237         MessageResources mr = (MessageResources) CoreServlet.getServlet().getServletContext().getAttribute(getBundle());
238         if(mr == null) {
239             MessageResourcesFactory fact = new ExceptionMessageResourcesFactory();
240             mr = fact.createResources("com.sslexplorer.errors.ApplicationResources");
241         }
242         return mr;
243     }
244
245     class ExceptionMessageResourcesFactory extends MessageResourcesFactory {
246
247         public MessageResources createResources(String JavaDoc config) {
248             return new PropertyMessageResources(this, config, true);
249         }
250
251     }
252 }
253
Popular Tags