Commits

Anonymous committed ffaf04b

Renaming XworkException to XWorkException to match the convention of every other class

Issue number: XW-388

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1028e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (20)

src/java/com/opensymphony/xwork/ActionChainResult.java

                 : null;
 
         if (isInChainHistory(finalNamespace, finalActionName, finalMethodName)) {
-            throw new XworkException("infinite recursion detected");
+            throw new XWorkException("infinite recursion detected");
         }
 
         addToHistory(finalNamespace, finalActionName, finalMethodName);

src/java/com/opensymphony/xwork/DefaultActionInvocation.java

                 return ObjectFactory.getObjectFactory().buildResult(resultConfig, invocationContext.getContextMap());
             } catch (Exception e) {
                 LOG.error("There was an exception while instantiating the result of type " + resultConfig.getClassName(), e);
-                throw new XworkException(e, resultConfig);
+                throw new XWorkException(e, resultConfig);
             }
         } else {
             return null;
         try {
             action = ObjectFactory.getObjectFactory().buildAction(proxy.getActionName(), proxy.getNamespace(), proxy.getConfig(), contextMap);
         } catch (InstantiationException e) {
-            throw new XworkException("Unable to intantiate Action!", e, proxy.getConfig());
+            throw new XWorkException("Unable to intantiate Action!", e, proxy.getConfig());
         } catch (IllegalAccessException e) {
-            throw new XworkException("Illegal access to constructor, is it public?", e, proxy.getConfig());
+            throw new XWorkException("Illegal access to constructor, is it public?", e, proxy.getConfig());
         } catch (Exception e) {
             String gripe = "";
 
             }
 
             gripe += (((" -- " + e.getMessage()) != null) ? e.getMessage() : " [no message in exception]");
-            throw new XworkException(gripe, e, proxy.getConfig());
+            throw new XWorkException(gripe, e, proxy.getConfig());
         }
 
         if (ObjectFactory.getContinuationPackage() != null) prepareContinuation();

src/java/com/opensymphony/xwork/XWorkException.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import java.net.URL;
+
+import com.opensymphony.xwork.util.location.Locatable;
+import com.opensymphony.xwork.util.location.Location;
+import com.opensymphony.xwork.util.location.LocationUtils;
+
+
+/**
+ * A generic runtime exception that optionally contains Location information 
+ *
+ * @author Jason Carreira
+ */
+public class XWorkException extends RuntimeException implements Locatable {
+
+    private Location location;
+
+
+    /**
+     * Constructs a <code>XWorkException</code> with no detail message.
+     */
+    public XWorkException() {
+    }
+
+    /**
+     * Constructs a <code>XWorkException</code> with the specified
+     * detail message.
+     *
+     * @param s the detail message.
+     */
+    public XWorkException(String s) {
+        this(s, null, null);
+    }
+    
+    /**
+     * Constructs a <code>XWorkException</code> with the specified
+     * detail message and target.
+     *
+     * @param s the detail message.
+     * @param target the target of the exception.
+     */
+    public XWorkException(String s, Object target) {
+        this(s, (Throwable) null, target);
+    }
+
+    /**
+     * Constructs a <code>XWorkException</code> with the root cause
+     *
+     * @param cause The wrapped exception
+     */
+    public XWorkException(Throwable cause) {
+        this(null, cause, null);
+    }
+    
+    /**
+     * Constructs a <code>XWorkException</code> with the root cause and target
+     *
+     * @param cause The wrapped exception
+     * @param target The target of the exception
+     */
+    public XWorkException(Throwable cause, Object target) {
+        this(null, cause, target);
+    }
+
+    /**
+     * Constructs a <code>XWorkException</code> with the specified
+     * detail message and exception cause.
+     *
+     * @param s the detail message.
+     * @param cause the wrapped exception
+     */
+    public XWorkException(String s, Throwable cause) {
+        this(s, cause, null);
+    }
+    
+    
+     /**
+     * Constructs a <code>XWorkException</code> with the specified
+     * detail message, cause, and target
+     *
+     * @param s the detail message.
+     * @param cause The wrapped exception
+     * @param target The target of the exception
+     */
+    public XWorkException(String s, Throwable cause, Object target) {
+        super(s, cause);
+        
+        this.location = LocationUtils.getLocation(target);
+        if (this.location == Location.UNKNOWN) {
+            this.location = LocationUtils.getLocation(cause);
+        }
+    }
+
+
+    /**
+     * Gets the underlying cause
+     * 
+     * @deprecated Use getCause()
+     */
+    public Throwable getThrowable() {
+        return getCause();
+    }
+
+
+    /**
+     * Gets the location of the error, if available
+     */
+    public Location getLocation() {
+        return this.location;
+    }
+    
+    
+    /**
+     * Gets a source code snippet with the default padding
+     */
+    public List getSnippet() {
+        return getSnippet(2);
+    }
+    
+    
+    /**
+     * Gets a source code snippet with the default padding
+     *
+     * @param padding The amount of lines before and after the error to include
+     */
+    public List getSnippet(int padding) {
+        List snippet = new ArrayList();
+        if (location != null && location.getLineNumber() > 0) {
+            try {
+                InputStream in = new URL(location.getURI()).openStream();
+                BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+                
+                int lineno = 0;
+                int errno = location.getLineNumber();
+                String line;
+                while ((line = reader.readLine()) != null) {
+                    lineno++;
+                    if (lineno >= errno - padding && lineno <= errno + padding) {
+                        snippet.add(line);
+                    }
+                }
+            } catch (Exception ex) {
+                // ignoring as snippet not available isn't a big deal
+            }
+        }
+        return snippet;
+    }
+            
+
+    /**
+     * Returns a short description of this throwable object, including the 
+     * location. If no detailed message is available, it will use the message
+     * of the underlying exception if available.
+     *
+     * @return a string representation of this <code>Throwable</code>.
+     */
+    public String toString() {
+        String msg = getMessage();
+        if (msg == null && getCause() != null) {
+            msg = getCause().getMessage();
+        }
+
+        if (location != null) {
+            if (msg != null) {
+                return msg + " - " + location.toString();
+            } else {
+                return location.toString();
+            }
+        } else {
+            return msg;
+        }
+    }
+}

