usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [3/3] incubator-usergrid git commit: compiling
Date Fri, 20 Mar 2015 01:00:13 GMT
compiling


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

Branch: refs/heads/USERGRID-480
Commit: d6bcf4bf3c31e8b06af175302f7795674579fc31
Parents: 1dd6ead
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Thu Mar 19 19:00:00 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Thu Mar 19 19:00:00 2015 -0600

----------------------------------------------------------------------
 .../batch/service/SchedulerServiceImpl.java     |  17 +++-
 .../corepersistence/CpEntityManager.java        |   7 --
 .../corepersistence/CpEntityManagerFactory.java |   8 +-
 .../usergrid/persistence/EntityManager.java     |   6 --
 .../persistence/EntityManagerFactory.java       |   2 -
 .../cassandra/EntityManagerFactoryImpl.java     |   5 -
 .../cassandra/EntityManagerImpl.java            |   5 -
 .../org/apache/usergrid/CoreApplication.java    |  11 +-
 .../java/org/apache/usergrid/CoreITSetup.java   |   6 ++
 .../org/apache/usergrid/CoreITSetupImpl.java    |  14 +++
 .../corepersistence/StaleIndexCleanupTest.java  |  26 ++---
 .../usergrid/persistence/CollectionIT.java      |  72 ++++++-------
 .../usergrid/persistence/CountingMutatorIT.java |   4 +-
 .../persistence/EntityConnectionsIT.java        |  14 +--
 .../usergrid/persistence/EntityManagerIT.java   |  16 +--
 .../org/apache/usergrid/persistence/GeoIT.java  |  26 ++---
 .../persistence/GeoQueryBooleanTest.java        |   4 +-
 .../apache/usergrid/persistence/IndexIT.java    |  14 +--
 .../usergrid/persistence/PathQueryIT.java       |   6 +-
 .../PerformanceEntityRebuildIndexTest.java      |  12 +--
 .../usergrid/persistence/PermissionsIT.java     |   4 +-
 .../cassandra/EntityManagerFactoryImplIT.java   |   4 +-
 .../persistence/query/CollectionIoHelper.java   |   2 +-
 .../persistence/query/ConnectionHelper.java     |   2 +-
 .../persistence/query/IteratingQueryIT.java     |   6 +-
 .../impl/EsApplicationEntityIndexImpl.java      |   2 +-
 .../index/impl/EsEntityIndexImpl.java           |   3 +-
 .../usergrid/rest/AbstractContextResource.java  | 102 +++++++++++--------
 .../org/apache/usergrid/rest/IndexResource.java |   2 +-
 .../rest/test/RefreshIndexResource.java         |  17 ++--
 .../org/apache/usergrid/ServiceApplication.java |  18 ++--
 .../apache/usergrid/management/EmailFlowIT.java |   6 +-
 .../usergrid/management/OrganizationIT.java     |  10 +-
 .../org/apache/usergrid/management/RoleIT.java  |   4 +-
 .../cassandra/ManagementServiceIT.java          |  22 ++--
 .../management/export/ExportServiceIT.java      |  12 +--
 .../management/importer/ImportCollectionIT.java |  15 +--
 .../usergrid/services/ConnectionsServiceIT.java |  10 +-
 .../usergrid/services/GroupServiceIT.java       |   6 +-
 .../usergrid/services/RolesServiceIT.java       |   2 +-
 .../usergrid/services/UsersServiceIT.java       |   2 +-
 .../AbstractServiceNotificationIT.java          |   2 +-
 .../apns/NotificationsServiceIT.java            |  40 ++++----
 .../gcm/NotificationsServiceIT.java             |   4 +-
 44 files changed, 300 insertions(+), 272 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
index 3547ee6..6e6564e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.UUID;
 
 
+import com.google.inject.Injector;
 import org.apache.usergrid.batch.JobExecution;
 import org.apache.usergrid.batch.JobExecution.Status;
 import org.apache.usergrid.batch.JobRuntime;
@@ -35,6 +36,7 @@ import org.apache.usergrid.mq.QueueQuery;
 import org.apache.usergrid.mq.QueueResults;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.index.EntityIndex;
 import org.apache.usergrid.persistence.index.query.Query;
 import org.apache.usergrid.persistence.Results;
 import org.apache.usergrid.persistence.Schema;
