Author: keith
Date: Mon Jan 21 03:58:12 2008
New Revision: 12625

Log:

removing printStackTrace and throwing MashupFault instead



Modified:
   
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java

Modified: 
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java
==============================================================================
--- 
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java
   (original)
+++ 
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupAdminService.java
   Mon Jan 21 03:58:12 2008
@@ -15,34 +15,36 @@
  */
 package org.wso2.mashup.admin.service;
 
-import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.AxisConfiguration;
 import org.wso2.javascript.rhino.JavaScriptEngineConstants;
+import org.wso2.mashup.MashupConstants;
+import org.wso2.mashup.MashupFault;
+import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.RegistryException;
+import org.wso2.registry.Resource;
+import org.wso2.registry.jdbc.JDBCRegistry;
 import org.wso2.wsas.ServerManager;
 import org.wso2.wsas.persistence.PersistenceManager;
-import org.wso2.wsas.persistence.exception.ServiceNotFoundException;
-import org.wso2.wsas.persistence.dataobject.ServiceIdentifierDO;
-import org.wso2.wsas.persistence.dataobject.ServiceDO;
 import org.wso2.wsas.persistence.dataobject.OperationDO;
-import org.wso2.registry.jdbc.JDBCRegistry;
-import org.wso2.registry.RegistryConstants;
-import org.wso2.registry.Resource;
-import org.wso2.registry.RegistryException;
-import org.wso2.mashup.MashupConstants;
+import org.wso2.wsas.persistence.dataobject.ServiceDO;
+import org.wso2.wsas.persistence.dataobject.ServiceIdentifierDO;
+import org.wso2.wsas.persistence.exception.ServiceNotFoundException;
 
-import java.io.File;
 import java.io.BufferedWriter;
+import java.io.File;
 import java.io.FileWriter;
+import java.io.IOException;
 import java.util.Iterator;
 
 public class MashupAdminService {
 
-    public Boolean saveServiceSource(String path, String modifiedSource) {
+    public Boolean saveServiceSource(String path, String modifiedSource) 
throws MashupFault {
         boolean success = false;
 
         try {
@@ -74,14 +76,16 @@
             out.close();
             success = true;
 
-        } catch (Exception e) {
-            e.printStackTrace();
+        } catch (AxisFault axisFault) {
+            throw new MashupFault("Cannot save service Source", axisFault);
+        } catch (IOException e) {
+            throw new MashupFault("Cannot save service Source", e);
         }
 
         return Boolean.valueOf(success);
     }
 
-    public Boolean saveUiSource(String path, String modifiedSource) {
+    public Boolean saveUiSource(String path, String modifiedSource) throws 
MashupFault {
         boolean success = false;
 
         try {
@@ -120,14 +124,16 @@
             out.close();
             success = true;
 
-        } catch (Exception e) {
-            e.printStackTrace();
+        } catch (AxisFault axisFault) {
+            throw new MashupFault("Cannot save ui Source", axisFault);
+        } catch (IOException e) {
+            throw new MashupFault("Cannot save ui Source", e);
         }
 
         return Boolean.valueOf(success);
     }
 
-    public Boolean redeployService(String serviceName) {
+    public Boolean redeployService(String serviceName) throws MashupFault {
         boolean success = false;
 
         MessageContext currentMessageContext = 
MessageContext.getCurrentMessageContext();
@@ -146,15 +152,15 @@
                 serviceJS.setLastModified(time);
                 success = true;
             }
-        } catch (Exception e) {
-            e.printStackTrace();
+        } catch (AxisFault axisFault) {
+            throw new MashupFault("Cannot redeploy service  " + serviceName, 
axisFault);
         }
 
 
         return Boolean.valueOf(success);
     }
 
-    public Boolean setServiceDocumentation(String serviceName, String 
documentation) {
+    public Boolean setServiceDocumentation(String serviceName, String 
documentation) throws MashupFault {
         boolean success = false;
 
         MessageContext currentMessageContext = 
MessageContext.getCurrentMessageContext();
@@ -189,11 +195,11 @@
             success = true;
 
         } catch (AxisFault axisFault) {
-            axisFault.printStackTrace();
+            throw new MashupFault("Cannot change service documentation of 
service " + serviceName, axisFault);
         } catch (ServiceNotFoundException e) {
-            e.printStackTrace();
+            throw new MashupFault("Cannot change service documentation of 
service " + serviceName, e);
         } catch (RegistryException e) {
-            e.printStackTrace();
+            throw new MashupFault("Cannot change service documentation of 
service " + serviceName, e);
         }
 
 
@@ -201,7 +207,7 @@
     }
 
     public Boolean setOperationDocumentation(String serviceName, String 
operationName,
-                                             String documentation) {
+                                             String documentation) throws 
MashupFault {
         boolean success = false;
         MessageContext currentMessageContext = 
MessageContext.getCurrentMessageContext();
         AxisConfiguration configuration =
@@ -233,15 +239,17 @@
             persistenceMgr.updateService(serviceDO);
 
         } catch (AxisFault axisFault) {
-            axisFault.printStackTrace();
+            throw new MashupFault("Cannot change operation documentation of " 
+ operationName + " in service " +
+                    serviceName, axisFault);
         } catch (ServiceNotFoundException e) {
-            e.printStackTrace();
+            throw new MashupFault("Cannot change operation documentation of " 
+ operationName + " in service " +
+                    serviceName, e);
         }
 
         return Boolean.valueOf(success);
     }
 
-    public Boolean changeOperationStatus(String serviceName, String 
operationName, boolean status) {
+    public Boolean changeOperationStatus(String serviceName, String 
operationName, boolean status) throws MashupFault {
         boolean success = false;
 
         MessageContext currentMessageContext = 
MessageContext.getCurrentMessageContext();
@@ -261,13 +269,14 @@
             }
 
         } catch (AxisFault axisFault) {
-            axisFault.printStackTrace();
+            throw new MashupFault("Cannot change operation status of " + 
operationName + " in service " + serviceName,
+                    axisFault);
         }
 
         return Boolean.valueOf(success);
     }
 
-    public Boolean deleteService(String serviceName) {
+    public Boolean deleteService(String serviceName) throws MashupFault {
         boolean success = false;
 
         MessageContext currentMessageContext = 
MessageContext.getCurrentMessageContext();
@@ -293,7 +302,7 @@
                 }
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new MashupFault("Cannot delete service " + serviceName, e);
         }
 
         return Boolean.valueOf(success);

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to