Updated Branches: refs/heads/master 8ee2fb1f1 -> b38067fa3
Remove unnecessary stactrace and handle http response 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/7429d3cd Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/7429d3cd Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/7429d3cd Branch: refs/heads/master Commit: 7429d3cdc8f648165c88781e3983139b4c3dc20e Parents: af57d48 Author: Manula Thantriwatte <[email protected]> Authored: Wed Dec 18 23:01:35 2013 +0530 Committer: Manula Thantriwatte <[email protected]> Committed: Wed Dec 18 23:01:35 2013 +0530 ---------------------------------------------------------------------- .../java/org/apache/stratos/cli/RestClient.java | 9 +++++++-- .../stratos/cli/RestCommandLineService.java | 21 +++++++------------- 2 files changed, 14 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/7429d3cd/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java index 5bf086c..17d98a4 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java @@ -105,7 +105,7 @@ public class RestClient implements GenericRestClient{ } */ - httpClient.getConnectionManager().shutdown(); + //httpClient.getConnectionManager().shutdown(); //return result; return response; @@ -144,6 +144,11 @@ public class RestClient implements GenericRestClient{ getRequest.addHeader("Authorization", basicAuth); httpClient = (DefaultHttpClient) WebClientWrapper.wrapClient(httpClient); + + HttpParams params = httpClient.getParams(); + HttpConnectionParams.setConnectionTimeout(params, 300000); + HttpConnectionParams.setSoTimeout(params, 300000); + HttpResponse response = httpClient.execute(getRequest); /* @@ -160,7 +165,7 @@ public class RestClient implements GenericRestClient{ } */ - httpClient.getConnectionManager().shutdown(); + //httpClient.getConnectionManager().shutdown(); return response; } catch (ClientProtocolException e) { http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/7429d3cd/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 59bb7ba..66c2b73 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 @@ -376,13 +376,10 @@ public class RestCommandLineService { return; } - System.out.println("Response code : " + responseCode); - System.out.println(completeJsonSubscribeString); - String subscription = getHttpResponseString(response); if (subscription == null) { - System.out.println("Error in response 1"); + System.out.println("Error in response"); return; } @@ -429,13 +426,10 @@ public class RestCommandLineService { return; } - System.out.println("Response code : " + responseCode); - System.out.println(completeJsonSubscribeString); - String subscriptionOutput = getHttpResponseString(response); if (subscriptionOutput == null) { - System.out.println("Error in response 2"); + System.out.println("Error in response"); return; } @@ -471,7 +465,7 @@ public class RestCommandLineService { System.out.println(takeTimeMsg); } - System.out.format("Please map the %s \"%s\" to ELB IP%n", hostnamesLabel, hostnames); + System.out.format("Please map the %s \"%s\" to LB IP%n", hostnamesLabel, hostnames); } catch (Exception e) { e.printStackTrace(); } @@ -540,12 +534,12 @@ public class RestCommandLineService { if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) { System.out.println("Invalid operations. Authorization failed"); return; + } else if (responseCode.equals(CliConstants.RESPONSE_NO_CONTENT)) { + System.out.println("You have successfully deployed the cartridge"); + 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(); @@ -894,14 +888,13 @@ public class RestCommandLineService { } return result; } catch (SocketException e) { - e.printStackTrace(); System.out.println("Connection problem"); return null; } catch (NullPointerException e) { System.out.println("Null value return from server"); return null; } catch (IOException e) { - e.printStackTrace(); + System.out.println("IO error"); return null; } }
