Updated Branches: refs/heads/master 081f9fc95 -> 69e36903c
Fixed issues 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/df9d500f Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/df9d500f Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/df9d500f Branch: refs/heads/master Commit: df9d500f85922971bcb288b4b90591b35c1cf76e Parents: 41e5f69 Author: Manula Thantriwatte <[email protected]> Authored: Thu Dec 12 18:08:20 2013 +0530 Committer: Manula Thantriwatte <[email protected]> Committed: Thu Dec 12 18:08:20 2013 +0530 ---------------------------------------------------------------------- .../apache/stratos/cli/CartridgeInfoBean.java | 20 +-- .../apache/stratos/cli/GenericRestClient.java | 6 +- .../java/org/apache/stratos/cli/RestClient.java | 13 +- .../stratos/cli/RestCommandLineService.java | 135 ++++++++++++++----- .../stratos/cli/commands/AddTenantCommand.java | 20 +-- .../stratos/cli/commands/SubscribeCommand.java | 13 +- .../apache/stratos/cli/utils/CliConstants.java | 7 +- 7 files changed, 145 insertions(+), 69 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df9d500f/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CartridgeInfoBean.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CartridgeInfoBean.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CartridgeInfoBean.java index a2b3511..67ca931 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CartridgeInfoBean.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CartridgeInfoBean.java @@ -30,8 +30,8 @@ public class CartridgeInfoBean { String repoPassword; String dataCartridgeType; String dataCartridgeAlias; - private String asPolicy; - private String depPolicy; + private String autoscalePolicy; + private String deploymentPolicy; public String getCartridgeType() { @@ -106,19 +106,19 @@ public class CartridgeInfoBean { this.dataCartridgeAlias = dataCartridgeAlias; } - public String getAsPolicy() { - return asPolicy; + public String getAutoscalePolicy() { + return autoscalePolicy; } - public void setAsPolicy(String asPolicy) { - this.asPolicy = asPolicy; + public void setAutoscalePolicy(String autoscalePolicy) { + this.autoscalePolicy = autoscalePolicy; } - public String getDepPolicy() { - return depPolicy; + public String getDeploymentPolicy() { + return deploymentPolicy; } - public void setDepPolicy(String depPolicy) { - this.depPolicy = depPolicy; + public void setDeploymentPolicy(String deploymentPolicy) { + this.deploymentPolicy = deploymentPolicy; } } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df9d500f/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/GenericRestClient.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/GenericRestClient.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/GenericRestClient.java index 539ff1b..17213da 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/GenericRestClient.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/GenericRestClient.java @@ -18,6 +18,8 @@ */ package org.apache.stratos.cli; +import org.apache.http.HttpResponse; + public interface GenericRestClient { /** @@ -35,7 +37,7 @@ public interface GenericRestClient { * @throws org.apache.http.client.ClientProtocolException and IOException * if any errors occur when executing the request */ - public String doPost(String resourcePath, String jsonParamString, String userName, String passWord) throws Exception; + public HttpResponse doPost(String resourcePath, String jsonParamString, String userName, String passWord) throws Exception; /** * Handle http get request. Return String @@ -50,7 +52,7 @@ public interface GenericRestClient { * @throws org.apache.http.client.ClientProtocolException and IOException * if any errors occur when executing the request */ - public String doGet(String resourcePath, String userName, String passWord); + public HttpResponse doGet(String resourcePath, String userName, String passWord); public void doDelete(); http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df9d500f/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 266591d..e27308e 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 @@ -58,7 +58,7 @@ public class RestClient implements GenericRestClient{ * @throws org.apache.http.client.ClientProtocolException and IOException * if any errors occur when executing the request */ - public String doPost(String resourcePath, String jsonParamString, String userName, String passWord) throws Exception{ + public HttpResponse doPost(String resourcePath, String jsonParamString, String userName, String passWord) throws Exception{ try { DefaultHttpClient httpClient = new DefaultHttpClient(); @@ -76,6 +76,7 @@ public class RestClient implements GenericRestClient{ httpClient = (DefaultHttpClient) WebClientWrapper.wrapClient(httpClient); HttpResponse response = httpClient.execute(postRequest); + /* int responseCode = response.getStatusLine().getStatusCode(); if (responseCode == CliConstants.RESPONSE_AUTHORIZATION_FAIL) { @@ -95,9 +96,11 @@ public class RestClient implements GenericRestClient{ while ((output = br.readLine()) != null) { result += output; } + */ httpClient.getConnectionManager().shutdown(); - return result; + //return result; + return response; } catch (ClientProtocolException e) { throw new ClientProtocolException(); @@ -123,7 +126,7 @@ public class RestClient implements GenericRestClient{ * @throws org.apache.http.client.ClientProtocolException and IOException * if any errors occur when executing the request */ - public String doGet(String resourcePath, String userName, String passWord) { + public HttpResponse doGet(String resourcePath, String userName, String passWord) { try { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet getRequest = new HttpGet(resourcePath); @@ -136,6 +139,7 @@ public class RestClient implements GenericRestClient{ httpClient = (DefaultHttpClient) WebClientWrapper.wrapClient(httpClient); HttpResponse response = httpClient.execute(getRequest); + /* if (response.getStatusLine().getStatusCode() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode()); } @@ -147,9 +151,10 @@ public class RestClient implements GenericRestClient{ while ((output = br.readLine()) != null) { result += output; } + */ httpClient.getConnectionManager().shutdown(); - return result; + return response; } catch (ClientProtocolException e) { e.printStackTrace(); http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df9d500f/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 72bcb44..9f0b696 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 @@ -26,12 +26,16 @@ import org.apache.axis2.context.ConfigurationContextFactory; import org.apache.axis2.description.TransportOutDescription; import org.apache.axis2.transport.http.HttpTransportProperties; import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.stratos.cli.exception.CommandException; import org.apache.stratos.cli.utils.CliConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; import java.net.ConnectException; import java.util.ArrayList; import java.util.HashMap; @@ -163,9 +167,11 @@ public class RestCommandLineService { // List currently available multi tenant and single tenant cartridges public void listAvailableCartridges() throws CommandException { try { - String resultString = restClientService.doGet(restClientService.getUrl() + listAvailableCartridgesRestEndpoint, + HttpResponse response = restClientService.doGet(restClientService.getUrl() + listAvailableCartridgesRestEndpoint, restClientService.getUsername(), restClientService.getPassword()); + String resultString = getHttpResponseString(response); + GsonBuilder gsonBuilder = new GsonBuilder(); Gson gson = gsonBuilder.create(); CartridgeList cartridgeList = gson.fromJson(resultString, CartridgeList.class); @@ -241,9 +247,11 @@ public class RestCommandLineService { public void listSubscribedCartridges(final boolean full) throws CommandException { try { - String resultString = restClientService.doGet(restClientService.getUrl() + listSubscribedCartridgesRestEndpoint, + HttpResponse response = restClientService.doGet(restClientService.getUrl() + listSubscribedCartridgesRestEndpoint, restClientService.getUsername(), restClientService.getPassword()); + String resultString = getHttpResponseString(response); + GsonBuilder gsonBuilder = new GsonBuilder(); Gson gson = gsonBuilder.create(); CartridgeList cartridgeList = gson.fromJson(resultString, CartridgeList.class); @@ -316,8 +324,8 @@ public class RestCommandLineService { cartridgeInfoBean.setPrivateRepo(false); cartridgeInfoBean.setRepoUsername(null); cartridgeInfoBean.setRepoPassword(null); - cartridgeInfoBean.setAsPolicy(null); - cartridgeInfoBean.setDepPolicy(null); + cartridgeInfoBean.setAutoscalePolicy(null); + cartridgeInfoBean.setDeploymentPolicy(null); cartridgeInfoBean.setDataCartridgeType(dataCartridgeType); cartridgeInfoBean.setDataCartridgeAlias(dataCartridgeAlias); @@ -332,16 +340,20 @@ public class RestCommandLineService { System.out.format("Subscribing to data cartridge %s with alias %s.%n", dataCartridgeType, dataCartridgeAlias); try { - String subscription = restClientService.doPost(restClientService.getUrl() + subscribCartridgeRestEndpoint, + HttpResponse response = restClientService.doPost(restClientService.getUrl() + subscribCartridgeRestEndpoint, completeJsonSubscribeString, restClientService.getUsername(), restClientService.getPassword()); - if (subscription.equals("" + CliConstants.RESPONSE_NO_CONTENT)) { + String subscription = getHttpResponseString(response); + + String responseCode = "" + response.getStatusLine().getStatusCode(); + + if (responseCode.equals(CliConstants.RESPONSE_NO_CONTENT)) { System.out.println("Duplicate alias. Please choose different alias"); return; - } else if (subscription.equals("" + CliConstants.RESPONSE_INTERNAL_SERVER_ERROR)) { + } else if (responseCode.equals(CliConstants.RESPONSE_INTERNAL_SERVER_ERROR)) { System.out.println("Error in backend"); return; - } else if (subscription.equals("" + CliConstants.RESPONSE_AUTHORIZATION_FAIL)) { + } else if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) { System.out.println("Invalid operation. Authorization failed"); return; } @@ -368,22 +380,25 @@ public class RestCommandLineService { cartridgeInfoBean.setRepoPassword(password); cartridgeInfoBean.setDataCartridgeType(dataCartridgeType); cartridgeInfoBean.setDataCartridgeAlias(dataCartridgeAlias); - cartridgeInfoBean.setAsPolicy(asPolicy); - cartridgeInfoBean.setDepPolicy(depPolicy); + cartridgeInfoBean.setAutoscalePolicy(asPolicy); + cartridgeInfoBean.setDeploymentPolicy(depPolicy); jsonSubscribeString = gson.toJson(cartridgeInfoBean, CartridgeInfoBean.class); completeJsonSubscribeString = "{\"cartridgeInfoBean\":" + jsonSubscribeString + "}"; - String subscriptionOutput = restClientService.doPost(restClientService.getUrl() + subscribCartridgeRestEndpoint, + HttpResponse response = restClientService.doPost(restClientService.getUrl() + subscribCartridgeRestEndpoint, completeJsonSubscribeString, restClientService.getUsername(), restClientService.getPassword()); - if (subscriptionOutput.equals("" + CliConstants.RESPONSE_NO_CONTENT)) { + String subscriptionOutput = getHttpResponseString(response); + String responseCode = "" + response.getStatusLine().getStatusCode(); + + if (responseCode.equals(CliConstants.RESPONSE_NO_CONTENT)) { System.out.println("Duplicate alias. Please choose different alias"); return; - } else if (subcriptionConnectInfo.equals("" + CliConstants.RESPONSE_INTERNAL_SERVER_ERROR)) { + } else if (responseCode.equals(CliConstants.RESPONSE_INTERNAL_SERVER_ERROR)) { System.out.println("Error in backend"); return; - } else if (subscriptionOutput.equals("" + CliConstants.RESPONSE_AUTHORIZATION_FAIL)) { + } else if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) { System.out.println("Invalid operation. Authorization failed"); return; } @@ -427,7 +442,7 @@ public class RestCommandLineService { } // This method helps to create the new tenant - public void addTenant(String admin, String firstName, String lastaName, String password, String domain, String email, String active){ + public void addTenant(String admin, String firstName, String lastaName, String password, String domain, String email){ try { TenantInfoBean tenantInfo = new TenantInfoBean(); tenantInfo.setAdmin(admin); @@ -436,7 +451,7 @@ public class RestCommandLineService { tenantInfo.setAdminPassword(password); tenantInfo.setTenantDomain(domain); tenantInfo.setEmail(email); - tenantInfo.setActive(active); + //tenantInfo.setActive(active); GsonBuilder gsonBuilder = new GsonBuilder(); Gson gson = gsonBuilder.create(); @@ -444,15 +459,25 @@ public class RestCommandLineService { String jsonString = gson.toJson(tenantInfo, TenantInfoBean.class); String completeJsonString = "{\"tenantInfoBean\":" + jsonString + "}"; - String result = restClientService.doPost(restClientService.getUrl() + addTenantEndPoint, + HttpResponse response = restClientService.doPost(restClientService.getUrl() + addTenantEndPoint, completeJsonString, restClientService.getUsername(), restClientService.getPassword()); - if (Integer.parseInt(result) == CliConstants.RESPONSE_AUTHORIZATION_FAIL) { + String result = getHttpResponseString(response); + String responseCode = "" + response.getStatusLine().getStatusCode(); + System.out.println(responseCode); + + if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) { System.out.println("Invalid operation. Authorization failed"); - } else if (Integer.parseInt(result) == CliConstants.RESPONSE_NO_CONTENT) { - System.out.println("Tenant added successfully"); - } else if (Integer.parseInt(result) == CliConstants.RESPONSE_INTERNAL_SERVER_ERROR) { + return; + } else if (responseCode.equals(CliConstants.RESPONSE_INTERNAL_SERVER_ERROR)) { System.out.println("Domain is not available to register. Please check domain name"); + return; + } else if (responseCode.equals(CliConstants.RESPONSE_OK)){ + System.out.println("Tenant added successfully"); + return; + } else { + System.out.println ("Unhandle error"); + return; } } catch (Exception e) { e.printStackTrace(); @@ -473,10 +498,13 @@ public class RestCommandLineService { // This method helps to deploy cartridge definitions public void deployCartridgeDefinition (String cartridgeDefinition) { try { - String result = restClientService.doPost(restClientService.getUrl() + cartridgeDeploymentEndPoint, + HttpResponse response = restClientService.doPost(restClientService.getUrl() + cartridgeDeploymentEndPoint, cartridgeDefinition, restClientService.getUsername(), restClientService.getPassword()); - if (Integer.parseInt(result) == CliConstants.RESPONSE_AUTHORIZATION_FAIL) { + String result = getHttpResponseString(response); + String responseCode = "" + response.getStatusLine().getStatusCode(); + + if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) { System.out.println("Invalid operations. Authorization failed"); } else { @@ -490,15 +518,24 @@ public class RestCommandLineService { // This method helps to deploy partitions public void deployPartition (String partitionDefinition) { try { - String result = restClientService.doPost(restClientService.getUrl() + partitionDeploymentEndPoint, + HttpResponse response = restClientService.doPost(restClientService.getUrl() + partitionDeploymentEndPoint, partitionDefinition, restClientService.getUsername(), restClientService.getPassword()); + String result = getHttpResponseString(response); + String responseCode = "" + response.getStatusLine().getStatusCode(); + if (result.equals("true")) { System.out.println("You have successfully deployed the partition"); - } else if (Integer.parseInt(result) == CliConstants.RESPONSE_AUTHORIZATION_FAIL) { + return; + } else if (responseCode.equals(CliConstants.RESPONSE_AUTHORIZATION_FAIL)) { System.out.println("Invalid operations. Authorization failed"); - } else if (Integer.parseInt(result) == CliConstants.RESPONSE_INTERNAL_SERVER_ERROR) { + 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) { @@ -509,15 +546,24 @@ public class RestCommandLineService { // This method helps to deploy autoscalling polices public void deployAutoscalingPolicy (String autoScalingPolicy) { try { - String result = restClientService.doPost(restClientService.getUrl() + autoscalingPolicyDeploymentEndPoint, + HttpResponse response = restClientService.doPost(restClientService.getUrl() + autoscalingPolicyDeploymentEndPoint, autoScalingPolicy, restClientService.getUsername(), restClientService.getPassword()); + String result = getHttpResponseString(response); + String responseCode = "" + response.getStatusLine().getStatusCode(); + if (result.equals("true")) { System.out.println("You have successfully deployed the autoscaling policy"); - } else if (Integer.parseInt(result) == CliConstants.RESPONSE_AUTHORIZATION_FAIL) { + return; + } else if (responseCode.equals("" + CliConstants.RESPONSE_AUTHORIZATION_FAIL)) { System.out.println("Invalid operations. Authorization failed"); - } else if (Integer.parseInt(result) == CliConstants.RESPONSE_INTERNAL_SERVER_ERROR) { + 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) { @@ -528,15 +574,24 @@ public class RestCommandLineService { // This method helps to deploy deployment polices public void deployDeploymentPolicy (String deploymentPolicy) { try { - String result = restClientService.doPost(restClientService.getUrl() + deploymentPolicyDeploymentEndPoint, + HttpResponse response = restClientService.doPost(restClientService.getUrl() + deploymentPolicyDeploymentEndPoint, deploymentPolicy, restClientService.getUsername(), restClientService.getPassword()); + String result = getHttpResponseString(response); + String responseCode = "" + response.getStatusLine().getStatusCode(); + if (result.equals("true")) { System.out.println("You have successfully deployed the deployment policy"); - } else if (Integer.parseInt(result) == CliConstants.RESPONSE_AUTHORIZATION_FAIL) { + return; + } else if (responseCode.equals("" + CliConstants.RESPONSE_AUTHORIZATION_FAIL)) { System.out.println("Invalid operations. Authorization failed"); - } else if (Integer.parseInt(result) == CliConstants.RESPONSE_INTERNAL_SERVER_ERROR) { + 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) { @@ -578,4 +633,20 @@ public class RestCommandLineService { } return urlBuilder.toString(); } + + private String getHttpResponseString (HttpResponse response) { + try { + BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent()))); + + String output; + String result = ""; + while ((output = br.readLine()) != null) { + result += output; + } + return result; + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df9d500f/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java index 9f0eff2..4139866 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java @@ -153,19 +153,19 @@ public class AddTenantCommand implements Command<StratosCommandContext> { email = commandLine.getOptionValue(CliConstants.EMAIL_OPTION); } - if (commandLine.hasOption(CliConstants.ACTIVE_OPTION)) { - if (logger.isTraceEnabled()) { - logger.trace("Tenat active option is passed"); - } - active = commandLine.getOptionValue(CliConstants.ACTIVE_OPTION); - } - - if (admin == null || firstName == null || lastaName == null || password == null || domain == null || email == null || active == null) { - System.out.println("usage: " + getName() + " [-u <user name>] [-f <first name>] [-l <last name>] [-p <password>] [-d <domain name>] [-e <email>] [-a <active/deactivate>]"); + //if (commandLine.hasOption(CliConstants.ACTIVE_OPTION)) { + // if (logger.isTraceEnabled()) { + // logger.trace("Tenat active option is passed"); + // } + // active = commandLine.getOptionValue(CliConstants.ACTIVE_OPTION); + //} + + if (admin == null || firstName == null || lastaName == null || password == null || domain == null || email == null) { + System.out.println("usage: " + getName() + " [-u <user name>] [-f <first name>] [-l <last name>] [-p <password>] [-d <domain name>] [-e <email>]"); return CliConstants.BAD_ARGS_CODE; } - RestCommandLineService.getInstance().addTenant(admin, firstName, lastaName, password, domain, email, active); + RestCommandLineService.getInstance().addTenant(admin, firstName, lastaName, password, domain, email); return CliConstants.SUCCESSFUL_CODE; } catch (ParseException e) { http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df9d500f/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java index 8d90d0e..21bac0f 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java @@ -98,22 +98,18 @@ public class SubscribeCommand implements Command<StratosCommandContext> { return options; } - @Override public String getName() { return CliConstants.SUBSCRIBE_ACTION; } - @Override public String getDescription() { return "Subscribe to a cartridge"; } - @Override public String getArgumentSyntax() { return "[Cartridge type] [Cartridge alias]"; } - @Override public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); @@ -151,17 +147,18 @@ public class SubscribeCommand implements Command<StratosCommandContext> { // } // policy = commandLine.getOptionValue(CliConstants.POLICY_OPTION); //} - if (commandLine.hasOption(CliConstants.AUTOSCALING_POLICY_DEPLOYMENT)) { + if (commandLine.hasOption(CliConstants.AUTOSCALING_POLICY_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Autoscaling policy option is passed"); } - asPolicy = commandLine.getOptionValue(CliConstants.AUTOSCALING_POLICY_DEPLOYMENT); + asPolicy = commandLine.getOptionValue(CliConstants.AUTOSCALING_POLICY_OPTION); + System.out.println(asPolicy); } - if (commandLine.hasOption(CliConstants.DEPLOYMENT_POLICY_DEPLOYMENT)) { + if (commandLine.hasOption(CliConstants.DEPLOYMENT_POLICY_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Deployment policy option is passed"); } - depPolicy = commandLine.getOptionValue(CliConstants.DEPLOYMENT_POLICY_DEPLOYMENT); + depPolicy = commandLine.getOptionValue(CliConstants.DEPLOYMENT_POLICY_OPTION); } if (commandLine.hasOption(CliConstants.REPO_URL_OPTION)) { if (logger.isTraceEnabled()) { http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df9d500f/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 8a48353..47894ad 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 @@ -178,7 +178,8 @@ public class CliConstants { public static final String RESOURCE_PATH = "p"; public static final String RESOURCE_PATH_LONG_OPTION = "resource-path"; - public static final int RESPONSE_INTERNAL_SERVER_ERROR = 500; - public static final int RESPONSE_AUTHORIZATION_FAIL = 403; - public static final int RESPONSE_NO_CONTENT = 204; + public static final String RESPONSE_INTERNAL_SERVER_ERROR = "500"; + public static final String RESPONSE_AUTHORIZATION_FAIL = "403"; + public static final String RESPONSE_NO_CONTENT = "204"; + public static final String RESPONSE_OK = "200"; }
