Fixed UsergridClient.logoutUser to set the current user to null if the user logging out is the current user.
Also the CRUD methods that take in a map now use Map<String,?> for ease of use. Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/960ada28 Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/960ada28 Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/960ada28 Branch: refs/heads/master Commit: 960ada28676d652966a9e652b975f453f49a4de9 Parents: 5aacc34 Author: Robert Walsh <rjwalsh1...@gmail.com> Authored: Thu Apr 14 13:49:12 2016 -0500 Committer: Robert Walsh <rjwalsh1...@gmail.com> Committed: Thu Apr 14 13:49:12 2016 -0500 ---------------------------------------------------------------------- .../apache/usergrid/java/client/Usergrid.java | 10 +++++----- .../usergrid/java/client/UsergridClient.java | 21 +++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/960ada28/sdks/java/src/main/java/org/apache/usergrid/java/client/Usergrid.java ---------------------------------------------------------------------- diff --git a/sdks/java/src/main/java/org/apache/usergrid/java/client/Usergrid.java b/sdks/java/src/main/java/org/apache/usergrid/java/client/Usergrid.java index 69be358..f7cd545 100644 --- a/sdks/java/src/main/java/org/apache/usergrid/java/client/Usergrid.java +++ b/sdks/java/src/main/java/org/apache/usergrid/java/client/Usergrid.java @@ -174,12 +174,12 @@ public final class Usergrid { } @NotNull - public static UsergridResponse PUT(@NotNull final String type, @NotNull final String uuidOrName, @NotNull final Map<String, Object> jsonBody) { + public static UsergridResponse PUT(@NotNull final String type, @NotNull final String uuidOrName, @NotNull final Map<String, ?> jsonBody) { return Usergrid.getInstance().PUT(type, uuidOrName, jsonBody); } @NotNull - public static UsergridResponse PUT(@NotNull final String type, @NotNull final Map<String, Object> jsonBody) { + public static UsergridResponse PUT(@NotNull final String type, @NotNull final Map<String, ?> jsonBody) { return Usergrid.getInstance().PUT(type, jsonBody); } @@ -189,7 +189,7 @@ public final class Usergrid { } @NotNull - public static UsergridResponse PUT(@NotNull final UsergridQuery query, @NotNull final Map<String, Object> jsonBody) { + public static UsergridResponse PUT(@NotNull final UsergridQuery query, @NotNull final Map<String, ?> jsonBody) { return Usergrid.getInstance().PUT(query, jsonBody); } @@ -199,12 +199,12 @@ public final class Usergrid { } @NotNull - public static UsergridResponse POST(@NotNull final String type, @NotNull final Map<String, Object> jsonBody) { + public static UsergridResponse POST(@NotNull final String type, @NotNull final Map<String, ?> jsonBody) { return Usergrid.getInstance().POST(type, jsonBody); } @NotNull - public static UsergridResponse POST(@NotNull final String type, @NotNull final List<Map<String, Object>> jsonBodies) { + public static UsergridResponse POST(@NotNull final String type, @NotNull final List<Map<String, ?>> jsonBodies) { return Usergrid.getInstance().POST(type, jsonBodies); } http://git-wip-us.apache.org/repos/asf/usergrid/blob/960ada28/sdks/java/src/main/java/org/apache/usergrid/java/client/UsergridClient.java ---------------------------------------------------------------------- diff --git a/sdks/java/src/main/java/org/apache/usergrid/java/client/UsergridClient.java b/sdks/java/src/main/java/org/apache/usergrid/java/client/UsergridClient.java index 396c8f6..87a84ae 100644 --- a/sdks/java/src/main/java/org/apache/usergrid/java/client/UsergridClient.java +++ b/sdks/java/src/main/java/org/apache/usergrid/java/client/UsergridClient.java @@ -198,7 +198,14 @@ public class UsergridClient { pathSegments[len-1] = "revoketokens"; } UsergridRequest request = new UsergridRequest(UsergridHttpMethod.PUT, UsergridRequest.APPLICATION_JSON_MEDIA_TYPE, this.clientAppUrl(), param, null, this.authForRequests() , pathSegments); - return this.sendRequest(request); + UsergridResponse response = this.sendRequest(request); + UsergridUser currentUser = this.getCurrentUser(); + if( currentUser != null && response.ok() ) { + if( uuidOrUsername.equalsIgnoreCase(currentUser.uuidOrUsername()) ) { + this.setCurrentUser(null); + } + } + return response; } @NotNull @@ -231,14 +238,14 @@ public class UsergridClient { } @NotNull - public UsergridResponse PUT(@NotNull final String type, @NotNull final String uuidOrName, @NotNull final Map<String, Object> jsonBody) { + public UsergridResponse PUT(@NotNull final String type, @NotNull final String uuidOrName, @NotNull final Map<String, ?> jsonBody) { String[] pathSegments = { type, uuidOrName }; UsergridRequest request = new UsergridRequest(UsergridHttpMethod.PUT, UsergridRequest.APPLICATION_JSON_MEDIA_TYPE, this.clientAppUrl(), null, jsonBody, this.authForRequests() , pathSegments); return this.sendRequest(request); } @NotNull - public UsergridResponse PUT(@NotNull final String type, @NotNull final Map<String, Object> jsonBody) { + public UsergridResponse PUT(@NotNull final String type, @NotNull final Map<String, ?> jsonBody) { String uuidOrName = null; Object uuid = jsonBody.get(UsergridEntityProperties.UUID.toString()); if( uuid != null ) { @@ -269,7 +276,7 @@ public class UsergridClient { } @NotNull - public UsergridResponse PUT(@NotNull final UsergridQuery query, @NotNull final Map<String, Object> jsonBody) { + public UsergridResponse PUT(@NotNull final UsergridQuery query, @NotNull final Map<String, ?> jsonBody) { String collectionName = query.getCollection(); if( collectionName == null ) { return UsergridResponse.fromError(this, "Query collection name missing.", "Query collection name is missing."); @@ -296,20 +303,20 @@ public class UsergridClient { } @NotNull - public UsergridResponse POST(@NotNull final String type, @NotNull final String uuidOrName, @NotNull final Map<String, Object> jsonBody) { + public UsergridResponse POST(@NotNull final String type, @NotNull final String uuidOrName, @NotNull final Map<String, ?> jsonBody) { String[] pathSegments = {type, uuidOrName}; UsergridRequest request = new UsergridRequest(UsergridHttpMethod.POST, UsergridRequest.APPLICATION_JSON_MEDIA_TYPE, this.clientAppUrl(), null, jsonBody, this.authForRequests() , pathSegments); return this.sendRequest(request); } @NotNull - public UsergridResponse POST(@NotNull final String type, @NotNull final Map<String, Object> jsonBody) { + public UsergridResponse POST(@NotNull final String type, @NotNull final Map<String, ?> jsonBody) { UsergridRequest request = new UsergridRequest(UsergridHttpMethod.POST, UsergridRequest.APPLICATION_JSON_MEDIA_TYPE, this.clientAppUrl(), null, jsonBody, this.authForRequests() , type); return this.sendRequest(request); } @NotNull - public UsergridResponse POST(@NotNull final String type, @NotNull final List<Map<String, Object>> jsonBodies) { + public UsergridResponse POST(@NotNull final String type, @NotNull final List<Map<String, ?>> jsonBodies) { UsergridRequest request = new UsergridRequest(UsergridHttpMethod.POST, UsergridRequest.APPLICATION_JSON_MEDIA_TYPE, this.clientAppUrl(), null, jsonBodies, this.authForRequests() , type); return this.sendRequest(request); }