Repository: stratos
Updated Branches:
  refs/heads/master 599235ca6 -> 798977a4f


Fixed following issues found in CLI commands.
1.) Printing API path
2.) Undeploying issues
3.) Print entity IDs in response messages


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

Branch: refs/heads/master
Commit: 19f1f196f1efe8757daf3e934e381336fcd548dd
Parents: 67e9f85
Author: Dinithi <[email protected]>
Authored: Fri Mar 6 11:14:19 2015 +0530
Committer: Dinithi <[email protected]>
Committed: Fri Mar 6 11:14:19 2015 +0530

----------------------------------------------------------------------
 .../java/org/apache/stratos/cli/RestClient.java | 17 ++++-----
 .../stratos/cli/RestCommandLineService.java     | 40 ++++++++------------
 2 files changed, 23 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/19f1f196/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 7f06495..f035072 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
@@ -169,14 +169,14 @@ public class RestClient implements GenericRestClient {
 
     public void undeployEntity(String serviceEndpoint, String entityName, 
String entityId) {
         try {
-            int responseCode = executeDelete(serviceEndpoint, entityId);
+            int responseCode = executeDelete(serviceEndpoint.replace("{id}", 
entityId));
             if (responseCode == 404) {
                 System.out.println(String.format("%s not found", 
StringUtils.capitalize(entityName)));
             } else if (responseCode >= 200 && responseCode <300) {
-                System.out.println(String.format("Successfully un-deployed 
%s", entityName));
+                System.out.println(String.format("Successfully un-deployed %s 
: %s", entityName,entityId));
             }
         } catch (Exception e) {
-            String message = String.format("Error in un-deploying %s", 
entityName);
+            String message = String.format("Error in un-deploying %s : %s", 
entityName,entityId);
             System.out.println(message);
             logger.error(message, e);
         }
@@ -199,11 +199,11 @@ public class RestClient implements GenericRestClient {
 
     public void deleteEntity(String serviceEndpoint, String identifier, String 
entityName) {
         try {
-            int responseCode = executeDelete(serviceEndpoint, identifier);
+            int responseCode = executeDelete(serviceEndpoint);
             if (responseCode == 404) {
                 System.out.println(String.format("%s not found", 
StringUtils.capitalize(entityName)));
             } else if (responseCode >= 200 && responseCode < 300) {
-                System.out.println(String.format("Successfully deleted %s", 
entityName));
+                System.out.println(String.format("Successfully deleted %s : 
%s", entityName,identifier));
             }
         } catch (Exception e) {
             String message = String.format("Error in deleting %s", entityName);
@@ -217,7 +217,7 @@ public class RestClient implements GenericRestClient {
         try {
             return executeGet(serviceEndpoint.replace(identifierPlaceHolder, 
identifier), responseJsonClass);
         } catch (Exception e) {
-            String message = String.format("Error in getting %s", entityName);
+            String message = String.format("Error in getting %s : %s", 
entityName,identifier);
             System.out.println(message);
             logger.error(message, e);
             return null;
@@ -228,7 +228,7 @@ public class RestClient implements GenericRestClient {
         try {
             return executeGet(serviceEndpoint.replace(identifierPlaceHolder, 
identifier), responseType);
         } catch (Exception e) {
-            String message = String.format("Error in getting %s", entityName);
+            String message = String.format("Error in getting %s : %s", 
entityName,identifier);
             System.out.println(message);
             logger.error(message, e);
             return null;
@@ -331,10 +331,9 @@ public class RestClient implements GenericRestClient {
         }
     }
 
-    private int executeDelete(String serviceEndpoint, String identifier) 
throws IOException {
+    private int executeDelete(String serviceEndpoint) throws IOException {
         DefaultHttpClient httpClient = new DefaultHttpClient();
         try {
-            System.out.println(getBaseURL() + serviceEndpoint.replace("{id}", 
identifier));
             HttpResponse response = doDelete(httpClient, getBaseURL() + 
serviceEndpoint);
 
             int responseCode = response.getStatusLine().getStatusCode();

http://git-wip-us.apache.org/repos/asf/stratos/blob/19f1f196/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 76676c4..2048f71 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
@@ -465,14 +465,14 @@ public class RestCommandLineService {
      * Add new tenant
      * @throws CommandException
      */
-    public void addTenant(String admin, String firstName, String lastaName, 
String password, String domain, String email)
+    public void addTenant(String admin, String firstName, String lastName, 
String password, String domain, String email)
             throws CommandException {
         DefaultHttpClient httpClient = new DefaultHttpClient();
         try {
             TenantInfoBean tenantInfo = new TenantInfoBean();
             tenantInfo.setAdmin(admin);
             tenantInfo.setFirstname(firstName);
-            tenantInfo.setLastname(lastaName);
+            tenantInfo.setLastname(lastName);
             tenantInfo.setAdminPassword(password);
             tenantInfo.setTenantDomain(domain);
             tenantInfo.setEmail(email);
@@ -488,11 +488,10 @@ public class RestCommandLineService {
             if (responseCode < 200 || responseCode >= 300) {
                 CliUtils.printError(response);
             } else {
-                System.out.println("Tenant added successfully");
-                return;
+                System.out.println("Tenant added successfully: " + domain);
             }
         } catch (Exception e) {
-            String message = "Could not add tenant";
+            String message = "Could not add tenant: " + domain;
             printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
@@ -608,7 +607,6 @@ public class RestCommandLineService {
                 CliUtils.printError(response);
             } else {
                 System.out.println("Tenant updated successfully: "+domain);
-                return;
             }
         } catch (Exception e) {
             String message = "Could not update tenant: "+domain;
@@ -647,11 +645,10 @@ public class RestCommandLineService {
             if (responseCode < 200 || responseCode >= 300) {
                 CliUtils.printError(response);
             } else {
-                System.out.println("User added successfully");
-                return;
+                System.out.println("User added successfully: " + userName);
             }
         } catch (Exception e) {
-            String message = "Could not add user";
+            String message = "Could not add user: " + userName;
             printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
@@ -688,7 +685,6 @@ public class RestCommandLineService {
                 CliUtils.printError(response);
             } else {
                 System.out.println("User updated successfully: "+userName);
-                return;
             }
         } catch (Exception e) {
             String message = "Could not update user: "+userName;
@@ -714,8 +710,7 @@ public class RestCommandLineService {
             Gson gson = gsonBuilder.create();
 
             if (responseCode.equals(CliConstants.RESPONSE_OK)) {
-                System.out.println("You have succesfully delete " + 
tenantDomain + " tenant");
-                return;
+                System.out.println("You have successfully deleted the tenant: 
" + tenantDomain);
             } else {
                 String resultString = CliUtils.getHttpResponseString(response);
                 ExceptionMapper exception = gson.fromJson(resultString, 
ExceptionMapper.class);
@@ -723,7 +718,7 @@ public class RestCommandLineService {
             }
 
         } catch (Exception e) {
-            String message = "Could not delete tenant";
+            String message = "Could not delete tenant: " + tenantDomain;
             printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
@@ -746,8 +741,7 @@ public class RestCommandLineService {
             Gson gson = gsonBuilder.create();
 
             if (responseCode.equals(CliConstants.RESPONSE_NO_CONTENT) || 
responseCode.equals(CliConstants.RESPONSE_OK)) {
-                System.out.println("You have successfully deleted " + userName 
+ " user");
-                return;
+                System.out.println("You have successfully deleted user:" + 
userName);
             } else {
                 String resultString = CliUtils.getHttpResponseString(response);
                 ExceptionMapper exception = gson.fromJson(resultString, 
ExceptionMapper.class);
@@ -755,7 +749,7 @@ public class RestCommandLineService {
             }
 
         } catch (Exception e) {
-            String message = "Could not delete user";
+            String message = "Could not delete user: " + userName;
             printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
@@ -778,7 +772,7 @@ public class RestCommandLineService {
             Gson gson = gsonBuilder.create();
 
             if (responseCode.equals(CliConstants.RESPONSE_OK)) {
-                System.out.println("You have successfully deactivated " + 
tenantDomain + " tenant");
+                System.out.println("You have successfully deactivated the 
tenant: " + tenantDomain );
                 return;
             } else {
                 String resultString = CliUtils.getHttpResponseString(response);
@@ -787,7 +781,7 @@ public class RestCommandLineService {
             }
 
         } catch (Exception e) {
-            String message = "Could not de-activate tenant";
+            String message = "Could not de-activate tenant: " + tenantDomain;
             printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
@@ -810,8 +804,7 @@ public class RestCommandLineService {
             Gson gson = gsonBuilder.create();
 
             if (responseCode.equals(CliConstants.RESPONSE_OK)) {
-                System.out.println("You have successfully activated " + 
tenantDomain + " tenant");
-                return;
+                System.out.println("You have successfully activated the 
tenant: " + tenantDomain);
             } else {
                 String resultString = CliUtils.getHttpResponseString(response);
                 ExceptionMapper exception = gson.fromJson(resultString, 
ExceptionMapper.class);
@@ -819,7 +812,7 @@ public class RestCommandLineService {
             }
 
         } catch (Exception e) {
-            String message = "Could not activate tenant";
+            String message = "Could not activate tenant: " + tenantDomain;
             printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
@@ -1095,7 +1088,6 @@ public class RestCommandLineService {
                 CliUtils.printTable(array, partitionMapper, "Group ID", 
"Description");
             } else {
                 System.out.println("No kubernetes clusters found");
-                return;
             }
         } catch (Exception e) {
             String message = "Could not list kubernetes clusters";
@@ -1328,7 +1320,6 @@ public class RestCommandLineService {
 
             if (responseCode.equals(CliConstants.RESPONSE_OK)) {
                 System.out.println(String.format("Synchronizing artifacts for 
cartridge subscription alias: %s", cartridgeAlias));
-                return;
             } else {
                 GsonBuilder gsonBuilder = new GsonBuilder();
                 Gson gson = gsonBuilder.create();
@@ -1416,7 +1407,6 @@ public class RestCommandLineService {
 
             if (Integer.parseInt(responseCode) < 300 && 
Integer.parseInt(responseCode) >= 200) {
                 System.out.println("You have successfully undeployed 
application: " + applicationId);
-                return;
             } else {
                 String resultString = CliUtils.getHttpResponseString(response);
                 ExceptionMapper exception = gson.fromJson(resultString, 
ExceptionMapper.class);
@@ -1424,7 +1414,7 @@ public class RestCommandLineService {
             }
 
         } catch (Exception e) {
-            String message = "Could not undeploy application";
+            String message = "Could not undeploy application: " + 
applicationId;
             printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();

Reply via email to