@@ -49,7 +51,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.Assert;
 
 /**
- * Should be referenced by services as a SchedulerService instance. Only the internal job 
+ * Should be referenced by services as a SchedulerService instance. Only the internal job
  * runtime should refer to this as a JobAccessor
  */
 public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobRuntimeService {
@@ -74,6 +76,8 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
 
     /** Timeout for how long to set the transaction timeout from the queue. Default is 30000 */
     private long jobTimeout = 30000;
+    private Injector injector;
+    private EntityIndex entityIndex;
 
 
     /**
@@ -141,7 +145,7 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
          */
         try {
             LOG.debug( "deleteJob {}", jobId );
-            getEm().delete( new SimpleEntityRef( 
+            getEm().delete( new SimpleEntityRef(
                 Schema.getDefaultSchema().getEntityType(JobData.class), jobId ) );
         }
         catch ( Exception e ) {
@@ -319,7 +323,7 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
 
         String jobDataType = Schema.getDefaultSchema().getEntityType(JobData.class);
 
-        return getEm().searchCollection( getEm().getApplicationRef(), 
+        return getEm().searchCollection( getEm().getApplicationRef(),
                 Schema.defaultCollectionName(jobDataType), query );
     }
 
@@ -400,6 +404,10 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
         this.emf = emf;
     }
 
+    /** @param injector **/
+    @Autowired
+    public void setInjector( Injector injector){ this.injector = injector;}
+
 
     /** @param jobQueueName the jobQueueName to set */
     public void setJobQueueName( String jobQueueName ) {
@@ -428,6 +436,7 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
 
     @Override
     public void refreshIndex() {
-        getEm().refreshIndex();
+        this.entityIndex = entityIndex == null ? injector.getInstance(EntityIndex.class) : entityIndex;
+        entityIndex.refresh();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/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 64f0257..e33bb22 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
@@ -2884,13 +2884,6 @@ public class CpEntityManager implements EntityManager {
     }
 
 
-    @Override
-    public void refreshIndex() {
-
-        // refresh factory indexes
-        emf.refreshIndex();
-    }
-
 
     @Override
     public void flushManagerCaches() {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 134886f..c77f6ed 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -309,7 +309,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         catch ( DuplicateUniquePropertyExistsException e ) {
             throw new ApplicationAlreadyExistsException( appName );
         }
-        em.refreshIndex();
+        entityIndex.refresh();
 
         // create application entity
         if ( properties == null ) {
@@ -320,7 +320,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
         appEm.create(applicationId, TYPE_APPLICATION, properties);
         appEm.resetRoles();
-        appEm.refreshIndex();
+        entityIndex.refresh();
 
         logger.info("Initialized application {}", appName );
 
@@ -358,7 +358,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
             em.delete(appToDelete);
 
         }
-        em.refreshIndex();
+        entityIndex.refresh();
     }
 
 
@@ -383,7 +383,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         appProps.put("type", "appinfo");
         Entity restoredApp = em.create("appinfo", appToRestore.getProperties());
 
-        em.refreshIndex();
+        entityIndex.refresh();
 
         // rebuild the apps index
         this.rebuildApplicationIndexes(applicationId, new ProgressObserver() {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/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 89a5384..7108472 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
@@ -685,12 +685,6 @@ public interface EntityManager {
     /** @return the cass */
     CassandraService getCass();
 
-    /**
-     * Refresh the applications index -- use sparingly.
-     */
-    void refreshIndex();
-
-
     public void init( EntityManagerFactory emf, EntityIndex entityIndex, UUID applicationId);
 
     /** For testing purposes */

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
index 33d72c4..2a74c74 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
@@ -117,8 +117,6 @@ public interface EntityManagerFactory {
 
     public UUID getDefaultAppId();
 
-    public void refreshIndex();
-
     public void rebuildAllIndexes( ProgressObserver po ) throws Exception;
 
     public void rebuildInternalIndexes( ProgressObserver po ) throws Exception;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index 5eea12f..0e1e62a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -409,11 +409,6 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     }
 
     @Override
-    public void refreshIndex() {
-        // no op
-    }
-
-    @Override
     public void flushEntityManagerCaches() {
         // no-op
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/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 112b684..30872c9 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
@@ -2884,11 +2884,6 @@ public class EntityManagerImpl implements EntityManager {
         return Results.fromEntities( entities );
     }
 
-    @Override
-    public void refreshIndex() {
-        // no action necessary
-    }
-
 
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index 99c4654..ea7a5de 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -22,6 +22,8 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 
+import com.google.inject.Injector;
+import org.apache.usergrid.persistence.index.EntityIndex;
 import org.junit.rules.TestRule;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
@@ -49,6 +51,7 @@ public class CoreApplication implements Application, TestRule {
     protected CoreITSetup setup;
     protected EntityManager em;
     protected Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    private EntityIndex entityIndex;
 
 
     public CoreApplication( CoreITSetup setup ) {
@@ -143,7 +146,7 @@ public class CoreApplication implements Application, TestRule {
 
 
     protected void after( Description description ) {
-        LOG.info( "Test {}: finish with application", description.getDisplayName() );
+        LOG.info("Test {}: finish with application", description.getDisplayName());
 
 //        try {
 //            setup.getEmf().getEntityManager(id).().get();
@@ -165,7 +168,9 @@ public class CoreApplication implements Application, TestRule {
         assertNotNull( id );
 
         em = setup.getEmf().getEntityManager( id );
-        assertNotNull( em );
+        Injector injector = setup.getInjector();
+        entityIndex = injector.getInstance(EntityIndex.class);
+        assertNotNull(em);
 
         LOG.info( "Created new application {} in organization {}", appName, orgName );
 
@@ -211,7 +216,7 @@ public class CoreApplication implements Application, TestRule {
 
     @Override
     public void refreshIndex() {
-        em.refreshIndex();
+        entityIndex.refresh();
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java b/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
index 201a0c5..a1db845 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
@@ -19,6 +19,8 @@ package org.apache.usergrid;
 
 import java.util.UUID;
 
+import com.google.inject.Injector;
+import org.apache.usergrid.persistence.index.EntityIndex;
 import org.junit.rules.TestRule;
 
 import org.apache.usergrid.mq.QueueManagerFactory;
@@ -42,4 +44,8 @@ public interface CoreITSetup extends TestRule {
     UUID createApplication( String organizationName, String applicationName ) throws Exception;
 
     void dump( String name, Object obj );
+
+    Injector getInjector();
+
+     EntityIndex getEntityIndex();
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
index d4e69bc..4996684 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
@@ -19,6 +19,7 @@ package org.apache.usergrid;
 
 import java.util.UUID;
 
+import org.apache.usergrid.persistence.index.EntityIndex;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
 import org.slf4j.Logger;
@@ -39,6 +40,7 @@ import com.google.inject.Injector;
 
 public class CoreITSetupImpl implements CoreITSetup {
     private static final Logger LOG = LoggerFactory.getLogger( CoreITSetupImpl.class );
+    private final Injector injector;
 
     protected EntityManagerFactory emf;
     protected QueueManagerFactory qmf;
@@ -55,6 +57,8 @@ public class CoreITSetupImpl implements CoreITSetup {
         emf = springResource.getBean( EntityManagerFactory.class );
         qmf = springResource.getBean( QueueManagerFactory.class );
         indexBucketLocator = springResource.getBean( IndexBucketLocator.class );
+        injector = springResource.getBean(Injector.class);
+
 
     }
 
@@ -145,4 +149,14 @@ public class CoreITSetupImpl implements CoreITSetup {
             LOG.info( name + ":\n" + JsonUtils.mapToFormattedJsonString( obj ) );
         }
     }
+
+    @Override
+    public Injector getInjector() {
+        return injector;
+    }
+
+    @Override
+    public EntityIndex getEntityIndex(){
+        return getInjector().getInstance(EntityIndex.class);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index 450f44b..6ba1353 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -101,7 +101,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
         Entity thing = em.create( "thing", new HashMap<String, Object>() {{
             put( "name", "thing1" );
         }} );
-        em.refreshIndex();
+        app.refreshIndex();
 
         assertEquals( 1, queryCollectionCp( "things", "thing", "select *" ).size() );
 
@@ -111,7 +111,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
         em.updateProperties( thing, new HashMap<String, Object>() {{
             put( "stuff", "widget" );
         }} );
-        em.refreshIndex();
+        app.refreshIndex();
 
         org.apache.usergrid.persistence.model.entity.Entity cpUpdated = getCpEntity( thing );
         assertEquals( "widget", cpUpdated.getField( "stuff" ).getValue() );
@@ -147,14 +147,14 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
             put( "ordinal", 0 );
         }} );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         assertEquals( 1, queryCollectionCp( "things", "thing", "select *" ).size() );
 
         em.updateProperties( thing, new HashMap<String, Object>() {{
             put( "ordinal", 1 );
         }} );
-        em.refreshIndex();
+        app.refreshIndex();
 
         UUID newVersion =  getCpEntity( thing ).getVersion();
 
@@ -182,7 +182,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
         assertEquals( 1, results.size() );
         assertEquals(1, results.getEntities().get( 0 ).getProperty( "ordinal" ));
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         //ensure it's actually gone
         do{
@@ -228,7 +228,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
             }} ) );
 
         }
-        em.refreshIndex();
+        app.refreshIndex();
 
         CandidateResults crs = queryCollectionCp( "things", "thing", "select * order by updateCount asc" );
         Assert.assertEquals( "Expect no stale candidates yet", numEntities, crs.size() );
@@ -258,7 +258,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
             maxVersions.add( toUpdate );
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // query Core Persistence directly for total number of result candidates
         crs = queryCollectionCp( "things", "thing", "select * order by updateCount asc" );
@@ -303,7 +303,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
         assertEquals( "Expect no stale candidates", numEntities, thingCount );
 
 
-        em.refreshIndex();
+        app.refreshIndex();
 
 
         // query for total number of result candidates = numEntities
@@ -339,7 +339,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
             }}));
             Thread.sleep( writeDelayMs );
         }
-        em.refreshIndex();
+        app.refreshIndex();
 
         CandidateResults crs = queryCollectionCp( "things", "thing", "select *");
         Assert.assertEquals( "Expect no stale candidates yet", numEntities, crs.size() );
@@ -367,7 +367,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
 
             maxVersions.add( toUpdate );
         }
-        em.refreshIndex();
+        app.refreshIndex();
 
         // query Core Persistence directly for total number of result candidates
         crs = queryCollectionCp("things", "thing", "select *");
@@ -383,7 +383,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
 
 
         //put this into the top of the queue, once it's acked we've been flushed
-        em.refreshIndex();
+        app.refreshIndex();
 
         // wait for indexes to be cleared for the deleted entities
         count = 0;
@@ -430,7 +430,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
                 put("name", dogName);
             }}));
         }
