usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdun...@apache.org
Subject usergrid git commit: For GET /users/{id}, add new force query parameter to force user ID to be treated as a name (force=name) or email (force=email)
Date Tue, 23 Aug 2016 20:04:18 GMT
Repository: usergrid
Updated Branches:
  refs/heads/hotfix-20160819 ca49f1fde -> d2cdcd3f8


For GET /users/{id}, add new force query parameter to force user ID to be treated
as a name (force=name) or email (force=email)


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

Branch: refs/heads/hotfix-20160819
Commit: d2cdcd3f87f5676dca0d9cd43f788226a1c686ea
Parents: ca49f1f
Author: Mike Dunker <mdunker@apigee.com>
Authored: Tue Aug 23 13:02:43 2016 -0700
Committer: Mike Dunker <mdunker@apigee.com>
Committed: Tue Aug 23 13:02:43 2016 -0700

----------------------------------------------------------------------
 .../rest/applications/users/UsersResource.java        | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/d2cdcd3f/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
index 247df8a..68a0a69 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
@@ -88,7 +88,7 @@ public class UsersResource extends ServiceResource {
 
     @Override
     @Path("{itemName}")
-    public AbstractContextResource addNameParameter( @Context UriInfo ui, @PathParam("itemName")
PathSegment itemName )
+    public AbstractContextResource addNameParameter( @Context UriInfo ui, @PathParam("itemName")
PathSegment itemName)
             throws Exception {
 
         if(logger.isTraceEnabled()){
@@ -109,7 +109,17 @@ public class UsersResource extends ServiceResource {
         addParameter( getServiceParameters(), itemName.getPath() );
 
         addMatrixParams( getServiceParameters(), ui, itemName );
-        Identifier id = Identifier.from( itemName.getPath() );
+
+        String forceString = ui.getQueryParameters().getFirst("force");
+
+        Identifier id;
+        if (forceString != null && "email".equals(forceString.toLowerCase())) {
+            id = Identifier.fromEmail(itemName.getPath().toLowerCase());
+        } else if (forceString != null && "name".equals(forceString.toLowerCase()))
{
+            id = Identifier.fromName(itemName.getPath().toLowerCase());
+        } else {
+            id = Identifier.from(itemName.getPath());
+        }
         if ( id == null ) {
             throw new IllegalArgumentException( "Not a valid user identifier: " + itemName.getPath()
);
         }


Mime
View raw message