You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2015/05/19 18:36:12 UTC
[1/2] stratos git commit: This closes #347 on GitHub
Repository: stratos
Updated Branches:
refs/heads/master bb5454456 -> 7f58cdbb5
This closes #347 on GitHub
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/7f58cdbb
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/7f58cdbb
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/7f58cdbb
Branch: refs/heads/master
Commit: 7f58cdbb5c5744adfd41b76daff0b59054692f0e
Parents: 0d0e1f1
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Tue May 19 22:06:07 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Tue May 19 22:06:07 2015 +0530
----------------------------------------------------------------------
----------------------------------------------------------------------
[2/2] stratos git commit: Display correct response message when
removing a non existing user
Posted by la...@apache.org.
Display correct response message when removing a non existing user
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/0d0e1f14
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/0d0e1f14
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/0d0e1f14
Branch: refs/heads/master
Commit: 0d0e1f144311ca23073d6e454b4d18f07ae6ef7f
Parents: bb54544
Author: Dinithi <di...@wso2.com>
Authored: Tue May 19 20:49:08 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Tue May 19 22:06:07 2015 +0530
----------------------------------------------------------------------
.../org/apache/stratos/cli/RestCommandLineService.java | 13 ++-----------
.../stratos/rest/endpoint/api/StratosApiV41.java | 13 +++++++++----
.../stratos/rest/endpoint/api/StratosApiV41Utils.java | 2 +-
3 files changed, 12 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/0d0e1f14/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 efc06d3..01bc45d 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
@@ -793,19 +793,10 @@ public class RestCommandLineService {
HttpResponse response = restClient.doDelete(httpClient, restClient.getBaseURL()
+ ENDPOINT_ADD_USER + "/" + userName);
- String responseCode = "" + response.getStatusLine().getStatusCode();
-
+ String resultString = CliUtils.getHttpResponseString(response);
GsonBuilder gsonBuilder = new GsonBuilder();
Gson gson = gsonBuilder.create();
-
- if (responseCode.equals(CliConstants.RESPONSE_NO_CONTENT) || responseCode.equals(CliConstants.RESPONSE_OK)) {
- System.out.println("You have successfully deleted user:" + userName);
- } else {
- String resultString = CliUtils.getHttpResponseString(response);
- ExceptionMapper exception = gson.fromJson(resultString, ExceptionMapper.class);
- System.out.println(exception);
- }
-
+ System.out.println(gson.fromJson(resultString, ResponseMessageBean.class).getMessage());
} catch (Exception e) {
String message = "Could not delete user: " + userName;
printError(message, e);
http://git-wip-us.apache.org/repos/asf/stratos/blob/0d0e1f14/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 6188995..ed46f17 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
@@ -1736,11 +1736,16 @@ public class StratosApiV41 extends AbstractApi {
@AuthorizationAction("/permission/admin/manage/removeUser")
public Response removeUser(
@PathParam("userName") String userName) throws RestAPIException {
+ try {
+ StratosApiV41Utils.removeUser(userName);
+ log.info("Successfully removed user: [username] " + userName);
+ return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
+ String.format("User deleted successfully: [user] %s", userName))).build();
+ } catch (RestAPIException e) {
+ return Response.status(Response.Status.BAD_REQUEST).entity(new ResponseMessageBean(
+ ResponseMessageBean.ERROR, e.getMessage())).build();
+ }
- StratosApiV41Utils.removeUser(userName);
- log.info("Successfully removed user: [username] " + userName);
- return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
- String.format("User deleted successfully: [user] %s", userName))).build();
}
/**
http://git-wip-us.apache.org/repos/asf/stratos/blob/0d0e1f14/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index 8304f98..d89ea35 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -3295,7 +3295,7 @@ public class StratosApiV41Utils {
} catch (UserManagerException e) {
String msg = "Error in removing user :" + userName;
log.error(msg, e);
- throw new RestAPIException(msg, e);
+ throw new RestAPIException(e.getMessage());
}
}