You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ma...@apache.org on 2013/12/18 08:24:04 UTC

[1/2] git commit: Handle error messages in CLI

Updated Branches:
  refs/heads/master 9728aa25c -> 507a882c4


Handle error messages in CLI


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

Branch: refs/heads/master
Commit: c429cc787f89ccc9e0e8cd08448e1ee09ff9d1e4
Parents: 39395ad
Author: Manula Thantriwatte <ma...@apache.org>
Authored: Wed Dec 18 12:53:29 2013 +0530
Committer: Manula Thantriwatte <ma...@apache.org>
Committed: Wed Dec 18 12:53:29 2013 +0530

----------------------------------------------------------------------
 .../stratos/cli/RestCommandLineService.java     | 123 ++++++++-----------
 1 file changed, 53 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/c429cc78/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 d2089fd..a948f9f 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
@@ -364,7 +364,13 @@ public class RestCommandLineService {
                         completeJsonSubscribeString, restClientService.getUsername(), restClientService.getPassword());
 
                 String responseCode = "" + response.getStatusLine().getStatusCode();
-                if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+                if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
+                    System.out.println("Invalid operation. Authorization failed");
+                    return;
+                } else if (responseCode.equals(CliConstants.RESPONSE_NO_CONTENT)) {
+                    System.out.println("Duplicate alias. Please choose different alias");
+                    return;
+                } else if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
                     System.out.println("Error occur in subscribe cartridge");
                     return;
                 }
@@ -372,17 +378,7 @@ public class RestCommandLineService {
                 String subscription = getHttpResponseString(response);
 
                 if (subscription == null) {
-                    System.out.println("Error");
-                    return;
-                }
-                else if (responseCode.equals(CliConstants.RESPONSE_NO_CONTENT)) {
-                    System.out.println("Duplicate alias. Please choose different alias");
-                    return;
-                } else if (responseCode.equals(CliConstants.RESPONSE_INTERNAL_SERVER_ERROR)) {
-                    System.out.println("Error in backend");
-                    return;
-                } else if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
-                    System.out.println("Invalid operation. Authorization failed");
+                    System.out.println("Error in response");
                     return;
                 }
 
@@ -418,7 +414,13 @@ public class RestCommandLineService {
                     completeJsonSubscribeString, restClientService.getUsername(), restClientService.getPassword());
 
             String responseCode = "" + response.getStatusLine().getStatusCode();
-            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+            if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
+                System.out.println("Invalid operation. Authorization failed");
+                return;
+            } else if (responseCode.equals(CliConstants.RESPONSE_NO_CONTENT)) {
+                System.out.println("Duplicate alias. Please choose different alias");
+                return;
+            } else if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
                 System.out.println("Error occur in subscribe cartridge");
                 return;
             }
@@ -426,16 +428,7 @@ public class RestCommandLineService {
             String subscriptionOutput = getHttpResponseString(response);
 
             if (subscriptionOutput == null) {
-                System.out.println("Error");
-                return;
-            } else if (responseCode.equals(CliConstants.RESPONSE_NO_CONTENT)) {
-                System.out.println("Duplicate alias. Please choose different alias");
-                return;
-            } else if (responseCode.equals(CliConstants.RESPONSE_INTERNAL_SERVER_ERROR)) {
-                System.out.println("Error in backend");
-                return;
-            } else if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
-                System.out.println("Invalid operation. Authorization failed");
+                System.out.println("Error in response");
                 return;
             }
 
@@ -499,24 +492,23 @@ public class RestCommandLineService {
                     completeJsonString, restClientService.getUsername(), restClientService.getPassword());
 
             String responseCode = "" + response.getStatusLine().getStatusCode();
-            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
-                System.out.println("Error occur in create tenant");
-                return;
-            }
-
             if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
                 System.out.println("Invalid operation. Authorization failed");
                 return;
-            } else if (responseCode.equals(CliConstants.RESPONSE_INTERNAL_SERVER_ERROR)) {
-                System.out.println("Domain is not available to register. Please check domain name");
+            } else if (responseCode.equals(CliConstants.RESPONSE_NO_CONTENT)) {
+                System.out.println("Duplicate alias. Please choose different alias");
                 return;
             } else if (responseCode.equals(CliConstants.RESPONSE_OK)){
                 System.out.println("Tenant added successfully");
                 return;
+            } else if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+                System.out.println("Error occur in create tenant");
+                return;
             } else {
                 System.out.println ("Unhandle error");
                 return;
             }
+
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -540,16 +532,16 @@ public class RestCommandLineService {
                     cartridgeDefinition, restClientService.getUsername(), restClientService.getPassword());
 
             String responseCode = "" + response.getStatusLine().getStatusCode();
-            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
-                System.out.println("Error occur in deploy cartridge definition");
-                return;
-            }
 
             if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
                 System.out.println("Invalid operations. Authorization failed");
