usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [11/12] incubator-usergrid git commit: Applied complains and refactored names to make the code clearer and checking for more null pointers. Removed redundant test.
Date Mon, 16 Mar 2015 23:35:54 GMT
Applied complains and refactored names to make the code clearer and checking for more null
pointers.
Removed redundant test.


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

Branch: refs/heads/USERGRID-466
Commit: b0a07baa354f790d820d1a32b435502ef5b062a9
Parents: 24a48a7
Author: GERey <greyes@apigee.com>
Authored: Fri Mar 13 15:23:15 2015 -0700
Committer: GERey <greyes@apigee.com>
Committed: Fri Mar 13 15:23:15 2015 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        | 10 ++-
 .../usergrid/persistence/EntityManager.java     |  5 +-
 .../cassandra/EntityManagerImpl.java            |  2 +-
 .../usergrid/persistence/EntityManagerIT.java   | 23 -------
 .../collection/EntityCollectionManager.java     | 10 +--
 .../cache/CachedEntityCollectionManager.java    | 17 +-----
 .../impl/EntityCollectionManagerImpl.java       | 15 +++--
 .../serialization/impl/FieldSetImpl.java        | 64 --------------------
 .../serialization/impl/MutableFieldSet.java     | 63 +++++++++++++++++++
 .../collection/EntityCollectionManagerIT.java   |  7 +--
 .../services/AbstractCollectionService.java     | 10 +--
 .../services/AbstractConnectionsService.java    |  6 +-
 12 files changed, 100 insertions(+), 132 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index a108f25..e5223f0 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -809,7 +809,7 @@ public class CpEntityManager implements EntityManager {
     }
 
     @Override
