Repository: usergrid Updated Branches: refs/heads/hotfix-20160819 ef51f3d7b -> 5fdce93b7
Fix NPE when user doesn't exist after lookup from the unique value index. Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/5fdce93b Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/5fdce93b Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/5fdce93b Branch: refs/heads/hotfix-20160819 Commit: 5fdce93b72481ec55d491150d52b1f5feed4fade Parents: ef51f3d Author: Michael Russo <[email protected]> Authored: Wed Sep 7 17:23:10 2016 -0700 Committer: Michael Russo <[email protected]> Committed: Wed Sep 7 17:23:10 2016 -0700 ---------------------------------------------------------------------- .../apache/usergrid/services/users/UsersService.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/5fdce93b/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java ---------------------------------------------------------------------- diff --git a/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java b/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java index 0539695..7341743 100644 --- a/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java +++ b/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java @@ -79,16 +79,12 @@ public class UsersService extends AbstractCollectionService { @Override public ServiceResults getItemByName( ServiceContext context, String name ) throws Exception { - String nameProperty = Schema.getDefaultSchema().aliasProperty( getEntityType() ); - - if ( nameProperty == null ) { - nameProperty = "name"; - } - + EntityRef entity = null; Identifier id = Identifier.from( name ); if ( id != null ) { + // get the entityRef from the unique value index entity = em.getUserByIdentifier( id ); } @@ -97,7 +93,14 @@ public class UsersService extends AbstractCollectionService { } if ( !context.moreParameters() ) { + + // full load the entity from the database based on the UUID from the unique value index entity = em.get( entity ); + + if ( entity == null ) { + throw new ServiceResourceNotFoundException( context ); + } + entity = importEntity( context, ( Entity ) entity ); }
