struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From musa...@apache.org
Subject svn commit: r654938 - in /struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions: BundlesAction.java ShellAction.java
Date Fri, 09 May 2008 21:16:15 GMT
Author: musachy
Date: Fri May  9 14:16:15 2008
New Revision: 654938

URL: http://svn.apache.org/viewvc?rev=654938&view=rev
Log:
* Out put errors from shell
* Catch possible exceptions

Modified:
    struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java
    struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/ShellAction.java

Modified: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java?rev=654938&r1=654937&r2=654938&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java
(original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java
Fri May  9 14:16:15 2008
@@ -110,7 +110,14 @@
     }
 
     public boolean isAllowedAction(Bundle bundle, String val) {
-        int state = bundle.getState();
+        int state = -1;
+        try {
+            state = bundle.getState();
+        } catch (Exception e) {
+            addActionError("Unable to determine bundle state: " + e.getMessage());
+            return false;
+        }
+
         if ("start".equals(val)) {
             return state == Bundle.RESOLVED;
         } else if ("stop".equals(val)) {

Modified: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/ShellAction.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/ShellAction.java?rev=654938&r1=654937&r2=654938&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/ShellAction.java
(original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/ShellAction.java
Fri May  9 14:16:15 2008
@@ -15,7 +15,6 @@
 
 public class ShellAction extends ActionSupport {
     private String command;
-    private String error;
     private String output;
 
     public String execute() {
@@ -25,18 +24,21 @@
         PrintStream outStream = new PrintStream(outByteStream);
         PrintStream errStream = new PrintStream(errByteStream);
 
+        String outString = null;
+        String errString = null;
         try {
             ShellService shellService = ServicesFactory.getInstance().getShellService();
             shellService.executeCommand(command, outStream, errStream);
-            output = outByteStream.toString();
-            error = errByteStream.toString();
+            outString = outByteStream.toString();
+            errString = errByteStream.toString();
         } catch (Exception e) {
-            error = e.getMessage();
+            errString = e.getMessage();
         } finally {
             outStream.close();
             errStream.close();
         }
 
+        output = errString != null && errString.length() > 0 ? errString : outString;
         return Action.SUCCESS;
     }
 
@@ -48,10 +50,6 @@
         this.command = command;
     }
 
-    public String getError() {
-        return error;
-    }
-
     public String getOutput() {
         return output;
     }



Mime
View raw message