-        em.refreshIndex();
+        app.refreshIndex();
 
         CandidateResults crs = queryCollectionCp( "dogs", "dog", "select *");
         Assert.assertEquals( "Expect no stale candidates yet", numEntities, crs.size() );
@@ -457,7 +457,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
 
             maxVersions.add( toUpdate );
         }
-        em.refreshIndex();
+        app.refreshIndex();
 
         // wait for indexes to be cleared for the deleted entities
         count = 0;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
index aa75a9a..b1a75d9 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.usergrid.persistence.index.EntityIndex;
 import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -56,6 +57,7 @@ public class CollectionIT extends AbstractCoreIT {
     @Rule
     public Application app = new CoreApplication( setup );
 
+
     @Test
     public void testSimpleCrud() throws Exception {
 
@@ -226,7 +228,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity user = em.create( "user", properties );
         assertNotNull( user );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // EntityRef
         Query query = new Query();
@@ -247,7 +249,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         em.update( user );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // search with the old username, should be no results
         query.addEqualityFilter( "firstname", firstName );
@@ -287,7 +289,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity user = em.create( "user", properties );
         assertNotNull( user );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // EntityRef
         Query query = new Query();
@@ -320,7 +322,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity user = em.create( "user", properties );
         assertNotNull( user );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // EntityRef
         Query query = new Query();
@@ -369,7 +371,7 @@ public class CollectionIT extends AbstractCoreIT {
         properties.put( "nickname", "ed" );
         em.updateProperties( user1, properties );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Results r = em.searchCollection( group, "users",
             new Query().addEqualityFilter( "nickname", "ed" )
@@ -399,7 +401,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity group = em.create( "group", properties );
         assertNotNull( group );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // EntityRef
         Query query = new Query();
@@ -432,7 +434,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity group = em.create( "group", properties );
         assertNotNull( group );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // EntityRef
         Query query = new Query();
@@ -490,7 +492,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         em.addToCollection( user, "activities", em.create( "activity", properties ) );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Results r = em.searchCollection( user, "activities", Query.searchForProperty( "verb", "post" ) );
         LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
@@ -522,7 +524,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity user2 = em.create( "user", properties );
         assertNotNull( user2 );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // EntityRef
         Query query = new Query();
@@ -565,7 +567,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity user2 = em.create( "user", properties );
         assertNotNull( user2 );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // EntityRef
         Query query = new Query();
@@ -606,7 +608,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity game2 = em.create( "orquerygame", properties );
         assertNotNull( game2 );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // EntityRef
         Query query = Query.fromQL( "select * where keywords contains 'Random' "
@@ -685,7 +687,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity game2 = em.create( "game", properties );
         assertNotNull( game2 );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // overlap
         Query query = Query.fromQL( "select * where keywords contains 'test' "
@@ -746,7 +748,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity game2 = em.create( "game", properties );
         assertNotNull( game2 );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // simple not
         Query query = Query.fromQL( "select * where NOT keywords contains 'game'" );
@@ -823,7 +825,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity entity2 = em.create( "game", properties );
         assertNotNull( entity2 );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
 
         // search for games without sub-field Foo should returned zero entities
@@ -880,7 +882,7 @@ public class CollectionIT extends AbstractCoreIT {
         properties.put( "keywords", "Action, New" );
         em.create( "game", properties );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = Query.fromQL( "select * where keywords contains 'hot' or title contains 'hot'" );
         Results r = em.searchCollection( em.getApplicationRef(), "games", query );
@@ -911,7 +913,7 @@ public class CollectionIT extends AbstractCoreIT {
         properties.put( "keywords", "Action, New" );
         Entity thirdGame = em.create( "game", properties );
 
-        em.refreshIndex();//need to track all batches then resolve promises
+        app.refreshIndex();//need to track all batches then resolve promises
 
         Query query = Query.fromQL( "select * where keywords contains 'new' and title contains 'extreme'" );
         Results r = em.searchCollection( em.getApplicationRef(), "games", query );
@@ -942,7 +944,7 @@ public class CollectionIT extends AbstractCoreIT {
             entityIds.add( created.getUuid() );
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = new Query();
         query.setLimit( 50 );
@@ -967,7 +969,7 @@ public class CollectionIT extends AbstractCoreIT {
             numDeleted++;
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // wait for indexes to be cleared
         Thread.sleep( 500 );
@@ -1016,7 +1018,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         int pageSize = 10;
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = new Query();
         query.setLimit( pageSize );
@@ -1069,7 +1071,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         int pageSize = 10;
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = Query.fromQL("select * where index >= " + size / 2);
         query.setLimit( pageSize );
@@ -1119,7 +1121,7 @@ public class CollectionIT extends AbstractCoreIT {
             entityIds.add( created.getUuid() );
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         int pageSize = 10;
 
@@ -1171,7 +1173,7 @@ public class CollectionIT extends AbstractCoreIT {
             entityIds.add( created.getUuid() );
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         int pageSize = 10;
 
@@ -1223,7 +1225,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         Entity saved = em.create( "test", root );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = new Query();
         query.addEqualityFilter( "rootprop1", "simpleprop" );
@@ -1278,7 +1280,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         Entity saved = em.create( "test", jsonData );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = new Query();
         query.addEqualityFilter( "intprop", 10 );
@@ -1342,7 +1344,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         Entity saved = em.create( "test", props );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = new Query();
         query.addEqualityFilter( "myString", "My simple string" );
@@ -1368,7 +1370,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         em.create( "user", properties );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         String s = "select username, email where username = 'edanuff'";
         Query query = Query.fromQL( s );
@@ -1398,7 +1400,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         em.create( "user", properties );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         String s = "select {name: username, email: email} where username = 'edanuff'";
         Query query = Query.fromQL( s );
@@ -1430,7 +1432,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         em.create( "user", properties );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         String s = "select * where username = 'ed@anuff.com'";
         Query query = Query.fromQL( s );
@@ -1452,7 +1454,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         em.createConnection( foo, "testconnection", entity );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // now query via the testConnection, this should work
 
@@ -1495,7 +1497,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         em.create( "loveobject", properties );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         location = new LinkedHashMap<String, Object>();
         location.put( "Place",
@@ -1514,7 +1516,7 @@ public class CollectionIT extends AbstractCoreIT {
 
         em.create( "loveobject", properties );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // String s = "select * where Flag = 'requested'";
         // String s = "select * where Flag = 'requested' and NOT Recipient.Username =
@@ -1560,7 +1562,7 @@ public class CollectionIT extends AbstractCoreIT {
             createdEntities.add( created );
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Results r = em.getCollection( em.getApplicationRef(), "users", null, 50, Level.ALL_PROPERTIES, false );
 
@@ -1655,7 +1657,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity game2 = em.create( "game", properties );
         assertNotNull( game2 );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // overlap
         Query query = new Query();
@@ -1689,7 +1691,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity game2 = em.create( "game", properties );
         assertNotNull( game2 );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // overlap
         Query query = new Query();
@@ -1723,7 +1725,7 @@ public class CollectionIT extends AbstractCoreIT {
         Entity createUser2 = em.create( user2 );
         assertNotNull( createUser2 );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // overlap
         Query query = new Query();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
index 68afbb9..175cc74 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
@@ -76,7 +76,7 @@ public class CountingMutatorIT extends AbstractCoreIT {
         properties.put( "username", "testuser" );
         properties.put( "email", "test@foo.bar" );
         Entity created = em.create( "user", properties );
-        em.refreshIndex();
+        app.refreshIndex();
 
         Entity returned = em.get( created.getUuid() );
 
@@ -91,7 +91,7 @@ public class CountingMutatorIT extends AbstractCoreIT {
 
 
             Entity connectedEntity = em.create( "user", connectedProps );
-            em.refreshIndex();
+            app.refreshIndex();
 
             // Connect from our new entity to our root one so it's updated when paging
             em.createConnection( connectedEntity, "following", returned );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
index 9780b8b..2e7de4f 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
@@ -70,7 +70,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
 
         em.createConnection( firstUserEntity, "likes", secondUserEntity );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Results r = em.getConnectedEntities( firstUserEntity, "likes", null, Level.IDS );
 
@@ -134,7 +134,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
         LOG.info( "\n\nConnecting " + awardA.getUuid() + " \"awarded\" " + catB.getUuid() + "\n" );
         em.createConnection( awardA, "awarded", catB );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // List forward connections for cat A
 
@@ -155,7 +155,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
         LOG.info( "\n\nConnecting " + awardA.getUuid() + " \"awarded\" " + catA.getUuid() + "\n" );
         em.createConnection( awardA, "awarded", catA );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // List forward connections for cat A
 // Not valid with current usages
@@ -262,7 +262,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
 
         em.createConnection( secondUserEntity, "likes", arrogantbutcher );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Results r = em.getConnectedEntities( firstUserEntity, "likes", "restaurant", Level.IDS );
 
@@ -316,7 +316,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
 
         em.createConnection( fredEntity, "likes", wilmaEntity );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
 //        // search for "likes" edges from fred
 //        assertEquals( 1,
@@ -370,7 +370,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
         }
 
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Results r = em.getConnectedEntities( firstUserEntity, "likes", null, Level.ALL_PROPERTIES ) ;
 
@@ -414,7 +414,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
 //
 //        em.createConnection( fredEntity, "likes", wilmaEntity );
 //
-//        em.refreshIndex();
+//        app.refreshIndex();
 //
 ////        // search for "likes" edges from fred
 ////        assertEquals( 1,

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/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 4896fc1..f86b2a3 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
@@ -79,7 +79,7 @@ public class EntityManagerIT extends AbstractCoreIT {
         assertEquals( "user.username not expected value", "edanuff", user.getProperty( "username"));
         assertEquals( "user.email not expected value", "ed@anuff.com", user.getProperty( "email" ));
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         EntityRef userRef = em.getAlias(
             new SimpleEntityRef("application", applicationId), "users", "edanuff" );
@@ -281,7 +281,7 @@ public class EntityManagerIT extends AbstractCoreIT {
         em.delete( thing );
         LOG.info( "Entity deleted" );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // now search by username, no results should be returned
 
@@ -308,13 +308,13 @@ public class EntityManagerIT extends AbstractCoreIT {
         Entity user = em.create( "user", properties );
         LOG.info( "Entity created" );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         LOG.info( "Starting entity delete" );
         em.delete( user );
         LOG.info( "Entity deleted" );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // now search by username, no results should be returned
 
@@ -333,7 +333,7 @@ public class EntityManagerIT extends AbstractCoreIT {
         user = em.create( "user", properties );
         LOG.info( "Entity created" );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         r = em.searchCollection( em.getApplicationRef(), "users",
                 new Query().addEqualityFilter( "username", name ) );
@@ -451,7 +451,7 @@ public class EntityManagerIT extends AbstractCoreIT {
 
         EntityRef appRef = em.get( new SimpleEntityRef("application", app.getId() ) );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Results r = em.getCollection( appRef, "things", null, 10, Level.ALL_PROPERTIES, false );
 
@@ -543,7 +543,7 @@ public class EntityManagerIT extends AbstractCoreIT {
 
         Entity createdDevice = em.createItemInCollection( createdUser, "devices", "device", device );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Entity returnedDevice = em.get( new SimpleEntityRef("device", createdDevice.getUuid()));
 
@@ -575,7 +575,7 @@ public class EntityManagerIT extends AbstractCoreIT {
         Entity user = em.create( "robot", properties );
         assertNotNull( user );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         assertNotNull( em.get( user.getUuid() ));
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
index ff15063..6070933 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
@@ -97,7 +97,7 @@ public class GeoIT extends AbstractCoreIT {
         }};
         Entity user = em.create("user", properties);
         assertNotNull(user);
-        em.refreshIndex();
+        app.refreshIndex();
 
         //2. Query with a globally large distance to verify location
         Query query = Query.fromQL("select * where location within " + Integer.MAX_VALUE + " of 0, 0");
@@ -107,7 +107,7 @@ public class GeoIT extends AbstractCoreIT {
         //3. Remove the entity's location
         properties.remove("location");
         em.updateProperties(user, properties);
-        em.refreshIndex();
+        app.refreshIndex();
 
         //4. Repeat the query, expecting no results
         listResults = em.searchCollection(em.getApplicationRef(), "users", query);
@@ -141,7 +141,7 @@ public class GeoIT extends AbstractCoreIT {
         }};
         Entity user = em.create("user", properties);
         assertNotNull(user);
-        em.refreshIndex();
+        app.refreshIndex();
 
         Point center = new Point(37.776753, -122.407846);
         //2. Query from a point near the entity's location
@@ -193,12 +193,12 @@ public class GeoIT extends AbstractCoreIT {
 
         Entity user = em.create("user", userProperties);
         assertNotNull(user);
-        em.refreshIndex();
+        app.refreshIndex();
 
         //3. Create a connection between the user and the entity
         em.createConnection(user, "likes", restaurant);
 
-        em.refreshIndex();
+        app.refreshIndex();
         //4. Test that the user is within 2000m of the entity
         Results emSearchResults = em.searchConnectedEntities(user,
             Query.fromQL("location within 5000 of "
@@ -235,7 +235,7 @@ public class GeoIT extends AbstractCoreIT {
             assertNotNull(entity);
             LOG.debug("Entity {} created", entity.getProperty("name"));
         }
-        em.refreshIndex();
+        app.refreshIndex();
         //2. validate the size of the result
         Query query = new Query();
         Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
@@ -392,7 +392,7 @@ public class GeoIT extends AbstractCoreIT {
             em.create("store", data);
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = new Query();
         // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
@@ -439,7 +439,7 @@ public class GeoIT extends AbstractCoreIT {
             em.create("store", data);
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = new Query();
         // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
@@ -500,7 +500,7 @@ public class GeoIT extends AbstractCoreIT {
             em.create("store", data);
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = new Query();
         // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
@@ -550,7 +550,7 @@ public class GeoIT extends AbstractCoreIT {
             created.add(e);
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         int startDelta = size - min;
 
@@ -615,7 +615,7 @@ public class GeoIT extends AbstractCoreIT {
             em.create("store", data);
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         //do a direct geo iterator test.  We need to make sure that we short circuit on the correct tile.
 
@@ -679,7 +679,7 @@ public class GeoIT extends AbstractCoreIT {
             assertNotNull(entity);
         }
         //3. refresh the index
-        em.refreshIndex();
+        app.refreshIndex();
         //4. return the entity manager
         return em;
     }
@@ -698,7 +698,7 @@ public class GeoIT extends AbstractCoreIT {
         latlong.put("longitude", longitude);
 
         em.setProperty(entity, "location", latlong);
-        em.refreshIndex();
+        app.refreshIndex();
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
index 97ef0fe..3dfab3f 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
@@ -84,7 +84,7 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
         Entity user2 = em.create( "user", properties );
         assertNotNull( user2 );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // define center point about 300m from that location
         Point center = new Point( 37.774277, -122.404744 );
@@ -163,7 +163,7 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
         Entity userFred = em.create( "user", properties );
         assertNotNull( userFred );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // define center point about 300m from that location
         Point center = new Point( 37.774277, -122.404744 );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
index 66d9276..a60a6b5 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
@@ -74,7 +74,7 @@ public class IndexIT extends AbstractCoreIT {
             em.create( "item", properties );
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         int i = 0;
 
@@ -147,7 +147,7 @@ public class IndexIT extends AbstractCoreIT {
             em.create( "item", properties );
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = Query.fromQL( "name < 'delta' order by name asc" );
         Results r = em.searchCollection( em.getApplicationRef(), "items", query );
@@ -275,7 +275,7 @@ public class IndexIT extends AbstractCoreIT {
             em.create( "item", properties );
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query query = Query.fromQL( "group = 1 order by name desc" );
         Results r = em.searchCollection( em.getApplicationRef(), "items", query );
@@ -314,7 +314,7 @@ public class IndexIT extends AbstractCoreIT {
 
         em.createConnection( entity2Ref, "connecting", entity1Ref );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         //should return valid values
         Query query = Query.fromQL( "select * where status = 'pickled'" );
@@ -333,7 +333,7 @@ public class IndexIT extends AbstractCoreIT {
 
         em.update( entity1Ref );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         //query and check the status has been updated, shouldn't return results
         query = Query.fromQL( "select * where status = 'pickled'" );
@@ -389,7 +389,7 @@ public class IndexIT extends AbstractCoreIT {
 
         em.createConnection( entity2Ref, "connecting", entity1Ref );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         //should return valid values
         Query query = Query.fromQL( "select * where status = 'pickled'" );
@@ -408,7 +408,7 @@ public class IndexIT extends AbstractCoreIT {
 
         em.update( entity1Ref );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         //query and check the status has been updated, shouldn't return results
         query = Query.fromQL( "select * where status = 'pickled'" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
index c56c07f..24cb563 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
@@ -65,7 +65,7 @@ public class PathQueryIT extends AbstractCoreIT {
             }
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // pick an arbitrary user, ensure it has 5 devices
         Results devices = em.getCollection( users.get( 10 ), "devices", null, 20, Level.IDS, false );
@@ -137,7 +137,7 @@ public class PathQueryIT extends AbstractCoreIT {
             }
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // pick an arbitrary group, ensure it has 7 users
         Results ru = em.getCollection( groups.get( 2 ), "users", null, 20, Level.IDS, false );
@@ -154,7 +154,7 @@ public class PathQueryIT extends AbstractCoreIT {
             }
         }
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // pick an arbitrary user, ensure it has 7 devices
         Results rd = em.getCollection( users.get( 6 ), "devices", null, 20, Level.IDS, false );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index c58750b..879f42c 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -145,7 +145,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
                     shepardCount++;
                 }
 
-                em.refreshIndex();
+                app.refreshIndex();
 
 //                em.createConnection(entity, "herds", cat1);
 //                em.createConnection(entity, "herds", cat2);
@@ -165,7 +165,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
         }
 
         logger.info("Created {} entities", entityCount);
-        em.refreshIndex();
+        app.refreshIndex();
 
         // ----------------- test that we can read them, should work fine
 
@@ -283,7 +283,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
                 entityMap.put("key", entityCount );
                 entity = em.create("testType", entityMap );
 
-                em.refreshIndex();
+                app.refreshIndex();
 
                 em.createConnection(entity, "herds", cat1);
                 em.createConnection(entity, "herds", cat2);
@@ -303,7 +303,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
         }
 
         logger.info("Created {} entities", entityCount);
-        em.refreshIndex();
+        app.refreshIndex();
 
         // ----------------- test that we can read them, should work fine
 
@@ -363,7 +363,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
             registry.remove( meterName );
             logger.info("Rebuilt index");
 
-            setup.getEmf().refreshIndex();
+            app.refreshIndex();
 
         } catch (Exception ex) {
             logger.error("Error rebuilding index", ex);
@@ -394,7 +394,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
     private int readData( EntityManager em,
         String collectionName, int expectedEntities, int expectedConnections ) throws Exception {
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Query q = Query.fromQL("select * where key1=1000");
         q.setLimit(40);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
index 5e83a34..6f76a79 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
@@ -151,10 +151,10 @@ public class PermissionsIT extends AbstractCoreIT {
         assertEquals( "proper number of group roles not set", 1, roles.size() );
         dump( "group roles", roles );
 
-        em.refreshIndex();
+        app.refreshIndex();
         em.addUserToGroupRole( user.getUuid(), group.getUuid(), "admin" );
 
-        em.refreshIndex();
+        app.refreshIndex();
         Results r = em.getUsersInGroupRole( group.getUuid(), "admin", Level.ALL_PROPERTIES );
         assertEquals( "proper number of users in group role not set", 1, r.size() );
         dump( "entities", r.getEntities() );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index dea4967..56b6ff4 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -116,7 +116,7 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
         properties2.put( "Year", 1992 );
         Entity film2 = em.create( "film", properties2 );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         // TODO: this assertion should work!
         //assertNotNull( "cannot lookup app by name", setup.getEmf().lookupApplication("test-app-" + rand) );
@@ -125,7 +125,7 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
 
         setup.getEmf().deleteApplication( applicationId );
 
-        em.refreshIndex();
+        app.refreshIndex();
 
         Func2<UUID, Map<String, UUID> ,Boolean> findApps = new Func2<UUID,Map<String, UUID> ,Boolean>() {
             @Override

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
index 109ec14..8965013 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
@@ -55,7 +55,7 @@ public class CollectionIoHelper implements IoHelper {
 
     @Override
     public Results getResults( Query query ) throws Exception {
-        app.getEntityManager().refreshIndex();
+        app.refreshIndex();
         return app.getEntityManager().searchCollection( app.getEntityManager().getApplicationRef(), "tests", query );
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
index aca1778..5f9874b 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
@@ -76,7 +76,7 @@ public class ConnectionHelper extends CollectionIoHelper {
     @Override
     public Results getResults( Query query ) throws Exception {
 
-        app.getEntityManager().refreshIndex();
+        app.refreshIndex();
         query.setConnectionType( CONNECTION );
         query.setEntityType( "test" );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
index f602a53..f4c5c0e 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
@@ -1123,7 +1123,7 @@ public class IteratingQueryIT {
 
         LOG.info( "Writes took {} ms", stop - start );
 
-        app.getEntityManager().refreshIndex();
+        app.refreshIndex();
 
         Query query = new Query();
         query.setLimit( 100 );
@@ -1224,7 +1224,7 @@ public class IteratingQueryIT {
 
         LOG.info( "Writes took {} ms", stop - start );
 
-        app.getEntityManager().refreshIndex();
+        app.refreshIndex();
 
         Query query = Query.fromQL( "select * order by boolean desc, index asc" );
         query.setLimit( queryLimit );
@@ -1330,7 +1330,7 @@ public class IteratingQueryIT {
 
         LOG.info( "Writes took {} ms", stop - start );
 
-        app.getEntityManager().refreshIndex();
+        app.refreshIndex();
 
         Query query =
                 Query.fromQL( "select * where intersect = true OR intersect2 = true order by created, intersect desc" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
index f8ed107..c83fe41 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
@@ -129,7 +129,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
     public CandidateResults search(final IndexScope indexScope, final SearchTypes searchTypes,
                                    final Query query ) {
 
-        final String context = IndexingUtils.createContextName(indexScope);
+        final String context = IndexingUtils.createContextName(applicationScope,indexScope);
         final String[] entityTypes = searchTypes.getTypeNames(applicationScope);
         QueryBuilder qb = query.createQueryBuilder(context);
         SearchResponse searchResponse;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 04fde6a..1eb73d3 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -327,7 +327,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
 
     public void refresh() {
         refreshIndexMeter.mark();
-
+        final Timer.Context timeRefreshIndex = refreshTimer.time();
         BetterFuture future = indexBatchBufferProducer.put(new IndexOperationMessage());
         future.get();
         //loop through all batches and retrieve promises and call get
@@ -346,7 +346,6 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
                         return true;
                     }
                     //Added For Graphite Metrics
-                    Timer.Context timeRefreshIndex = refreshTimer.time();
                     esProvider.getClient().admin().indices().prepareRefresh( indexes ).execute().actionGet();
                     timeRefreshIndex.stop();
                     logger.debug("Refreshed indexes: {}", StringUtils.join(indexes, ", "));

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
index 422eedd..cd73991 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
@@ -28,6 +28,8 @@ import javax.ws.rs.core.Request;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
 
+import com.google.inject.Injector;
+import org.apache.usergrid.persistence.index.EntityIndex;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.apache.usergrid.management.ManagementService;
 import org.apache.usergrid.mq.QueueManagerFactory;
@@ -54,9 +56,13 @@ import org.slf4j.LoggerFactory;
 
 public abstract class AbstractContextResource {
 
-    protected static final TypeReference<Map<String, Object>> mapTypeReference = new TypeReference<Map<String, Object>>() {};
-    protected static final TypeReference<List<Object>> listTypeReference = new TypeReference<List<Object>>() {};
-    protected static final   ObjectMapper mapper = new ObjectMapper();
+    protected static final TypeReference<Map<String, Object>> mapTypeReference = new TypeReference<Map<String, Object>>() {
+    };
+    protected static final TypeReference<List<Object>> listTypeReference = new TypeReference<List<Object>>() {
+    };
+    protected static final ObjectMapper mapper = new ObjectMapper();
+
+    private EntityIndex entityIndex;
 
 
     protected AbstractContextResource parent;
@@ -98,9 +104,12 @@ public abstract class AbstractContextResource {
     protected QueueManagerFactory qmf;
 
     @Autowired
+    protected Injector injector;
+
+    @Autowired
     protected TokenService tokens;
 
-    private static final Logger logger = LoggerFactory.getLogger( AbstractContextResource.class );
+    private static final Logger logger = LoggerFactory.getLogger(AbstractContextResource.class);
 
 
     public AbstractContextResource() {
@@ -112,26 +121,26 @@ public abstract class AbstractContextResource {
     }
 
 
-    public void setParent( AbstractContextResource parent ) {
+    public void setParent(AbstractContextResource parent) {
         this.parent = parent;
     }
 
 
-    public <T extends AbstractContextResource> T getSubResource( Class<T> t ) {
+    public <T extends AbstractContextResource> T getSubResource(Class<T> t) {
         logger.debug("getSubResource: " + t.getCanonicalName());
-        T subResource = resourceContext.getResource( t );
-        subResource.setParent( this );
+        T subResource = resourceContext.getResource(t);
+        subResource.setParent(this);
         return subResource;
     }
 
 
-    public PathSegment getFirstPathSegment( String name ) {
-        if ( name == null ) {
+    public PathSegment getFirstPathSegment(String name) {
+        if (name == null) {
             return null;
         }
         List<PathSegment> segments = uriInfo.getPathSegments();
-        for ( PathSegment segment : segments ) {
-            if ( name.equals( segment.getPath() ) ) {
+        for (PathSegment segment : segments) {
+            if (name.equals(segment.getPath())) {
                 return segment;
             }
         }
@@ -140,70 +149,73 @@ public abstract class AbstractContextResource {
 
 
     public boolean useReCaptcha() {
-        return StringUtils.isNotBlank( properties.getRecaptchaPublic() )
-                && StringUtils.isNotBlank( properties.getRecaptchaPrivate() );
+        return StringUtils.isNotBlank(properties.getRecaptchaPublic())
+            && StringUtils.isNotBlank(properties.getRecaptchaPrivate());
     }
 
 
     public String getReCaptchaHtml() {
-        if ( !useReCaptcha() ) {
+        if (!useReCaptcha()) {
             return "";
         }
         ReCaptcha c = ReCaptchaFactory.newSecureReCaptcha(
-                properties.getRecaptchaPublic(), properties.getRecaptchaPrivate(), false );
-        return c.createRecaptchaHtml( null, null );
+            properties.getRecaptchaPublic(), properties.getRecaptchaPrivate(), false);
+        return c.createRecaptchaHtml(null, null);
     }
 
 
-    public void sendRedirect( String location ) {
-        if ( StringUtils.isNotBlank( location ) ) {
-            throw new RedirectionException( location );
+    public void sendRedirect(String location) {
+        if (StringUtils.isNotBlank(location)) {
+            throw new RedirectionException(location);
         }
     }
 
 
-    public Viewable handleViewable( String template, Object model ) {
+    public Viewable handleViewable(String template, Object model) {
 
         String className = this.getClass().getName().toLowerCase();
         String packageName = AbstractContextResource.class.getPackage().getName();
 
         String template_property = "usergrid.view" +
-            StringUtils.removeEnd( className.toLowerCase(), "resource" )
-                .substring( packageName.length() ) + "." + template.toLowerCase();
+            StringUtils.removeEnd(className.toLowerCase(), "resource")
+                .substring(packageName.length()) + "." + template.toLowerCase();
 
-        String redirect_url = properties.getProperty( template_property );
+        String redirect_url = properties.getProperty(template_property);
 
-        if ( StringUtils.isNotBlank( redirect_url ) ) {
+        if (StringUtils.isNotBlank(redirect_url)) {
             logger.debug("Redirecting to URL: ", redirect_url);
-            sendRedirect( redirect_url );
+            sendRedirect(redirect_url);
         }
         logger.debug("Dispatching to viewable with template: {}",
-                template, template_property );
+            template, template_property);
 
-        Viewable viewable = new Viewable( template, model, this.getClass() );
+        Viewable viewable = new Viewable(template, model, this.getClass());
         return viewable;
     }
 
 
-
     protected ApiResponse createApiResponse() {
-        return new ApiResponse( properties );
+        return new ApiResponse(properties);
     }
 
+    protected EntityIndex getEntityIndex(){
+        entityIndex = entityIndex == null ? injector.getInstance(EntityIndex.class) : entityIndex;
+        return entityIndex;
+    }
     /**
-          * Next three new methods necessary to work around inexplicable problems with EntityHolder.
-          * This problem happens consistently when you deploy "two-dot-o" to Tomcat:
-          * https://groups.google.com/forum/#!topic/usergrid/yyAJdmsBfig
-          */
-         protected Object readJsonToObject( String content ) throws IOException {
-
-             JsonNode jsonNode = mapper.readTree( content );
-             Object jsonObject;
-             if ( jsonNode.isArray() ) {
-                 jsonObject = mapper.readValue( content, listTypeReference );
-             } else {
-                 jsonObject = mapper.readValue( content, mapTypeReference );
-             }
-             return jsonObject;
-         }
+     * Next three new methods necessary to work around inexplicable problems with EntityHolder.
+     * This problem happens consistently when you deploy "two-dot-o" to Tomcat:
+     * https://groups.google.com/forum/#!topic/usergrid/yyAJdmsBfig
+     */
+    protected Object readJsonToObject(String content) throws IOException {
+
+        JsonNode jsonNode = mapper.readTree(content);
+        Object jsonObject;
+        if (jsonNode.isArray()) {
+            jsonObject = mapper.readValue(content, listTypeReference);
+        } else {
+            jsonObject = mapper.readValue(content, mapTypeReference);
+        }
+        return jsonObject;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
index f3238a4..d68b894 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
@@ -300,7 +300,7 @@ public class IndexResource extends AbstractContextResource {
         logger.info( "Reindexing for app id: {} and collection {}", applicationId, collectionName );
 
         emf.rebuildCollectionIndex(applicationId, collectionName, reverse, po);
-        emf.refreshIndex();
+        getEntityIndex().refresh();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
index 4d0adb7..1717011 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
@@ -36,7 +36,7 @@ import org.springframework.stereotype.Component;
 import org.apache.usergrid.rest.AbstractContextResource;
 
 
-/** 
+/**
  * Refresh index of an application, FOR TESTING PURPOSES ONLY. Only works with usergrid.test=true.
  */
 @Component
@@ -49,9 +49,9 @@ public class RefreshIndexResource extends AbstractContextResource {
     public RefreshIndexResource() {}
 
     @POST
-    public Response refresh( 
-            @QueryParam("org_name") String orgName, 
-            @QueryParam("app_name") String appName, 
+    public Response refresh(
+            @QueryParam("org_name") String orgName,
+            @QueryParam("app_name") String appName,
             @QueryParam("app_id") String appIdString ) throws IOException, Exception {
 
         try {
@@ -64,7 +64,7 @@ public class RefreshIndexResource extends AbstractContextResource {
             }
 
             // refresh the system apps or app lookup below may fail
-            emf.refreshIndex();
+            getEntityIndex().refresh();
 
             UUID appId;
             if ( orgName != null && appName != null ) {
@@ -72,12 +72,13 @@ public class RefreshIndexResource extends AbstractContextResource {
             } else {
                 appId = UUID.fromString(appIdString);
             }
-            
+
             if ( appId != null ) {
                 // found an app, then refresh it!
                 EntityManager em = emf.getEntityManager( appId );
-                em.refreshIndex();
-            } 
+                getEntityIndex().refresh();
+
+            }
 
         } catch (Exception e) {
             logger.error("Error in refresh", e);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
index 4172327..4ba85f3 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
@@ -73,7 +73,7 @@ public class ServiceApplication extends CoreApplication {
         ServiceResults testRequest = testRequest( action, expectedCount, true, params );
 
         if ( !action.equals( ServiceAction.GET )) {
-            getEntityManager().refreshIndex();
+            setup.getEntityIndex().refresh();
         }
 
         return testRequest;
@@ -105,7 +105,7 @@ public class ServiceApplication extends CoreApplication {
         dumpResults( results );
 
         if ( !action.name().equals( ServiceAction.GET )) {
-            getEntityManager().refreshIndex();
+            setup.getEntityIndex().refresh();
         }
 
         return results;
@@ -131,14 +131,14 @@ public class ServiceApplication extends CoreApplication {
         put( "name", name );
 
         Entity entity = testRequest( ServiceAction.POST, 1, pluralize( entityType ) ).getEntity();
-        getEntityManager().refreshIndex();
+        setup.getEntityIndex().refresh();
         return entity;
     }
 
 
     public void createConnection( Entity subject, String verb, Entity noun ) throws Exception {
         sm.getEntityManager().createConnection( subject, verb, noun );
-        getEntityManager().refreshIndex();
+        setup.getEntityIndex().refresh();
     }
 
 
@@ -153,7 +153,7 @@ public class ServiceApplication extends CoreApplication {
         dumpResults( results );
 
         if ( !action.name().equals( ServiceAction.GET )) {
-            getEntityManager().refreshIndex();
+            setup.getEntityIndex().refresh();
         }
 
         return results;
@@ -169,7 +169,7 @@ public class ServiceApplication extends CoreApplication {
         assertNotNull( results.getData() );
 
         if ( !action.name().equals( ServiceAction.GET )) {
-            getEntityManager().refreshIndex();
+            setup.getEntityIndex().refresh();
         }
 
         // dump( results.getData() );
@@ -179,20 +179,20 @@ public class ServiceApplication extends CoreApplication {
 
     public Entity createRole( String name, String title, int inactivity ) throws Exception {
         Entity createRole = sm.getEntityManager().createRole( name, title, inactivity );
-        getEntityManager().refreshIndex();
+        setup.getEntityIndex().refresh();
         return createRole;
     }
 
 
     public void grantRolePermission( String role, String permission ) throws Exception {
         sm.getEntityManager().grantRolePermission( role, permission );
-        getEntityManager().refreshIndex();
+        setup.getEntityIndex().refresh();
     }
 
 
     public void grantUserPermission( UUID uuid, String permission ) throws Exception {
         sm.getEntityManager().grantUserPermission( uuid, permission );
-        getEntityManager().refreshIndex();
+        setup.getEntityIndex().refresh();
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
index 2632909..1062120 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
@@ -283,7 +283,7 @@ public class EmailFlowIT {
         String activation_url = String.format( setup.get( PROPERTIES_USER_ACTIVATION_URL ), orgName, appName,
             appUser.getUuid().toString() );
 
-        setup.getEmf().refreshIndex();
+        setup.getEntityIndex().refresh();
 
         // Activation
         setup.getMgmtSvc().startAppUserActivationFlow( app.getId(), appUser );
@@ -356,7 +356,7 @@ public class EmailFlowIT {
         orgOwner = createOwnerAndOrganization( orgName, appName, userName, email, passwd, false, false );
         assertNotNull( orgOwner );
 
-        setup.getEmf().refreshIndex();
+        setup.getEntityIndex().refresh();
 
         ApplicationInfo app = setup.getMgmtSvc().createApplication( orgOwner.getOrganization().getUuid(), appName );
         assertNotNull( app );
@@ -466,7 +466,7 @@ public class EmailFlowIT {
         userProps.put( "activated", activated );
 
         User user = em.create( User.ENTITY_TYPE, User.class, userProps );
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
         return user;
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
index 5bf0c3d..7bd6574 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
@@ -70,7 +70,7 @@ public class OrganizationIT {
         //createOrganization( orgName, user, false );
         assertNotNull( organization );
 
-        setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() ).refreshIndex();
+        setup.getEntityIndex().refresh();
         Map<UUID, String> userOrganizations = setup.getMgmtSvc().getOrganizationsForAdminUser(
             organization.getOwner().getUuid() );
         assertEquals( "wrong number of organizations", 1, userOrganizations.size() );
@@ -82,8 +82,8 @@ public class OrganizationIT {
         UUID applicationId = setup.getMgmtSvc().createApplication( organization.getOrganization().getUuid(), "ed-application" ).getId();
         assertNotNull( applicationId );
 
-        setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() ).refreshIndex();
-        setup.getEmf().getEntityManager( applicationId ).refreshIndex();
+
+        setup.getEntityIndex().refresh();
 
         Map<UUID, String> applications = setup.getMgmtSvc().getApplicationsForOrganization( organization.getOrganization().getUuid() );
         assertEquals( "wrong number of applications", 1, applications.size() );
@@ -97,7 +97,7 @@ public class OrganizationIT {
 
         setup.getMgmtSvc().activateOrganization( organization2 );
 
-        setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() ).refreshIndex();
+        setup.getEntityIndex().refresh();
 
         UserInfo u = setup.getMgmtSvc().verifyAdminUserPasswordCredentials( organization.getOwner().getUuid().toString(), "test" );
         assertNotNull( u );
@@ -215,7 +215,7 @@ public class OrganizationIT {
         OrganizationInfo organization2 = setup.getMgmtSvc().createOrganization(uniqueOrg(), user, false );
         assertNotNull( organization2 );
 
-        setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() ).refreshIndex();
+        setup.getEntityIndex().refresh();
         Map<UUID, String> userOrganizations = setup.getMgmtSvc().getOrganizationsForAdminUser( user.getUuid() );
         assertEquals( "wrong number of organizations", 2, userOrganizations.size() );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java b/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
index 05cc7c3..64109b2 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
@@ -66,7 +66,7 @@ public class RoleIT {
         UUID applicationId = setup.getMgmtSvc().createApplication( organization.getUuid(), "test-app" ).getId();
         EntityManager em = setup.getEmf().getEntityManager( applicationId );
 
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
         Map<String, Object> properties = new LinkedHashMap<String, Object>();
         properties.put( "username", "edanuff5" );
@@ -75,7 +75,7 @@ public class RoleIT {
         User user = em.create( User.ENTITY_TYPE, User.class, properties );
 
         em.createRole( "logged-in", "Logged In", 1000 );
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
         em.addUserToRole( user.getUuid(), "logged-in" );
 
         String accessToken = setup.getMgmtSvc().getAccessTokenForAppUser( applicationId, user.getUuid(), 0 );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 8d551cf..9f4fc94 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -97,7 +97,7 @@ public class ManagementServiceIT {
         adminUser = orgAppAdminRule.getAdminInfo();
         applicationId = orgAppAdminRule.getApplicationInfo().getId();
 
-        setup.getEmf().refreshIndex();
+        setup.getEntityIndex().refresh();
     }
 
 
@@ -195,7 +195,7 @@ public class ManagementServiceIT {
 
         setup.getMgmtSvc().activateAppUser( applicationId, user.getUuid() );
 
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
         user = em.get( entity.getUuid(), User.class );
 
@@ -491,7 +491,7 @@ public class ManagementServiceIT {
                                           false, false );
 
         EntityManager em = setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() );
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
         UserInfo authedUser = setup.getMgmtSvc().verifyAdminUserPasswordCredentials( username, password );
 
@@ -542,7 +542,7 @@ public class ManagementServiceIT {
 
         em.addToDictionary( storedUser, DICTIONARY_CREDENTIALS, "password", info );
 
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
 
         //verify authorization works
@@ -580,7 +580,7 @@ public class ManagementServiceIT {
         EntityManager em = setup.getEmf().getEntityManager( setup.getEmf().getManagementAppId() );
 
         User storedUser = em.create( user );
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
 
         UUID userId = storedUser.getUuid();
@@ -647,7 +647,7 @@ public class ManagementServiceIT {
 
         User storedUser = em.create( user );
 
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
         UUID userId = storedUser.getUuid();
 
@@ -664,7 +664,7 @@ public class ManagementServiceIT {
 
         setup.getMgmtSvc().setAppUserPassword( appId, userId, password, newPassword );
 
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
         //verify authorization works
         authedUser = setup.getMgmtSvc().verifyAppUserPasswordCredentials( appId, username, newPassword );
@@ -691,7 +691,7 @@ public class ManagementServiceIT {
 
         User storedUser = em.create( user );
 
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
         UUID userId = storedUser.getUuid();
 
@@ -721,7 +721,7 @@ public class ManagementServiceIT {
 
         setup.getMgmtSvc().setAppUserPassword( appId, userId, password, newPassword );
 
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
         //verify authorization works
         authedUser = setup.getMgmtSvc().verifyAppUserPasswordCredentials( appId, username, newPassword );
@@ -750,7 +750,7 @@ public class ManagementServiceIT {
 
         User storedUser = em.create( user );
 
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
         UUID userId = storedUser.getUuid();
 
@@ -787,7 +787,7 @@ public class ManagementServiceIT {
 
         setup.getMgmtSvc().setAppUserPassword( appId, userId, password, newPassword );
 
-        em.refreshIndex();
+        setup.getEntityIndex().refresh();
 
         //verify authorization works
         authedUser = setup.getMgmtSvc().verifyAppUserPasswordCredentials( appId, username, newPassword );


Mime
View raw message