You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2015/05/21 16:13:45 UTC

[18/23] stratos git commit: handling specific exceptions in API class

handling specific exceptions in API class


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4c6da2e9
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4c6da2e9
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4c6da2e9

Branch: refs/heads/master
Commit: 4c6da2e9e9af6b2aaec8ff05cf17abb39e7a4965
Parents: 2ac1499
Author: Dinithi <di...@wso2.com>
Authored: Wed May 20 22:32:37 2015 +0530
Committer: Dinithi <di...@wso2.com>
Committed: Wed May 20 22:32:37 2015 +0530

----------------------------------------------------------------------
 .../apache/stratos/rest/endpoint/api/StratosApiV41.java | 10 +++++++++-
 .../stratos/rest/endpoint/api/StratosApiV41Utils.java   | 12 +++---------
 2 files changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4c6da2e9/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index b4dbb45..1a0ca88 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -59,6 +59,7 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 import java.net.URI;
+import java.rmi.RemoteException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -430,9 +431,16 @@ public class StratosApiV41 extends AbstractApi {
             StratosApiV41Utils.removeCartridge(cartridgeType);
             return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
                     String.format("Cartridge deleted successfully: [cartridge-type] %s", cartridgeType))).build();
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(
                     ResponseMessageBean.ERROR, e.getMessage())).build();
+        } catch (CloudControllerServiceInvalidCartridgeTypeExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(
+                    ResponseMessageBean.ERROR, e.getFaultMessage().getInvalidCartridgeTypeException().getMessage()))
+                    .build();
+        } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
+            return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(
+                    ResponseMessageBean.ERROR, e.getFaultMessage().getCartridgeNotFoundException().getMessage())).build();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/4c6da2e9/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index 8ca2ff0..2be2180 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -225,9 +225,10 @@ public class StratosApiV41Utils {
      * @param cartridgeType Cartridge Type
      * @throws RestAPIException
      */
-    public static void removeCartridge(String cartridgeType) throws RestAPIException {
+    public static void removeCartridge(String cartridgeType) throws RestAPIException, RemoteException,
+            CloudControllerServiceCartridgeNotFoundExceptionException,
+            CloudControllerServiceInvalidCartridgeTypeExceptionException {
 
-        try {
             if (log.isDebugEnabled()) {
                 log.debug(String.format("Removing cartridge: [cartridge-type] %s ", cartridgeType));
             }
@@ -251,13 +252,6 @@ public class StratosApiV41Utils {
             if (log.isInfoEnabled()) {
                 log.info(String.format("Successfully removed cartridge: [cartridge-type] %s ", cartridgeType));
             }
-        } catch (RemoteException e) {
-            throw new RestAPIException(e.getMessage());
-        } catch (CloudControllerServiceInvalidCartridgeTypeExceptionException e) {
-            throw new RestAPIException(e.getFaultMessage().getInvalidCartridgeTypeException().getMessage());
-        } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
-            throw new RestAPIException(e.getFaultMessage().getCartridgeNotFoundException().getMessage());
-        }
     }
 
     /**