-            }
-            else {
+                return;
+            } else if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+                System.out.println("Error occur in deploy cartridge definition");
+                return;
+            } else {
                 System.out.println("You have successfully deployed the cartridge");
+                return;
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -563,7 +555,11 @@ public class RestCommandLineService {
                     partitionDefinition, restClientService.getUsername(), restClientService.getPassword());
 
             String responseCode = "" + response.getStatusLine().getStatusCode();
-            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+
+            if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
+                System.out.println("Invalid operations. Authorization failed");
+                return;
+            } else if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
                 System.out.println("Error occur in deploy partition");
                 return;
             }
@@ -573,15 +569,6 @@ public class RestCommandLineService {
             if (result.equals("true")) {
                 System.out.println("You have successfully deployed the partition");
                 return;
-            } else if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
-                System.out.println("Invalid operations. Authorization failed");
-                return;
-            } else if (responseCode.equals(CliConstants.RESPONSE_INTERNAL_SERVER_ERROR)) {
-                System.out.println("Specified policy already exists");
-                return;
-            } else {
-                System.out.println ("Unhandle error");
-                return;
             }
 
         } catch (Exception e) {
@@ -596,7 +583,10 @@ public class RestCommandLineService {
                     autoScalingPolicy, restClientService.getUsername(), restClientService.getPassword());
 
             String responseCode = "" + response.getStatusLine().getStatusCode();
-            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+            if (responseCode.equals("" + CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
+                System.out.println("Invalid operations. Authorization failed");
+                return;
+            } else if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
                 System.out.println("Error occur in deploy autoscaling policy");
                 return;
             }
@@ -606,15 +596,6 @@ public class RestCommandLineService {
             if (result.equals("true")) {
                 System.out.println("You have successfully deployed the autoscaling policy");
                 return;
-            } else if (responseCode.equals("" + CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
-                System.out.println("Invalid operations. Authorization failed");
-                return;
-            } else if (responseCode.equals("" + CliConstants.RESPONSE_INTERNAL_SERVER_ERROR)) {
-                System.out.println("Specified policy already exists");
-                return;
-            } else {
-                System.out.println ("Unhandle error");
-                return;
             }
 
         } catch (Exception e) {
@@ -628,9 +609,11 @@ public class RestCommandLineService {
             HttpResponse response = restClientService.doPost(restClientService.getUrl() + deploymentPolicyDeploymentEndPoint,
                     deploymentPolicy, restClientService.getUsername(), restClientService.getPassword());
 
-
             String responseCode = "" + response.getStatusLine().getStatusCode();
-            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+            if (responseCode.equals("" + CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
+                System.out.println("Invalid operations. Authorization failed");
+                return;
+            } else if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
                 System.out.println("Error occur in deploy deployment policy");
                 return;
             }
@@ -640,15 +623,6 @@ public class RestCommandLineService {
             if (result.equals("true")) {
                 System.out.println("You have successfully deployed the deployment policy");
                 return;
-            } else if (responseCode.equals("" + CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
-                System.out.println("Invalid operations. Authorization failed");
-                return;
-            } else if (responseCode.equals("" + CliConstants.RESPONSE_INTERNAL_SERVER_ERROR)) {
-                System.out.println("Specified policy already exists");
-                return;
-            } else {
-                System.out.println ("Unhandle error");
-                return;
             }
 
         } catch (Exception e) {
@@ -663,7 +637,10 @@ public class RestCommandLineService {
                     restClientService.getUsername(), restClientService.getPassword());
 
             String responseCode = "" + response.getStatusLine().getStatusCode();
-            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+            if (responseCode.equals("" + CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
+                System.out.println("Invalid operations. Authorization failed");
+                return;
+            } else if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
                 System.out.println("Error occur in list partitions");
                 return;
             }
@@ -715,7 +692,10 @@ public class RestCommandLineService {
                     restClientService.getUsername(), restClientService.getPassword());
 
             String responseCode = "" + response.getStatusLine().getStatusCode();
-            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+            if (responseCode.equals("" + CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
+                System.out.println("Invalid operations. Authorization failed");
+                return;
+            } else if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
                 System.out.println("Error occur in list autoscase policies");
                 return;
             }
@@ -766,7 +746,10 @@ public class RestCommandLineService {
                     restClientService.getUsername(), restClientService.getPassword());
 
             String responseCode = "" + response.getStatusLine().getStatusCode();
-            if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+            if (responseCode.equals("" + CliConstants.RESPONSE_AUTHORIZATION_FAIL)) {
+                System.out.println("Invalid operations. Authorization failed");
+                return;
+            } else if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
                 System.out.println("Error occur in list deployment policies");
                 return;
             }


[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos

Posted by ma...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos


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

Branch: refs/heads/master
Commit: 507a882c435086f8cb88c4352c12ff4e8f43f2f7
Parents: c429cc7 9728aa2
Author: Manula Thantriwatte <ma...@apache.org>
Authored: Wed Dec 18 12:53:48 2013 +0530
Committer: Manula Thantriwatte <ma...@apache.org>
Committed: Wed Dec 18 12:53:48 2013 +0530

----------------------------------------------------------------------
 .../stratos/adc/mgt/client/AutoscalerServiceClient.java      | 8 ++++----
 .../stratos/adc/mgt/client/CloudControllerServiceClient.java | 6 +++---
 .../client/cloud/controller/CloudControllerClient.java       | 4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------