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/17 14:21:53 UTC
[1/2] git commit: Error handle in CLI
Updated Branches:
refs/heads/master 819373a9f -> b797ef7a5
Error handle 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/3fdc53cf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/3fdc53cf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/3fdc53cf
Branch: refs/heads/master
Commit: 3fdc53cfc813cc52ce427a2e496d83b172ccf596
Parents: 214bf85
Author: Manula Thantriwatte <ma...@apache.org>
Authored: Tue Dec 17 18:51:15 2013 +0530
Committer: Manula Thantriwatte <ma...@apache.org>
Committed: Tue Dec 17 18:51:15 2013 +0530
----------------------------------------------------------------------
.../stratos/cli/RestCommandLineService.java | 78 +++++++++++++++++---
.../apache/stratos/cli/utils/CliConstants.java | 1 +
2 files changed, 67 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3fdc53cf/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 5a517f1..175ffe7 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
@@ -172,8 +172,13 @@ public class RestCommandLineService {
HttpResponse response = restClientService.doGet(restClientService.getUrl() + listAvailableCartridgesRestEndpoint,
restClientService.getUsername(), restClientService.getPassword());
- String resultString = getHttpResponseString(response);
+ String responseCode = "" + response.getStatusLine().getStatusCode();
+ if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+ System.out.println("Error occur in list available cartridges");
+ return;
+ }
+ String resultString = getHttpResponseString(response);
if (resultString == null) {
return;
}
@@ -257,6 +262,12 @@ public class RestCommandLineService {
HttpResponse response = restClientService.doGet(restClientService.getUrl() + listSubscribedCartridgesRestEndpoint,
restClientService.getUsername(), restClientService.getPassword());
+ String responseCode = "" + response.getStatusLine().getStatusCode();
+ if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+ System.out.println("Error occur in list subscribe cartridges");
+ return;
+ }
+
String resultString = getHttpResponseString(response);
GsonBuilder gsonBuilder = new GsonBuilder();
@@ -351,9 +362,13 @@ public class RestCommandLineService {
HttpResponse response = restClientService.doPost(restClientService.getUrl() + subscribCartridgeRestEndpoint,
completeJsonSubscribeString, restClientService.getUsername(), restClientService.getPassword());
- String subscription = getHttpResponseString(response);
-
String responseCode = "" + response.getStatusLine().getStatusCode();
+ if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+ System.out.println("Error occur in subscribe cartridge");
+ return;
+ }
+
+ String subscription = getHttpResponseString(response);
if (subscription == null) {
System.out.println("Error");
@@ -401,9 +416,13 @@ public class RestCommandLineService {
HttpResponse response = restClientService.doPost(restClientService.getUrl() + subscribCartridgeRestEndpoint,
completeJsonSubscribeString, restClientService.getUsername(), restClientService.getPassword());
- String subscriptionOutput = getHttpResponseString(response);
String responseCode = "" + response.getStatusLine().getStatusCode();
+ if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+ System.out.println("Error occur in subscribe cartridge");
+ return;
+ }
+ String subscriptionOutput = getHttpResponseString(response);
if (subscriptionOutput == null) {
System.out.println("Error");
@@ -478,8 +497,11 @@ public class RestCommandLineService {
HttpResponse response = restClientService.doPost(restClientService.getUrl() + addTenantEndPoint,
completeJsonString, restClientService.getUsername(), restClientService.getPassword());
- String result = getHttpResponseString(response);
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");
@@ -516,8 +538,11 @@ public class RestCommandLineService {
HttpResponse response = restClientService.doPost(restClientService.getUrl() + cartridgeDeploymentEndPoint,
cartridgeDefinition, restClientService.getUsername(), restClientService.getPassword());
- String result = getHttpResponseString(response);
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");
@@ -536,8 +561,13 @@ public class RestCommandLineService {
HttpResponse response = restClientService.doPost(restClientService.getUrl() + partitionDeploymentEndPoint,
partitionDefinition, restClientService.getUsername(), restClientService.getPassword());
- String result = getHttpResponseString(response);
String responseCode = "" + response.getStatusLine().getStatusCode();
+ if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+ System.out.println("Error occur in deploy partition");
+ return;
+ }
+
+ String result = getHttpResponseString(response);
if (result.equals("true")) {
System.out.println("You have successfully deployed the partition");
@@ -564,8 +594,13 @@ public class RestCommandLineService {
HttpResponse response = restClientService.doPost(restClientService.getUrl() + autoscalingPolicyDeploymentEndPoint,
autoScalingPolicy, restClientService.getUsername(), restClientService.getPassword());
- String result = getHttpResponseString(response);
String responseCode = "" + response.getStatusLine().getStatusCode();
+ if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+ System.out.println("Error occur in deploy autoscaling policy");
+ return;
+ }
+
+ String result = getHttpResponseString(response);
if (result.equals("true")) {
System.out.println("You have successfully deployed the autoscaling policy");
@@ -592,8 +627,14 @@ public class RestCommandLineService {
HttpResponse response = restClientService.doPost(restClientService.getUrl() + deploymentPolicyDeploymentEndPoint,
deploymentPolicy, restClientService.getUsername(), restClientService.getPassword());
- String result = getHttpResponseString(response);
+
String responseCode = "" + response.getStatusLine().getStatusCode();
+ if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+ System.out.println("Error occur in deploy deployment policy");
+ return;
+ }
+
+ String result = getHttpResponseString(response);
if (result.equals("true")) {
System.out.println("You have successfully deployed the deployment policy");
@@ -620,9 +661,16 @@ public class RestCommandLineService {
HttpResponse response = restClientService.doGet(restClientService.getUrl() + listParitionRestEndPoint,
restClientService.getUsername(), restClientService.getPassword());
+ String responseCode = "" + response.getStatusLine().getStatusCode();
+ if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+ System.out.println("Error occur in list partitions");
+ return;
+ }
+
String resultString = getHttpResponseString(response);
if (resultString == null) {
+ System.out.println("Response content is empty");
return;
}
@@ -631,7 +679,7 @@ public class RestCommandLineService {
PartitionList partitionList = gson.fromJson(resultString, PartitionList.class);
if (partitionList == null) {
- System.out.println("Partition list is null");
+ System.out.println("Partition list is empty");
return;
}
@@ -665,10 +713,16 @@ public class RestCommandLineService {
HttpResponse response = restClientService.doGet(restClientService.getUrl() + listAutoscalePolicyRestEndPoint,
restClientService.getUsername(), restClientService.getPassword());
- System.out.println(response.getStatusLine().getStatusCode());
+ String responseCode = "" + response.getStatusLine().getStatusCode();
+ if ( ! responseCode.equals(CliConstants.RESPONSE_OK)) {
+ System.out.println("Error occur in list autoscase policies");
+ return;
+ }
+
String resultString = getHttpResponseString(response);
if (resultString == null) {
+ System.out.println("Response content is empty");
return;
}
@@ -677,7 +731,7 @@ public class RestCommandLineService {
AutoscalePolicyList policyList = gson.fromJson(resultString, AutoscalePolicyList.class);
if (policyList == null) {
- System.out.println("Autoscale policy list is null");
+ System.out.println("Autoscale policy list is empty");
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3fdc53cf/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
index 047bb50..382a82b 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
@@ -192,4 +192,5 @@ public class CliConstants {
public static final String RESPONSE_AUTHORIZATION_FAIL = "403";
public static final String RESPONSE_NO_CONTENT = "204";
public static final String RESPONSE_OK = "200";
+ public static final String RESPONSE_BAD_REQUEST = "400";
}
[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/b797ef7a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/b797ef7a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/b797ef7a
Branch: refs/heads/master
Commit: b797ef7a5e9fedb86f1914ea385ddfe7ea2597e5
Parents: 3fdc53c 819373a
Author: Manula Thantriwatte <ma...@apache.org>
Authored: Tue Dec 17 18:51:34 2013 +0530
Committer: Manula Thantriwatte <ma...@apache.org>
Committed: Tue Dec 17 18:51:34 2013 +0530
----------------------------------------------------------------------
.../main/java/org/apache/stratos/autoscaler/ClusterMonitor.java | 2 +-
features/adc/org.apache.stratos.adc.mgt.server.feature/pom.xml | 4 ++--
.../org.apache.stratos.cloud.controller.feature/pom.xml | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------