1 19 20 package com.sslexplorer.extensions; 21 22 import javax.servlet.http.HttpSession ; 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 37 public class ExtensionException extends CoreException { 38 41 public final static int NO_AGENT = 1; 42 43 46 public final static int AGENT_REFUSED_LAUNCH = 2; 47 48 51 public final static int FAILED_TO_LAUNCH = 3; 52 53 56 public final static int INVALID_EXTENSION = 4; 57 58 61 public static final int INTERNAL_ERROR = 5; 62 63 67 public static final int FAILED_TO_PARSE_DESCRIPTOR = 6; 68 69 73 public static final int UNKNOWN_EXTENSION_TYPE = 7; 74 75 78 public static final int FAILED_TO_PROCESS_DESCRIPTOR = 8; 79 80 84 public static final int INSUFFICIENT_SSLEXPLORER_HOST_VERSION = 9; 85 86 91 public static final int FAILED_TO_CREATE_PLUGIN_INSTANCE = 10; 92 93 98 public static final int INVALID_EXTENSION_BUNDLE_STATUS = 11; 99 100 103 public static final int UNKNOWN_PLUGIN = 12; 104 105 110 public static final int DEPENDENCY_NOT_INSTALLED = 13; 111 112 117 public static final int DEPENDENCY_NOT_STARTED = 14; 118 119 122 public static final int LICENSE_ERROR = 15; 123 124 127 public static final int CANNOT_REPLACE_DEV_EXTENSION = 16; 128 129 132 public final static String ERROR_CATEGORY = "extensions"; 133 134 139 public ExtensionException(int code) { 140 super(code, ERROR_CATEGORY); 141 } 142 143 154 public ExtensionException(int code, String bundle, Throwable cause, String arg0, String arg1, String arg2, String arg3) { 155 super(code, ERROR_CATEGORY, bundle, cause, arg0, arg1, arg2, arg3); 156 } 157 158 166 public ExtensionException(int code, String bundle, Throwable cause, String arg0) { 167 super(code, ERROR_CATEGORY, bundle, cause, arg0); 168 } 169 170 177 public ExtensionException(int code, String bundle, Throwable cause) { 178 super(code, ERROR_CATEGORY, bundle, cause); 179 } 180 181 187 public ExtensionException(int code, String arg0) { 188 super(code, ERROR_CATEGORY, arg0); 189 } 190 191 198 public ExtensionException(int code, String arg0, String arg1) { 199 super(code, ERROR_CATEGORY, DEFAULT_BUNDLE, null, arg0, arg1, null, null); 200 } 201 202 208 public ExtensionException(int code, Throwable cause) { 209 super(code, ERROR_CATEGORY, DEFAULT_BUNDLE, cause, cause.getMessage()); 210 } 211 212 219 public ExtensionException(int code, Throwable cause, String arg0) { 220 super(code, ERROR_CATEGORY, DEFAULT_BUNDLE, cause, arg0); 221 } 222 223 232 public ExtensionException(int code, String arg0, String arg1, String arg2, Throwable cause) { 233 super(code, ERROR_CATEGORY, DEFAULT_BUNDLE, cause, arg0, arg1, arg2, null); 234 } 235 236 protected MessageResources getMessageResources(String 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 config) { 248 return new PropertyMessageResources(this, config, true); 249 } 250 251 } 252 } 253 | Popular Tags |