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/07 20:55:22 UTC

[5/5] stratos git commit: Update deployment policy rest call reply messages

Update deployment policy rest call reply messages


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

Branch: refs/heads/master
Commit: 98f667c104a2b3adcb676f19e5856235b8c8ff2b
Parents: c2894de
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Thu May 7 13:57:59 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Fri May 8 00:15:50 2015 +0530

----------------------------------------------------------------------
 .../stratos/rest/endpoint/api/StratosApiV41.java      | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/98f667c1/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 f165f41..47da053 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
@@ -161,12 +161,12 @@ public class StratosApiV41 extends AbstractApi {
         try {
             // TODO :: Deployment policy validation
             StratosApiV41Utils.addDeploymentPolicy(deploymentPolicyDefinitionBean);
-        } catch (RestAPIException e) {
-            throw e;
         } catch (AutoscalerServiceInvalidDeploymentPolicyExceptionException e) {
-            return Response.status(Response.Status.BAD_REQUEST).build();
+            return Response.status(Response.Status.BAD_REQUEST).entity(new StatusResponseBean(
+                    Response.Status.BAD_REQUEST.getStatusCode(), "Deployment policy is not valid")).build();
         } catch (AutoscalerServiceDeploymentPolicyAlreadyExistsExceptionException e) {
-            return Response.status(Response.Status.CONFLICT).build();
+            return Response.status(Response.Status.CONFLICT).entity(new StatusResponseBean(
+                    Response.Status.CONFLICT.getStatusCode(), "Deployment policy already exists")).build();
         }
         URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
         return Response.created(url).entity(new StatusResponseBean(Response.Status.CREATED.getStatusCode(),
@@ -189,7 +189,8 @@ public class StratosApiV41 extends AbstractApi {
             @PathParam("deploymentPolicyId") String deploymentPolicyId) throws RestAPIException {
         DeploymentPolicyBean deploymentPolicyBean = StratosApiV41Utils.getDeployementPolicy(deploymentPolicyId);
         if (deploymentPolicyBean == null) {
-            return Response.status(Response.Status.NOT_FOUND).build();
+            return Response.status(Response.Status.NOT_FOUND).entity(new StatusResponseBean(
+                    Response.Status.NOT_FOUND.getStatusCode(), "Deployment policy not found")).build();
         }
         return Response.ok(deploymentPolicyBean).build();
     }
@@ -209,7 +210,8 @@ public class StratosApiV41 extends AbstractApi {
             throws RestAPIException {
         DeploymentPolicyBean[] deploymentPolicies = StratosApiV41Utils.getDeployementPolicies();
         if (deploymentPolicies == null || deploymentPolicies.length == 0) {
-            return Response.status(Response.Status.NOT_FOUND).build();
+            return Response.status(Response.Status.NOT_FOUND).entity(new StatusResponseBean(
+                    Response.Status.NOT_FOUND.getStatusCode(), "No deployment policies found")).build();
         }
 
         return Response.ok(deploymentPolicies).build();