-    public Entity getAllEntityFromFields( String collectionType, String aliasType ){
+    public Entity getUniqueEntityFromAlias( String collectionType, String aliasType ){
         String collName = Schema.defaultCollectionName( collectionType );
 
         CollectionScope collectionScope = getCollectionScopeNameFromEntityType(
@@ -824,8 +824,13 @@ public class CpEntityManager implements EntityManager {
 
         StringField uniqueLookupRepairField =  new StringField( propertyName, aliasType.toString());
 
-        Observable<FieldSet> fieldSetObservable = ecm.getAllEntities( Arrays.<Field>asList(
uniqueLookupRepairField) );
+        Observable<FieldSet> fieldSetObservable = ecm.getEntitiesFromFields(
+            Arrays.<Field>asList( uniqueLookupRepairField ) );
 
+        if(fieldSetObservable == null){
+            logger.debug( "Couldn't return the observable based on unique entities." );
+            return null;
+        }
         FieldSet fieldSet = fieldSetObservable.toBlocking().last();
 
         repairedEntityGet.stop();
@@ -2284,7 +2289,6 @@ public class CpEntityManager implements EntityManager {
             getApplicationScope().getApplication(), collectionName);
 
         final EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope
);
-//TODO: can't we just sub in the getEntityRepair method here so for every read of a uniqueEntityField
we can verify it is correct?
 
         //convert to a string, that's what we store
         final Id results = ecm.getIdField( new StringField(

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
index 5657d4f..65fac8d 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
@@ -713,6 +713,5 @@ public interface EntityManager {
      */
     public Health getIndexHealth();
 
-    public Entity getAllEntityFromFields( String aliasType, String aliasValue );
-
-    }
+    public Entity getUniqueEntityFromAlias( String aliasType, String aliasValue );
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index 3993285..e505b8e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@ -2949,7 +2949,7 @@ public class EntityManagerImpl implements EntityManager {
 
 
     @Override
-    public Entity getAllEntityFromFields( final String aliasType, final String aliasValue
) {
+    public Entity getUniqueEntityFromAlias( final String aliasType, final String aliasValue
) {
         throw new UnsupportedOperationException( "Not supported." );
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
index cd08607..4896fc1 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
@@ -579,27 +579,4 @@ public class EntityManagerIT extends AbstractCoreIT {
 
         assertNotNull( em.get( user.getUuid() ));
     }
-
-    @Test
-    public void testInvalidNameRepair() throws Exception {
-        LOG.info("EntityManagerIT.testInvalidNameReapir");
-
-        EntityManager em = app.getEntityManager();
-
-        Map<String, Object> properties = new LinkedHashMap<String, Object>();
-        properties.put( "name", "XR-51B" );
-        properties.put( "fuel", "Nutrinox" );
-
-        Entity user = em.create( "robot", properties );
-        assertNotNull( user );
-
-        em.refreshIndex();
-
-        assertNotNull( em.get( user.getUuid() ));
-
-        em.delete( user );
-
-        assertNull( em.get( user.getUuid() ));
-
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
index 6bbe912..35fc5d4 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
@@ -54,9 +54,9 @@ public interface EntityCollectionManager {
      * Return the latest versions of the specified entityIds
      */
     public Observable<VersionSet> getLatestVersion( Collection<Id> entityId );
-    
-    
-    public Observable<FieldSet> getAllEntities(Collection<Field> fields);
+
+
+    public Observable<FieldSet> getEntitiesFromFields( Collection<Field> fields
);
 
     /**
      * Gets the Id for a field
@@ -77,12 +77,12 @@ public interface EntityCollectionManager {
 
     /**
      * Takes the change and reloads an entity with all changes applied in this entity applied.
-     * The resulting entity from calling load will be the previous version of this entity
plus 
+     * The resulting entity from calling load will be the previous version of this entity
plus
      * the entity in this object applied to it.
      */
     public Observable<Entity> update ( Entity entity );
 
-    /** 
+    /**
      * Returns health of entity data store.
      */
     public Health getHealth();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
index d33f762..7d229e6 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
@@ -20,19 +20,10 @@
 package org.apache.usergrid.persistence.collection.cache;
 
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 
-import com.netflix.astyanax.MutationBatch;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
 import org.apache.usergrid.persistence.collection.*;
-import org.apache.usergrid.persistence.collection.serialization.UniqueValue;
-import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet;
-import org.apache.usergrid.persistence.collection.serialization.impl.FieldSetImpl;
 import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
@@ -40,15 +31,11 @@ import org.apache.usergrid.persistence.model.field.Field;
 
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import rx.Observable;
 import rx.functions.Action1;
-import rx.functions.Func1;
 
 
 @Singleton
@@ -83,8 +70,8 @@ public class CachedEntityCollectionManager implements EntityCollectionManager
{
     }
 
     @Override
-    public Observable<FieldSet> getAllEntities(final Collection<Field> fields)
{
-        return targetEntityCollectionManager.getAllEntities( fields );
+    public Observable<FieldSet> getEntitiesFromFields( final Collection<Field>
fields ) {
+        return targetEntityCollectionManager.getEntitiesFromFields( fields );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
index 7db34aa..3c89280 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
@@ -23,8 +23,8 @@ import java.util.*;
 
 import com.netflix.astyanax.MutationBatch;
 import org.apache.usergrid.persistence.collection.*;
-import org.apache.usergrid.persistence.collection.serialization.impl.FieldSetImpl;
-import org.apache.usergrid.persistence.core.rx.ObservableIterator;
+import org.apache.usergrid.persistence.collection.serialization.impl.MutableFieldSet;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,7 +41,6 @@ import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteCommit;
 import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteOptimisticVerify;
 import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteStart;
 import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteUniqueVerify;
-import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValue;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet;
@@ -294,7 +293,7 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager
{
      * @return
      */
     @Override
-    public Observable<FieldSet> getAllEntities(final Collection<Field> fields)
{
+    public Observable<FieldSet> getEntitiesFromFields( final Collection<Field>
fields ) {
         return rx.Observable.just(fields).map( new Func1<Collection<Field>, FieldSet>()
{
             @Override
             public FieldSet call( Collection<Field> fields ) {
@@ -307,7 +306,7 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager
{
 
                     //Short circut if we don't have any uniqueValues from the given fields.
                     if(!set.iterator().hasNext()){
-                        return new FieldSetImpl( 0 );
+                        return new MutableFieldSet( 0 );
                     }
 
 
@@ -319,6 +318,10 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager
{
 
                         UniqueValue value = set.getValue(expectedField.getName());
 
+                        if(value ==null){
+                            logger.debug( "Field does not correspond to a unique value" );
+                        }
+
                         entityIds.add(value.getEntityId());
                         uniqueValues.add(value);
                     }
@@ -329,7 +332,7 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager
{
                     //now loop through and ensure the entities are there.
                     final MutationBatch deleteBatch = keyspace.prepareMutationBatch();
 
-                    final FieldSetImpl response = new FieldSetImpl(fields.size());
+                    final MutableFieldSet response = new MutableFieldSet(fields.size());
 
                     for(final UniqueValue expectedUnique: uniqueValues) {
                         final MvccEntity entity = entitySet.getEntity(expectedUnique.getEntityId());

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/FieldSetImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/FieldSetImpl.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/FieldSetImpl.java
deleted file mode 100644
index 241d5c2..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/FieldSetImpl.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.apache.usergrid.persistence.collection.serialization.impl;/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-import org.apache.usergrid.persistence.collection.FieldSet;
-import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.model.field.Field;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-public class FieldSetImpl implements FieldSet {
-
-
-    private final Map<Field<?>, MvccEntity> entities;
-
-
-    public FieldSetImpl(
-            final int expectedSize) {
-        this.entities = new HashMap<>( expectedSize );
-    }
-
-
-    public void addEntity(final Field<?> field,  final MvccEntity entity ) {
-        entities.put( field, entity );
-    }
-
-
-    @Override
-    public MvccEntity getEntity( final Field<?> field) {
-        return entities.get( field );
-    }
-
-
-
-
-    @Override
-    public int size() {
-        return entities.size();
-    }
-
-
-    @Override
-    public boolean isEmpty() {
-        return entities.size() == 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MutableFieldSet.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MutableFieldSet.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MutableFieldSet.java
new file mode 100644
index 0000000..ae921a7
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MutableFieldSet.java
@@ -0,0 +1,63 @@
+package org.apache.usergrid.persistence.collection.serialization.impl;/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import org.apache.usergrid.persistence.collection.FieldSet;
+import org.apache.usergrid.persistence.collection.MvccEntity;
+import org.apache.usergrid.persistence.model.field.Field;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class MutableFieldSet implements FieldSet {
+
+
+    private final Map<Field<?>, MvccEntity> entities;
+
+
+    public MutableFieldSet( final int expectedSize ) {
+        this.entities = new HashMap<>( expectedSize );
+    }
+
+
+    public void addEntity(final Field<?> field,  final MvccEntity entity ) {
+        entities.put( field, entity );
+    }
+
+
+    @Override
+    public MvccEntity getEntity( final Field<?> field) {
+        return entities.get( field );
+    }
+
+
+
+
+    @Override
+    public int size() {
+        return entities.size();
+    }
+
+
+    @Override
+    public boolean isEmpty() {
+        return entities.size() == 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
index 46e844d..a52486e 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
@@ -20,7 +20,6 @@ package org.apache.usergrid.persistence.collection;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import java.util.UUID;
 
@@ -780,12 +779,12 @@ public class EntityCollectionManagerIT {
 
         Entity createReturned = observable.toBlocking().lastOrDefault( null );
 
-
+        assertNotNull( "Need entity to be created before proceeding", createReturned );
         assertNotNull( "Id was assigned", createReturned.getId() );
         assertNotNull( "Version was assigned", createReturned.getVersion() );
 
         FieldSet
-            fieldResults = manager.getAllEntities( Arrays.<Field>asList( expectedInteger)
).toBlocking().last();
+            fieldResults = manager.getEntitiesFromFields( Arrays.<Field>asList( expectedInteger
) ).toBlocking().last();
 
         assertEquals(1,fieldResults.size());
 
@@ -800,7 +799,7 @@ public class EntityCollectionManagerIT {
 
         //try to load via the unique field, should have triggered repair
         final FieldSet
-            results = manager.getAllEntities( Arrays.<Field>asList( expectedInteger)
).toBlocking().last();
+            results = manager.getEntitiesFromFields( Arrays.<Field>asList( expectedInteger
) ).toBlocking().last();
 
 
         //verify no entity returned

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/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 e404321..dcd7557 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
@@ -72,7 +72,7 @@ public class AbstractCollectionService extends AbstractService {
             nameProperty = "name";
         }
 
-        Entity entity = em.getAllEntityFromFields( getEntityType(), name );
+        Entity entity = em.getUniqueEntityFromAlias( getEntityType(), name );
         if ( entity != null ) {
             entity = importEntity( request, entity );
         }
@@ -144,7 +144,7 @@ public class AbstractCollectionService extends AbstractService {
             nameProperty = "name";
         }
 
-        Entity entity = em.getAllEntityFromFields( getEntityType(), name );
+        Entity entity = em.getUniqueEntityFromAlias( getEntityType(), name );
 
         if ( entity == null ) {
             logger.info( "miss on entityType: {} with name: {}", getEntityType(), name );
@@ -287,7 +287,7 @@ public class AbstractCollectionService extends AbstractService {
         }
 
        // EntityRef ref = em.getAlias( getEntityType(), name );
-        Entity entity = em.getAllEntityFromFields( getEntityType(), name );
+        Entity entity = em.getUniqueEntityFromAlias( 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
@@ -431,7 +431,7 @@ public class AbstractCollectionService extends AbstractService {
             return super.postItemByName( context, name );
         }
 
-        Entity entity = em.getAllEntityFromFields( getEntityType(), name );
+        Entity entity = em.getUniqueEntityFromAlias( getEntityType(), name );
         if ( entity == null ) {
             throw new ServiceResourceNotFoundException( context );
         }
@@ -485,7 +485,7 @@ public class AbstractCollectionService extends AbstractService {
             return getItemByName( context, name );
         }
 
-        Entity entity = em.getAllEntityFromFields(getEntityType(), name );
+        Entity entity = em.getUniqueEntityFromAlias( getEntityType(), name );
         if ( entity == null ) {
             throw new ServiceResourceNotFoundException( context );
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0a07baa/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 8a95e5c..1e4c4b8 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
@@ -265,7 +265,7 @@ public class AbstractConnectionsService extends AbstractService {
 
             //TODO T.N. USERGRID-1919 actually validate this is connected
 
-            Entity entity = em.getAllEntityFromFields( query.getEntityType(),name );
+            Entity entity = em.getUniqueEntityFromAlias( query.getEntityType(), name );
             if ( entity == null ) {
                 return null;
             }
@@ -361,7 +361,7 @@ public class AbstractConnectionsService extends AbstractService {
             if ( query.containsSingleNameOrEmailIdentifier() ) {
                 String name = query.getSingleNameOrEmailIdentifier();
 
-                entity = em.getAllEntityFromFields( query.getEntityType(), name );
+                entity = em.getUniqueEntityFromAlias( query.getEntityType(), name );
                 if ( entity == null ) {
                     throw new ServiceResourceNotFoundException( context );
                 }
@@ -472,7 +472,7 @@ public class AbstractConnectionsService extends AbstractService {
                 nameProperty = "name";
             }
 
-            Entity entity = em.getAllEntityFromFields( query.getEntityType(), name );
+            Entity entity = em.getUniqueEntityFromAlias( query.getEntityType(), name );
             if ( entity == null ) {
                 throw new ServiceResourceNotFoundException( context );
             }


Mime
View raw message