You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2016/10/24 13:06:36 UTC
[51/83] [abbrv] usergrid git commit: Fix NPE when user doesn't exist
after lookup from the unique value index.
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/asf-site
Commit: 5fdce93b72481ec55d491150d52b1f5feed4fade
Parents: ef51f3d
Author: Michael Russo <mr...@apigee.com>
Authored: Wed Sep 7 17:23:10 2016 -0700
Committer: Michael Russo <mr...@apigee.com>
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 );
}