svn commit: r789400 - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/container/ base/src/org/ofbiz/base/util/ base/src/org/ofbiz/base/util/template/ minilang/src/org/ofbiz/minilang/ testtools/src/org/ofbiz/testtools/ webapp/src/org/ofbiz/webapp/tag...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r789400 - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/container/ base/src/org/ofbiz/base/util/ base/src/org/ofbiz/base/util/template/ minilang/src/org/ofbiz/minilang/ testtools/src/org/ofbiz/testtools/ webapp/src/org/ofbiz/webapp/tag...

doogie-3
Author: doogie
Date: Mon Jun 29 18:13:19 2009
New Revision: 789400

URL: http://svn.apache.org/viewvc?rev=789400&view=rev
Log:
Add a simple initCause helper method.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/container/JustLoadComponentsContainer.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilMisc.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java
    ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/TestListContainer.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java
    ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java
    ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java
    ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java
    ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java
    ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerBSFServiceEngine.java
    ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContainer.java
    ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/container/JustLoadComponentsContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/container/JustLoadComponentsContainer.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/container/JustLoadComponentsContainer.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/container/JustLoadComponentsContainer.java Mon Jun 29 18:13:19 2009
@@ -21,6 +21,7 @@
 import org.ofbiz.base.component.AlreadyLoadedException;
 import org.ofbiz.base.component.ComponentException;
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
 
 /**
  * A Container implementation to run the tests configured through this testtools stuff.
@@ -39,7 +40,7 @@
             Debug.logError(e, module);
         } catch (ComponentException e) {
             Debug.logError(e, module);
-            //throw (ContainerException) new ContainerException(e.getMessage()).initCause(e);
+            //throw UtilMisc.initCause(new ContainerException(e.getMessage()), e);
         }
     }
 

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilMisc.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilMisc.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilMisc.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilMisc.java Mon Jun 29 18:13:19 2009
@@ -46,6 +46,11 @@
 
     public static final BigDecimal ZERO_BD = BigDecimal.ZERO;
 
+    public static final <T extends Throwable> T initCause(T throwable, Throwable cause) {
+        throwable.initCause(cause);
+        return throwable;
+    }
+
     /**
      * Get an iterator from a collection, returning null if collection is null
      * @param col The collection to be turned in to an iterator

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java Mon Jun 29 18:13:19 2009
@@ -97,7 +97,7 @@
             resources = loader.getResources("freemarkerTransforms.properties");
         } catch (IOException e) {
             Debug.logError(e, "Could not load list of freemarkerTransforms.properties", module);
-            throw (InternalError) new InternalError(e.getMessage()).initCause(e);
+            throw UtilMisc.initCause(new InternalError(e.getMessage()), e);
         }
         while (resources.hasMoreElements()) {
             URL propertyURL = resources.nextElement();

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java Mon Jun 29 18:13:19 2009
@@ -104,7 +104,7 @@
             simpleMethodExecMethod = SimpleMethod.class.getDeclaredMethod("exec", MethodContext.class);
             methodOperationExecMethod = MethodOperation.class.getDeclaredMethod("exec", MethodContext.class);
         } catch (NoSuchMethodException e) {
-            throw (InternalError) new InternalError(e.getMessage()).initCause(e);
+            throw UtilMisc.initCause(new InternalError(e.getMessage()), e);
         }
     }
 

Modified: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/TestListContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/TestListContainer.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/TestListContainer.java (original)
+++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/TestListContainer.java Mon Jun 29 18:13:19 2009
@@ -32,6 +32,7 @@
 import org.ofbiz.base.container.Container;
 import org.ofbiz.base.container.ContainerException;
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -112,7 +113,7 @@
             new File(outputLocation + ".tmp").renameTo(new File(outputLocation));
         } catch (IOException e) {
             Debug.logError(e, module);
-            throw (IllegalArgumentException) new IllegalArgumentException(e.getMessage()).initCause(e);
+            throw UtilMisc.initCause(new IllegalArgumentException(e.getMessage()), e);
         }
 
         return true;

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java Mon Jun 29 18:13:19 2009
@@ -26,6 +26,7 @@
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilJ2eeCompat;
+import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.webapp.website.WebSiteWorker;
@@ -43,7 +44,7 @@
         try {
             appendContentPrefix(request, (Appendable) urlBuffer);
         } catch (IOException e) {
-            throw (InternalError) new InternalError(e.getMessage()).initCause(e);
+            throw UtilMisc.initCause(new InternalError(e.getMessage()), e);
         }
     }
 
@@ -51,7 +52,7 @@
         try {
             appendContentPrefix(request, (Appendable) urlBuffer);
         } catch (IOException e) {
-            throw (InternalError) new InternalError(e.getMessage()).initCause(e);
+            throw UtilMisc.initCause(new InternalError(e.getMessage()), e);
         }
     }
 

Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java (original)
+++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java Mon Jun 29 18:13:19 2009
@@ -30,6 +30,7 @@
 
 import org.ofbiz.base.container.Container;
 import org.ofbiz.base.container.ContainerException;
+import org.ofbiz.base.util.UtilMisc;
 import org.webslinger.commons.vfs.VFSUtil;
 
 public class CommonsVfsContainer implements Container {
@@ -45,9 +46,9 @@
             sfsm.setBaseFile(currentDir);
             CommonsVfsContainer.sfsm = sfsm;
         } catch (FileSystemException e) {
-            throw (ContainerException) new ContainerException("Initializing StandardFileSystemManager").initCause(e);
+            throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
         } catch (MalformedURLException e) {
-            throw (ContainerException) new ContainerException("Initializing StandardFileSystemManager").initCause(e);
+            throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
         }
         return true;
     }

Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java (original)
+++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java Mon Jun 29 18:13:19 2009
@@ -26,6 +26,7 @@
 import org.apache.commons.vfs.provider.AbstractFileProvider;
 import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
 import org.ofbiz.base.location.FlexibleLocation;
+import org.ofbiz.base.util.UtilMisc;
 import org.webslinger.commons.vfs.VFSUtil;
 
 public class OfbizComponentProvider extends AbstractFileProvider {
@@ -51,9 +52,7 @@
             FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
             return VFSUtil.toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase.resolveFile(name.substring(restStart)).getURL().toString(), properties);
         } catch (Exception e) {
-            FileSystemException fse = new FileSystemException(e.getMessage(), null, e);
-            fse.initCause(e);
-            throw fse;
+            throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
         }
     }
 }

Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java (original)
+++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java Mon Jun 29 18:13:19 2009
@@ -28,6 +28,7 @@
 import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
 
 import org.ofbiz.base.location.FlexibleLocation;
+import org.ofbiz.base.util.UtilMisc;
 
 import org.webslinger.commons.vfs.VFSUtil;
 
@@ -43,9 +44,7 @@
             FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
             return VFSUtil.toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase.resolveFile(name.substring(13)).getURL().toString(), properties);
         } catch (Exception e) {
-            FileSystemException fse = new FileSystemException(e.getMessage(), null, e);
-            fse.initCause(e);
-            throw fse;
+            throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
         }
     }
 }

Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java (original)
+++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java Mon Jun 29 18:13:19 2009
@@ -27,6 +27,7 @@
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
+import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericPK;
@@ -70,7 +71,7 @@
             } catch (GenericEntityException e) {
                 throw e;
             } catch (Exception e) {
-                throw (GenericEntityException) new GenericEntityException(e.getMessage()).initCause(e);
+                throw UtilMisc.initCause(new GenericEntityException(e.getMessage()), e);
             }
         }
 

Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerBSFServiceEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerBSFServiceEngine.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerBSFServiceEngine.java (original)
+++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerBSFServiceEngine.java Mon Jun 29 18:13:19 2009
@@ -24,6 +24,7 @@
 import org.apache.bsf.BSFException;
 
 import org.ofbiz.base.util.UtilGenerics;
+import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.ModelService;
@@ -51,9 +52,9 @@
         try {
             return UtilGenerics.checkMap(WebslingerContainer.runEvent(modelService.engineName, modelService.location, paramNames, paramTypes, params));
         } catch (IOException e) {
-            throw (GenericServiceException) new GenericServiceException(e.getMessage()).initCause(e);
+            throw UtilMisc.initCause(new GenericServiceException(e.getMessage()), e);
         } catch (BSFException e) {
-            throw (GenericServiceException) new GenericServiceException(e.getMessage()).initCause(e);
+            throw UtilMisc.initCause(new GenericServiceException(e.getMessage()), e);
         }
     }
 }

Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContainer.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContainer.java (original)
+++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContainer.java Mon Jun 29 18:13:19 2009
@@ -29,6 +29,7 @@
 
 import org.ofbiz.base.container.Container;
 import org.ofbiz.base.container.ContainerException;
+import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.commons.vfs.CommonsVfsContainer;
 
 import org.webslinger.bsf.LanguageManager;
@@ -62,7 +63,7 @@
             templateManager = new TemplateManager(vfsDelegate, null);
             templateManager.setClassLoader(loader);
         } catch (BSFException e) {
-            throw (ContainerException) new ContainerException("Initializing StandardFileSystemManager").initCause(e);
+            throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
         }
         return true;
     }

Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java (original)
+++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java Mon Jun 29 18:13:19 2009
@@ -56,7 +56,7 @@
         } catch (GenericServiceException e) {
             throw e;
         } catch (Exception e) {
-            throw (GenericServiceException) new GenericServiceException(e.getMessage()).initCause(e);
+            throw UtilMisc.initCause(new GenericServiceException(e.getMessage()), e);
         }
     }
 }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=789400&r1=789399&r2=789400&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Mon Jun 29 18:13:19 2009
@@ -2899,7 +2899,7 @@
             try {
                 appendOfbizUrl(ajaxUrl, UtilHttp.removeQueryStringFromTarget(targetUrl));
             } catch (IOException e) {
-                throw (InternalError) new InternalError(e.getMessage()).initCause(e);
+                throw UtilMisc.initCause(new InternalError(e.getMessage()), e);
             }
             ajaxUrl.append(",").append(ajaxParams);
         }