You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/05/18 16:01:17 UTC
[2/2] stratos git commit: Fix issues found when removing non existing
deployment policies and network partitions
Fix issues found when removing non existing deployment policies and network partitions
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b7cd4b1a
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b7cd4b1a
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b7cd4b1a
Branch: refs/heads/master
Commit: b7cd4b1af24cc6b7f2038bbaf3c83d1351fa67df
Parents: 506f993
Author: Dinithi <di...@wso2.com>
Authored: Mon May 18 19:27:59 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Mon May 18 19:30:58 2015 +0530
----------------------------------------------------------------------
.../java/org/apache/stratos/cli/RestClient.java | 32 ++++++--------------
.../rest/endpoint/api/StratosApiV41.java | 14 ++++-----
2 files changed, 16 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/b7cd4b1a/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 faf8bd6..53cc1d2 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
@@ -20,7 +20,6 @@ package org.apache.stratos.cli;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
@@ -178,14 +177,8 @@ public class RestClient implements GenericRestClient {
public void undeployEntity(String serviceEndpoint, String entityName, String entityId) {
try {
- int responseCode = executeDelete(serviceEndpoint.replace("{id}", entityId));
- if (responseCode == 404) {
- System.out.println(String.format("%s not found", StringUtils.capitalize(entityName)));
- } else if (responseCode == 500) {
- System.out.println("Internal server error occurred");
- } else if (responseCode >= 200 && responseCode < 300) {
- System.out.println(String.format("Successfully un-deployed %s : %s", entityName, entityId));
- }
+ String responseMessage = executeDelete(serviceEndpoint.replace("{id}", entityId));
+ System.out.println(responseMessage);
} catch (Exception e) {
String message = String.format("Error in un-deploying %s : %s", entityName, entityId);
System.out.println(message);
@@ -206,14 +199,8 @@ public class RestClient implements GenericRestClient {
public void deleteEntity(String serviceEndpoint, String identifier, String entityName) {
try {
- int responseCode = executeDelete(serviceEndpoint);
- if (responseCode == 404) {
- System.out.println(String.format("%s not found", StringUtils.capitalize(entityName)));
- } else if (responseCode == 500) {
- System.out.println("Internal server error occurred");
- } else if (responseCode >= 200 && responseCode < 300) {
- System.out.println(String.format("Successfully deleted %s : %s", entityName, identifier));
- }
+ String responseMessage = executeDelete(serviceEndpoint);
+ System.out.println(responseMessage);
} catch (Exception e) {
String message = String.format("Error in deleting %s", entityName);
System.out.println(message);
@@ -339,16 +326,15 @@ public class RestClient implements GenericRestClient {
}
}
- private int executeDelete(String serviceEndpoint) throws IOException {
+ private String executeDelete(String serviceEndpoint) throws IOException {
DefaultHttpClient httpClient = new DefaultHttpClient();
try {
HttpResponse response = doDelete(httpClient, getBaseURL() + serviceEndpoint);
+ String result = getHttpResponseString(response);
- int responseCode = response.getStatusLine().getStatusCode();
- if (responseCode < 200 || responseCode >= 300) {
- CliUtils.printError(response);
- }
- return responseCode;
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ Gson gson = gsonBuilder.create();
+ return gson.fromJson(result, ResponseMessageBean.class).getMessage();
} finally {
httpClient.getConnectionManager().shutdown();
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b7cd4b1a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index 9aa060f..54340ca 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -260,28 +260,28 @@ public class StratosApiV41 extends AbstractApi {
/**
* Updates the Deployment Policy Definition.
*
- * @param deploymentPolicyID the deployment policy id
+ * @param deploymentPolicyId the deployment policy id
* @return 200 if deployment policy is successfully removed
* @throws RestAPIException the rest api exception
*/
@DELETE
- @Path("/deploymentPolicies/{depolymentPolicyID}")
+ @Path("/deploymentPolicies/{deploymentPolicyId}")
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/admin/manage/removeDeploymentPolicy")
public Response removeDeploymentPolicy(
- @PathParam("depolymentPolicyID") String deploymentPolicyID) throws RestAPIException {
+ @PathParam("deploymentPolicyId") String deploymentPolicyId) throws RestAPIException {
try {
- StratosApiV41Utils.removeDeploymentPolicy(deploymentPolicyID);
+ StratosApiV41Utils.removeDeploymentPolicy(deploymentPolicyId);
} catch (AutoscalerServiceDeploymentPolicyNotExistsExceptionException e) {
return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean(
- ResponseMessageBean.ERROR, "Autoscaling policy not found")).build();
+ ResponseMessageBean.ERROR, "Deployment policy not found")).build();
}
- URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
+ URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyId).build();
return Response.ok(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
String.format("Deployment policy removed successfully: " + "[deployment-policy-id] %s",
- deploymentPolicyID))).build();
+ deploymentPolicyId))).build();
}
/**