src/java/com/opensymphony/xwork/XworkException.java

-/*
- * Copyright (c) 2002-2006 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.xwork;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import java.net.URL;
-
-import com.opensymphony.xwork.util.location.Locatable;
-import com.opensymphony.xwork.util.location.Location;
-import com.opensymphony.xwork.util.location.LocationUtils;
-
-
-/**
- * A generic runtime exception that optionally contains Location information 
- *
- * @author Jason Carreira
- */
-public class XworkException extends RuntimeException implements Locatable {
-
-    private Location location;
-
-
-    /**
-     * Constructs a <code>XworkException</code> with no detail message.
-     */
-    public XworkException() {
-    }
-
-    /**
-     * Constructs a <code>XworkException</code> with the specified
-     * detail message.
-     *
-     * @param s the detail message.
-     */
-    public XworkException(String s) {
-        this(s, null, null);
-    }
-    
-    /**
-     * Constructs a <code>XworkException</code> with the specified
-     * detail message and target.
-     *
-     * @param s the detail message.
-     * @param target the target of the exception.
-     */
-    public XworkException(String s, Object target) {
-        this(s, (Throwable) null, target);
-    }
-
-    /**
-     * Constructs a <code>XworkException</code> with the root cause
-     *
-     * @param cause The wrapped exception
-     */
-    public XworkException(Throwable cause) {
-        this(null, cause, null);
-    }
-    
-    /**
-     * Constructs a <code>XworkException</code> with the root cause and target
-     *
-     * @param cause The wrapped exception
-     * @param target The target of the exception
-     */
-    public XworkException(Throwable cause, Object target) {
-        this(null, cause, target);
-    }
-
-    /**
-     * Constructs a <code>XworkException</code> with the specified
-     * detail message and exception cause.
-     *
-     * @param s the detail message.
-     * @param cause the wrapped exception
-     */
-    public XworkException(String s, Throwable cause) {
-        this(s, cause, null);
-    }
-    
-    
-     /**
-     * Constructs a <code>XworkException</code> with the specified
-     * detail message, cause, and target
-     *
-     * @param s the detail message.
-     * @param cause The wrapped exception
-     * @param target The target of the exception
-     */
-    public XworkException(String s, Throwable cause, Object target) {
-        super(s, cause);
-        
-        this.location = LocationUtils.getLocation(target);
-        if (this.location == Location.UNKNOWN) {
-            this.location = LocationUtils.getLocation(cause);
-        }
-    }
-
-
-    /**
-     * Gets the underlying cause
-     * 
-     * @deprecated Use getCause()
-     */
-    public Throwable getThrowable() {
-        return getCause();
-    }
-
-
-    /**
-     * Gets the location of the error, if available
-     */
-    public Location getLocation() {
-        return this.location;
-    }
-    
-    
-    /**
-     * Gets a source code snippet with the default padding
-     */
-    public List getSnippet() {
-        return getSnippet(2);
-    }
-    
-    
-    /**
-     * Gets a source code snippet with the default padding
-     *
-     * @param padding The amount of lines before and after the error to include
-     */
-    public List getSnippet(int padding) {
-        List snippet = new ArrayList();
-        if (location != null && location.getLineNumber() > 0) {
-            try {
-                InputStream in = new URL(location.getURI()).openStream();
-                BufferedReader reader = new BufferedReader(new InputStreamReader(in));
-                
-                int lineno = 0;
-                int errno = location.getLineNumber();
-                String line;
-                while ((line = reader.readLine()) != null) {
-                    lineno++;
-                    if (lineno >= errno - padding && lineno <= errno + padding) {
-                        snippet.add(line);
-                    }
-                }
-            } catch (Exception ex) {
-                // ignoring as snippet not available isn't a big deal
-            }
-        }
-        return snippet;
-    }
-            
-
-    /**
-     * Returns a short description of this throwable object, including the 
-     * location. If no detailed message is available, it will use the message
-     * of the underlying exception if available.
-     *
-     * @return a string representation of this <code>Throwable</code>.
-     */
-    public String toString() {
-        String msg = getMessage();
-        if (msg == null && getCause() != null) {
-            msg = getCause().getMessage();
-        }
-
-        if (location != null) {
-            if (msg != null) {
-                return msg + " - " + location.toString();
-            } else {
-                return location.toString();
-            }
-        } else {
-            return msg;
-        }
-    }
-}

