You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/03/16 01:25:03 UTC

[08/11] incubator-usergrid git commit: [USERGRID-396] Everywhere that an alias is used, we now do the repair entity retrieval.

[USERGRID-396] Everywhere that an alias is used, we now do the repair entity retrieval.


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

Branch: refs/heads/two-dot-o
Commit: 4c0102e678d67e235d877654f60ec9947e08c160
Parents: a6929ab
Author: GERey <gr...@apigee.com>
Authored: Thu Mar 12 15:40:42 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Thu Mar 12 15:40:42 2015 -0700

----------------------------------------------------------------------
 .../services/AbstractCollectionService.java     | 24 +++++-------
 .../services/AbstractConnectionsService.java    | 39 +++++++-------------
 2 files changed, 22 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4c0102e6/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java b/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
index 26eb6b9..0820737 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
@@ -148,7 +148,7 @@ public class AbstractCollectionService extends AbstractService {
             nameProperty = "name";
         }
 
-        EntityRef entity = em.getAlias( getEntityType(), name );
+        Entity entity = em.getAllEntityFromFields( getEntityType(), name );
 
         if ( entity == null ) {
             logger.info( "miss on entityType: {} with name: {}", getEntityType(), name );
@@ -165,8 +165,7 @@ public class AbstractCollectionService extends AbstractService {
         }
 
         if ( !context.moreParameters() ) {
-            entity = em.get( entity );
-            entity = importEntity( context, ( Entity ) entity );
+            entity = importEntity( context, entity );
         }
 
         checkPermissionsForEntity( context, entity );
@@ -291,9 +290,9 @@ public class AbstractCollectionService extends AbstractService {
             return getItemByName( context, name );
         }
 
-        EntityRef ref = em.getAlias( getEntityType(), name );
-        Entity entity;
-        if ( ref == null ) {
+       // EntityRef ref = em.getAlias( getEntityType(), name );
+        Entity entity = em.getAllEntityFromFields( getEntityType(), name );
+        if ( entity == null ) {
             // null entity ref means we tried to put a non-existing entity
             // before we create a new entity for it, we should check for permission
             checkPermissionsForCollection(context);
@@ -305,7 +304,6 @@ public class AbstractCollectionService extends AbstractService {
             entity = em.create( getEntityType(), properties );
         }
         else {
-            entity = em.get( ref );
             entity = importEntity( context, entity );
             checkPermissionsForEntity( context, entity );
             updateEntity( context, entity );
@@ -437,12 +435,12 @@ public class AbstractCollectionService extends AbstractService {
             return super.postItemByName( context, name );
         }
 
-        EntityRef ref = em.getAlias( getEntityType(), name );
-        if ( ref == null ) {
+        Entity entity = em.getAllEntityFromFields( getEntityType(), name );
+        if ( entity == null ) {
             throw new ServiceResourceNotFoundException( context );
         }
 
-        return postItemById( context, ref.getUuid() );
+        return postItemById( context, entity.getUuid() );
     }
 
 
@@ -491,11 +489,7 @@ public class AbstractCollectionService extends AbstractService {
             return getItemByName( context, name );
         }
 
-        EntityRef ref = em.getAlias( getEntityType(), name );
-        if ( ref == null ) {
-            throw new ServiceResourceNotFoundException( context );
-        }
-        Entity entity = em.get( ref );
+        Entity entity = em.getAllEntityFromFields(getEntityType(), name );
         if ( entity == null ) {
             throw new ServiceResourceNotFoundException( context );
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4c0102e6/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java b/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
index 72be0a2..8a95e5c 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
@@ -172,13 +172,13 @@ public class AbstractConnectionsService extends AbstractService {
         Results r = null;
 
         if ( connecting() ) {
-            r = em.getConnectingEntities( 
-                new SimpleEntityRef( context.getOwner().getType(), context.getOwner().getUuid()), 
+            r = em.getConnectingEntities(
+                new SimpleEntityRef( context.getOwner().getType(), context.getOwner().getUuid()),
                 context.getCollectionName(), null, Level.ALL_PROPERTIES );
         }
         else {
-            r = em.getConnectedEntities( 
-                new SimpleEntityRef( context.getOwner().getType(), context.getOwner().getUuid()), 
+            r = em.getConnectedEntities(
+                new SimpleEntityRef( context.getOwner().getType(), context.getOwner().getUuid()),
                 context.getCollectionName(), null, Level.ALL_PROPERTIES );
         }
 
@@ -239,7 +239,7 @@ public class AbstractConnectionsService extends AbstractService {
             throw new ServiceResourceNotFoundException( context );
         }
 
-        if ( results.size() == 1 && !em.isConnectionMember( 
+        if ( results.size() == 1 && !em.isConnectionMember(
                 context.getOwner(), context.getCollectionName(), results.getEntity() ) ) {
             throw new ServiceResourceNotFoundException( context );
         }
@@ -263,14 +263,9 @@ public class AbstractConnectionsService extends AbstractService {
                 nameProperty = "name";
             }
 
-            EntityRef ref = em.getAlias( query.getEntityType(), name );
-            if ( ref == null ) {
-                return null;
-            }
-
             //TODO T.N. USERGRID-1919 actually validate this is connected
 
-            Entity entity = em.get( ref );
+            Entity entity = em.getAllEntityFromFields( query.getEntityType(),name );
             if ( entity == null ) {
                 return null;
             }
@@ -294,7 +289,7 @@ public class AbstractConnectionsService extends AbstractService {
         }
 
 //        query.setLimit( count );
-        // usergrid-2389: User defined limit in the query is ignored. Fixed it by following 
+        // usergrid-2389: User defined limit in the query is ignored. Fixed it by following
         // same style in AstractCollectionService
         query.setLimit( query.getLimit( count ) );
         query.setResultsLevel( level );
@@ -309,11 +304,11 @@ public class AbstractConnectionsService extends AbstractService {
             else {
 //            	r = em.getConnectingEntities( context.getOwner().getUuid(), query.getConnectionType(),
 //            			query.getEntityType(), level );
-                // usergrid-2389: User defined limit in the query is ignored. Fixed it by adding 
+                // usergrid-2389: User defined limit in the query is ignored. Fixed it by adding
                 // the limit to the method parameter downstream.
-            	r = em.getConnectingEntities( 
-                    new SimpleEntityRef( context.getOwner().getType(), context.getOwner().getUuid()), 
-                    query.getConnectionType(),query.getEntityType(), level , query.getLimit()); 
+            	r = em.getConnectingEntities(
+                    new SimpleEntityRef( context.getOwner().getType(), context.getOwner().getUuid()),
+                    query.getConnectionType(),query.getEntityType(), level , query.getLimit());
             }
         }
         else {
@@ -366,11 +361,7 @@ public class AbstractConnectionsService extends AbstractService {
             if ( query.containsSingleNameOrEmailIdentifier() ) {
                 String name = query.getSingleNameOrEmailIdentifier();
 
-                EntityRef ref = em.getAlias( query.getEntityType(), name );
-                if ( ref == null ) {
-                    throw new ServiceResourceNotFoundException( context );
-                }
-                entity = em.get( ref );
+                entity = em.getAllEntityFromFields( query.getEntityType(), name );
                 if ( entity == null ) {
                     throw new ServiceResourceNotFoundException( context );
                 }
@@ -481,11 +472,7 @@ public class AbstractConnectionsService extends AbstractService {
                 nameProperty = "name";
             }
 
-            EntityRef ref = em.getAlias( query.getEntityType(), name );
-            if ( ref == null ) {
-                throw new ServiceResourceNotFoundException( context );
-            }
-            Entity entity = em.get( ref );
+            Entity entity = em.getAllEntityFromFields( query.getEntityType(), name );
             if ( entity == null ) {
                 throw new ServiceResourceNotFoundException( context );
             }