geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hanhongf...@apache.org
Subject svn commit: r1189654 - in /geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator: GetArchiveHandler.java JSR88_Util.java
Date Thu, 27 Oct 2011 07:54:28 GMT
Author: hanhongfang
Date: Thu Oct 27 07:54:27 2011
New Revision: 1189654

URL: http://svn.apache.org/viewvc?rev=1189654&view=rev
Log:
GERONIMO-6206 Concise infomation rather than Exception stacktrace when create plan from a
WAR. Thanks Yi Xiao for the patch.

Modified:
    geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/GetArchiveHandler.java
    geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR88_Util.java

Modified: geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/GetArchiveHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/GetArchiveHandler.java?rev=1189654&r1=1189653&r2=1189654&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/GetArchiveHandler.java
(original)
+++ geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/GetArchiveHandler.java
Thu Oct 27 07:54:27 2011
@@ -61,33 +61,45 @@ public class GetArchiveHandler extends A
 
     public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel
model)
             throws PortletException, IOException {
-        FileItem fileItem = (FileItem) getUploadFiles().get(MODULE_URI_PARAMETER);
-        String fileName = fileItem.getName();
-        if (fileName != null && fileName.length() > 0) {
-            File uploadedFile = uploadFile(fileItem);
-            ApplicationInfo applicationInfo = JSR88_Util.createApplicationInfo(request, uploadedFile);
-            ConfigurationModuleType applicationType = applicationInfo.getType();
-            if (ConfigurationModuleType.WAR == applicationType) {
-                WARConfigData data = setNewWARSessionData(request);
-                data.setUploadedWarUri(uploadedFile.toURI().toString());
-                data.parseWeb((WebModule) (applicationInfo.getModules().toArray()[0]));
-                return ENVIRONMENT_MODE + "-before";
-            }
-            if (ConfigurationModuleType.EAR == applicationType) {
-                EARConfigData earConfigData = setNewEARSessionData(request);
-                earConfigData.parseEAR(applicationInfo);
-                return EAR_MODE + "-before";
-            }
-            if (ConfigurationModuleType.EJB == applicationType) {
-                EjbConfigData ejbJarConfigData = setNewEjbJarSessionData(request);
-                ejbJarConfigData.parseEjbJar((EjbModule) (applicationInfo.getModules().toArray()[0]));
-                return EJB_MODE + "-before";
+        String errorMsg = portlet.getLocalizedString(request, "errorMsg01");
+        try {
+            FileItem fileItem = (FileItem) getUploadFiles().get(MODULE_URI_PARAMETER);
+            String fileName = fileItem.getName();
+            if (fileName != null && fileName.length() > 0) {
+                File uploadedFile = uploadFile(fileItem);
+                ApplicationInfo applicationInfo = JSR88_Util.createApplicationInfo(request,
uploadedFile);
+                ConfigurationModuleType applicationType = applicationInfo.getType();
+                if (ConfigurationModuleType.WAR == applicationType) {
+                    WARConfigData data = setNewWARSessionData(request);
+                    data.setUploadedWarUri(uploadedFile.toURI().toString());
+                    data.parseWeb((WebModule) (applicationInfo.getModules().toArray()[0]));
+                    return ENVIRONMENT_MODE + "-before";
+                }
+                if (ConfigurationModuleType.EAR == applicationType) {
+                    EARConfigData earConfigData = setNewEARSessionData(request);
+                    earConfigData.parseEAR(applicationInfo);
+                    return EAR_MODE + "-before";
+                }
+                if (ConfigurationModuleType.EJB == applicationType) {
+                    EjbConfigData ejbJarConfigData = setNewEjbJarSessionData(request);
+                    ejbJarConfigData.parseEjbJar((EjbModule) (applicationInfo.getModules().toArray()[0]));
+                    return EJB_MODE + "-before";
+                }
             }
+        } catch(Throwable e) {
+            errorMsg = getRootCause(e).getMessage();
         }
-        portlet.addErrorMessage(request, portlet.getLocalizedString(request, "errorMsg01"));
+        portlet.addErrorMessage(request, errorMsg);
         return getMode();
     }
-
+    
+    private Throwable getRootCause(Throwable e) {
+        while(e.getCause() != null && e.getCause() != e) {
+            e = e.getCause();
+        }
+        return e;
+    }
+    
     private File uploadFile(FileItem fileItem) throws PortletException, IOException {
         File tempDir = File.createTempFile("geronimo-planCreator", ".tmpdir");
         tempDir.delete();

Modified: geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR88_Util.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR88_Util.java?rev=1189654&r1=1189653&r2=1189654&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR88_Util.java
(original)
+++ geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/java/org/apache/geronimo/console/configcreator/JSR88_Util.java
Thu Oct 27 07:54:27 2011
@@ -83,7 +83,9 @@ public class JSR88_Util {
             command.setCommandContext(commandContext);
             command.doDeploy(targets[0], true);
         } catch (Exception e) {
-            // ignore exceptions
+            // Any better ideas?
+            if(EARConfigBuilder.appInfo.get() == null) throw new RuntimeException(e);
+            
         } finally {
             EARConfigBuilder.createPlanMode.set(Boolean.FALSE);
             applicationInfo = EARConfigBuilder.appInfo.get();



Mime
View raw message