src/java/com/opensymphony/xwork/config/ConfigurationException.java

  */
 package com.opensymphony.xwork.config;
 
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 
 
 /**
  *
  * @author Jason Carreira
  */
-public class ConfigurationException extends XworkException {
+public class ConfigurationException extends XWorkException {
 
     /**
      * Constructs a <code>ConfigurationException</code> with no detail message.

src/java/com/opensymphony/xwork/config/ReferenceResolverException.java

  */
 package com.opensymphony.xwork.config;
 
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 
 
 /**
  *
  * @author Mike
  */
-public class ReferenceResolverException extends XworkException {
+public class ReferenceResolverException extends XWorkException {
 
     public ReferenceResolverException() {
         super();

src/java/com/opensymphony/xwork/config/providers/XmlConfigurationProvider.java

 import com.opensymphony.xwork.Action;
 import com.opensymphony.xwork.ActionSupport;
 import com.opensymphony.xwork.ObjectFactory;
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 import com.opensymphony.xwork.config.*;
 import com.opensymphony.xwork.config.entities.*;
 import com.opensymphony.xwork.util.DomHelper;
                 dtdMappings.put("-//OpenSymphony Group//XWork 1.0//EN", "xwork-1.0.dtd");
 
                 doc = DomHelper.parse(in, dtdMappings);
-            } catch (XworkException e) {
+            } catch (XWorkException e) {
                 if (includeElement != null) {
                     throw new ConfigurationException(e, includeElement);
                 } else {

src/java/com/opensymphony/xwork/util/DomHelper.java

 
 import com.opensymphony.xwork.util.location.Location;
 import com.opensymphony.xwork.util.location.LocationAttributes;
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
         try {
             parser = factory.newSAXParser();
         } catch (Exception ex) {
-            throw new XworkException("Unable to create SAX parser", ex);
+            throw new XWorkException("Unable to create SAX parser", ex);
         }
         
         
         try {
             parser.parse(inputSource, new StartHandler(locationHandler, dtdMappings));
         } catch (Exception ex) {
-            throw new XworkException(ex);
+            throw new XWorkException(ex);
         }
         
         return builder.getDocument();
                 }
                 handler.setResult(this.result);
             } catch (javax.xml.transform.TransformerException local) {
-                throw new XworkException("Fatal-Error: Unable to get transformer handler", local);
+                throw new XWorkException("Fatal-Error: Unable to get transformer handler", local);
             }
         }
     

src/java/com/opensymphony/xwork/util/TypeConversionException.java

  */
 package com.opensymphony.xwork.util;
 
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 
 
 /**
  * @author Jason Carreira
  *         Created Oct 3, 2003 12:18:33 AM
  */
-public class TypeConversionException extends XworkException {
+public class TypeConversionException extends XWorkException {
 
     /**
-     * Constructs a <code>XworkException</code> with no detail  message.
+     * Constructs a <code>XWorkException</code> with no detail  message.
      */
     public TypeConversionException() {
     }
 
     /**
-     * Constructs a <code>XworkException</code> with the specified
+     * Constructs a <code>XWorkException</code> with the specified
      * detail message.
      *
      * @param s the detail message.
     }
 
     /**
-     * Constructs a <code>XworkException</code> with no detail  message.
+     * Constructs a <code>XWorkException</code> with no detail  message.
      */
     public TypeConversionException(Throwable cause) {
         super(cause);
     }
 
     /**
-     * Constructs a <code>XworkException</code> with the specified
+     * Constructs a <code>XWorkException</code> with the specified
      * detail message.
      *
      * @param s the detail message.

src/java/com/opensymphony/xwork/util/XWorkBasicConverter.java

 
 import com.opensymphony.util.TextUtils;
 import com.opensymphony.xwork.ActionContext;
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 
 
 /**
             }
             
             if (result == null && value != null && !"".equals(value)) {
-                throw new XworkException("Cannot create type " + toType + " from value " + value);
+                throw new XWorkException("Cannot create type " + toType + " from value " + value);
             }
         }
 
             try {
                 clazz = Class.forName((String) value);
             } catch (ClassNotFoundException e) {
-                throw new XworkException(e.getLocalizedMessage(), e);
+                throw new XWorkException(e.getLocalizedMessage(), e);
             }
         }
 
                         Constructor constructor = toType.getConstructor(new Class[]{long.class});
                         return constructor.newInstance(new Object[]{new Long(result.getTime())});
                     } catch (Exception e) {
-                        throw new XworkException("Couldn't create class " + toType + " using default (long) constructor", e);
+                        throw new XWorkException("Couldn't create class " + toType + " using default (long) constructor", e);
                     }
                 }
             } catch (ParseException e) {
-                throw new XworkException("Could not parse date", e);
+                throw new XWorkException("Could not parse date", e);
             }
         } else if (Date.class.isAssignableFrom(value.getClass())) {
             result = (Date) value;
                 Number number = numFormat.parse(stringValue, parsePos);
                 
                 if (parsePos.getIndex() != stringValue.length()) {
-                    throw new XworkException("Unparseable number: \"" + stringValue + "\" at position "
+                    throw new XWorkException("Unparseable number: \"" + stringValue + "\" at position "
                             + parsePos.getIndex());
                 }
                 else {

src/java/com/opensymphony/xwork/validator/ActionValidatorManagerFactory.java

 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import com.opensymphony.util.ClassLoaderUtil;
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 
 /**
  * <code>ActionValidatorManagerFactory</code>
         } catch (ClassNotFoundException e) {
             // this is fine, just fall back to the default object type determiner
         } catch (Exception e) {
-            throw new XworkException(e);
+            throw new XWorkException(e);
         }
     }
 

src/java/com/opensymphony/xwork/validator/ValidatorFactory.java

 
 import com.opensymphony.util.ClassLoaderUtil;
 import com.opensymphony.xwork.ObjectFactory;
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
             validator = ObjectFactory.getObjectFactory().buildValidator(className, cfg.getParams(), null); // ActionContext.getContext().getContextMap());
         } catch (Exception e) {
             final String msg = "There was a problem creating a Validator of type " + className + " : caused by " + e.getMessage();
-            throw new XworkException(msg, e, cfg);
+            throw new XWorkException(msg, e, cfg);
         }
 
         // set other configured properties

src/java/com/opensymphony/xwork/validator/ValidatorFileParser.java

 
 import com.opensymphony.xwork.ObjectFactory;
 import com.opensymphony.xwork.util.DomHelper;
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 import org.w3c.dom.*;
 import org.xml.sax.InputSource;
 
                 ObjectFactory.getObjectFactory().buildValidator(className, new HashMap(), null);
                 ValidatorFactory.registerValidator(name, className);
             } catch (Exception e) {
-                throw new XworkException("Unable to load validator class " + className, e, validatorElement);
+                throw new XWorkException("Unable to load validator class " + className, e, validatorElement);
             }
         }
     }

src/test/com/opensymphony/xwork/ChainResultTest.java

         try {
             proxy.execute();
             fail("did not detected repeated chain to an action");
-        } catch (XworkException e) {
+        } catch (XWorkException e) {
         }
     }
 

src/test/com/opensymphony/xwork/XworkExceptionTest.java

 import java.net.URL;
 
 /**
- * XworkException tests
+ * XWorkException tests
  */
 public class XworkExceptionTest extends TestCase {
 
     public void testGetSnippet() throws Exception {
         URL url = ClassLoaderUtil.getResource("com/opensymphony/xwork/somefile.txt", getClass());
         Location loc = new LocationImpl("foo", url.toString(), 3, 2);
-        XworkException ex = new XworkException("Some message", loc);
+        XWorkException ex = new XWorkException("Some message", loc);
         
         List snippet = ex.getSnippet(1);
         assertNotNull(snippet);
     public void testGetSnippetNoPadding() throws Exception {
         URL url = ClassLoaderUtil.getResource("com/opensymphony/xwork/somefile.txt", getClass());
         Location loc = new LocationImpl("foo", url.toString(), 3, 2);
-        XworkException ex = new XworkException("Some message", loc);
+        XWorkException ex = new XWorkException("Some message", loc);
         
         List snippet = ex.getSnippet(0);
         assertNotNull(snippet);

src/test/com/opensymphony/xwork/interceptor/ExceptionMappingInterceptorTest.java

         this.setUpWithExceptionMappings();
 
         Mock action = new Mock(Action.class);
-        Exception exception = new XworkException("test");
+        Exception exception = new XWorkException("test");
         mockInvocation.expectAndThrow("invoke", exception);
         mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
         String result = interceptor.intercept(invocation);
 
     private void setUpWithExceptionMappings() {
         ActionConfig actionConfig = new ActionConfig();
-        actionConfig.addExceptionMapping(new ExceptionMappingConfig("xwork", "com.opensymphony.xwork.XworkException", "spooky"));
+        actionConfig.addExceptionMapping(new ExceptionMappingConfig("xwork", "com.opensymphony.xwork.XWorkException", "spooky"));
         actionConfig.addExceptionMapping(new ExceptionMappingConfig("throwable", "java.lang.Throwable", "throwable"));
         Mock actionProxy = new Mock(ActionProxy.class);
         actionProxy.expectAndReturn("getConfig", actionConfig);

src/test/com/opensymphony/xwork/util/OgnlUtilTest.java

 
 import com.opensymphony.xwork.ActionContext;
 import com.opensymphony.xwork.XWorkTestCase;
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 import com.opensymphony.xwork.interceptor.ChainingInterceptor;
 import com.opensymphony.xwork.test.User;
 
                 try {
                     this.add(clazz.newInstance());
                 } catch (Exception e) {
-                    throw new XworkException(e);
+                    throw new XWorkException(e);
                 }
             }
 

src/test/com/opensymphony/xwork/util/XWorkBasicConverterTest.java

 import java.util.Date;
 import java.util.HashMap;
 
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 
 import junit.framework.TestCase;
 
 		try {
 			Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "asdsd", Date.class);
 		}
-		catch(XworkException e) {
+		catch(XWorkException e) {
 			// we MUST get this exception as this is a conversion error
 			assertTrue(true);
 			return;

src/test/com/opensymphony/xwork/validator/DefaultActionValidatorManagerTest.java

 import com.opensymphony.xwork.TestBean;
 import com.opensymphony.xwork.ValidationOrderAction;
 import com.opensymphony.xwork.XWorkTestCase;
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 import com.opensymphony.xwork.test.DataAware2;
 import com.opensymphony.xwork.test.SimpleAction2;
 import com.opensymphony.xwork.test.SimpleAction3;
         boolean pass = false;
         try {
             List validatorList = actionValidatorManager.getValidators(TestBean.class, "badtest");
-        } catch (XworkException ex) {
+        } catch (XWorkException ex) {
             pass = true;
         }
         assertTrue("Didn't throw exception on load failure", pass);

src/test/com/opensymphony/xwork/validator/ValidatorFileParserTest.java

 
 import com.opensymphony.util.ClassLoaderUtil;
 import com.opensymphony.xwork.XWorkStatic;
-import com.opensymphony.xwork.XworkException;
+import com.opensymphony.xwork.XWorkException;
 import com.opensymphony.xwork.config.providers.MockConfigurationProvider;
 import junit.framework.TestCase;
 
         boolean pass = false;
         try {
             ValidatorFileParser.parseActionValidatorConfigs(is, testFileName3);
-        } catch (XworkException ex) {
+        } catch (XWorkException ex) {
             assertTrue("Wrong line number", 3 == ex.getLocation().getLineNumber());
             pass = true;
         }
         boolean pass = false;
         try {
             ValidatorFileParser.parseActionValidatorConfigs(is, testFileName4);
-        } catch (XworkException ex) {
+        } catch (XWorkException ex) {
             assertTrue("Wrong line number: " + ex.getLocation(), 13 == ex.getLocation().getLineNumber());
             pass = true;
         }
         boolean pass = false;
         try {
             ValidatorFileParser.parseValidatorDefinitions(is, testFileName5);
-        } catch (XworkException ex) {
+        } catch (XWorkException ex) {
             assertTrue("Wrong line number", 3 == ex.getLocation().getLineNumber());
             pass = true;
         }