You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2015/05/20 19:40:36 UTC
[2/4] 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/eaf518cc
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/eaf518cc
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/eaf518cc
Branch: refs/heads/master
Commit: eaf518ccaa9331774a62f92bbff8ae53020ac49a
Parents: 54106d5
Author: Dinithi <di...@wso2.com>
Authored: Wed May 20 22:32:37 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed May 20 23:10:30 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/eaf518cc/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/eaf518cc/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());
- }
}
/**