You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/12/12 14:08:44 UTC

stratos git commit: Returning 404 if autoscaling policy not found in /autoscalingPolicies/{autoscalePolicyId}

Repository: stratos
Updated Branches:
  refs/heads/4.1.0-test 0c4dee4db -> e28cc3e5b


Returning 404 if autoscaling policy not found in /autoscalingPolicies/{autoscalePolicyId}


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

Branch: refs/heads/4.1.0-test
Commit: e28cc3e5b2f6b4bb5a3a1a3ffdfaa823ce63db20
Parents: 0c4dee4
Author: Imesh Gunaratne <im...@apache.org>
Authored: Fri Dec 12 18:38:20 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Fri Dec 12 18:38:35 2014 +0530

----------------------------------------------------------------------
 .../org/apache/stratos/rest/endpoint/api/StratosApiV41.java    | 6 +++++-
 .../rest/endpoint/bean/util/converter/PojoConverter.java       | 5 ++---
 2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e28cc3e5/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 d827519..33bfdde 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
@@ -457,7 +457,11 @@ public class StratosApiV41 extends AbstractApi {
     @AuthorizationAction("/permission/admin/manage/view/autoscalingPolicy")
     public Response getAutoscalingPolicy(@PathParam("autoscalePolicyId") String autoscalePolicyId)
             throws RestAPIException {
-        return Response.ok().entity(StratosApiV41Utils.getAutoScalePolicy(autoscalePolicyId)).build();
+        AutoscalePolicy autoScalePolicy = StratosApiV41Utils.getAutoScalePolicy(autoscalePolicyId);
+        if(autoScalePolicy == null) {
+            return Response.status(Response.Status.NOT_FOUND).build();
+        }
+        return Response.ok().entity(autoScalePolicy).build();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/stratos/blob/e28cc3e5/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
index 1e5091f..9649fb7 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
@@ -720,12 +720,11 @@ public class PojoConverter {
 
     public static AutoscalePolicy populateAutoscalePojo(org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy
                                                                 autoscalePolicy) {
-
-        AutoscalePolicy autoscalePolicyBean = new AutoscalePolicy();
         if (autoscalePolicy == null) {
-            return autoscalePolicyBean;
+            return null;
         }
 
+        AutoscalePolicy autoscalePolicyBean = new AutoscalePolicy();
         autoscalePolicyBean.setId(autoscalePolicy.getId());
         autoscalePolicyBean.setDescription(autoscalePolicy.getDescription());
         autoscalePolicyBean.setIsPublic(autoscalePolicy.getIsPublic());