Repository: stratos
Updated Branches:
  refs/heads/master ce277f44d -> 73fdb984e


Fixing error handling in RestCommandLineService.executeList()


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

Branch: refs/heads/master
Commit: 73fdb984e2fbafa196e7761d903260c2d0582238
Parents: ce277f4
Author: Imesh Gunaratne <[email protected]>
Authored: Sat Oct 11 06:47:39 2014 +0530
Committer: Imesh Gunaratne <[email protected]>
Committed: Sat Oct 11 06:59:11 2014 +0530

----------------------------------------------------------------------
 .../org/apache/stratos/cli/RestCommandLineService.java  | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/73fdb984/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
index a02effe..b98575d 100644
--- 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
@@ -2115,14 +2115,17 @@ public class RestCommandLineService {
         try {
             response = restClient.doGet(httpClient, restClient.getBaseURL() + 
serviceEndpoint);
             int responseCode = response.getStatusLine().getStatusCode();
+            String resultString = getHttpResponseString(response);
 
-            if (responseCode != 200) {
-                String resultString = getHttpResponseString(response);
+            GsonBuilder gsonBuilder = new GsonBuilder();
+            Gson gson = gsonBuilder.create();
+
+            if (responseCode == 200) {
+                return gson.fromJson(resultString, _class);
+            } else {
                 if(StringUtils.isBlank(resultString)) {
                     return null;
                 } else {
-                    GsonBuilder gsonBuilder = new GsonBuilder();
-                    Gson gson = gsonBuilder.create();
                     ExceptionMapper exception = gson.fromJson(resultString, 
ExceptionMapper.class);
                     if(exception != null) {
                         System.out.println(exception);
@@ -2130,7 +2133,6 @@ public class RestCommandLineService {
                     return gson.fromJson(resultString, _class);
                 }
             }
-            return null;
         } catch (Exception e) {
             handleException(String.format("Error in listing %s", entityName), 
e);
             return null;

Reply via email to