You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/03/30 21:58:30 UTC
[26/50] incubator-usergrid git commit: Use Graph instead of ES to get
AppInfo information for migration.
Use Graph instead of ES to get AppInfo information for migration.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/285230f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/285230f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/285230f3
Branch: refs/heads/two-dot-o-dev
Commit: 285230f36cd79519f7c158aaf4acbe48589d891a
Parents: f837883
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Mar 16 12:16:37 2015 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Mar 16 12:16:37 2015 -0400
----------------------------------------------------------------------
.../migration/AppInfoMigrationPlugin.java | 297 ++++++++++++++-----
.../org/apache/usergrid/CoreITSetupImpl.java | 9 +-
.../apache/usergrid/persistence/CounterIT.java | 5 +-
.../usergrid/persistence/EntityManagerIT.java | 5 +-
.../cassandra/EntityManagerFactoryImplIT.java | 7 +-
.../cassandra/ManagementServiceIT.java | 13 +-
.../management/export/ExportServiceIT.java | 8 +-
.../usergrid/services/ServiceFactoryIT.java | 8 +-
8 files changed, 273 insertions(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/285230f3/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPlugin.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPlugin.java
index 1f8f784..c0f3f15 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPlugin.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPlugin.java
@@ -19,25 +19,40 @@
package org.apache.usergrid.corepersistence.migration;
import com.google.inject.Inject;
+import org.apache.usergrid.corepersistence.util.CpEntityMapUtils;
import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.persistence.*;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.EntityCollectionManager;
+import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
+import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
import org.apache.usergrid.persistence.core.migration.data.MigrationPlugin;
import org.apache.usergrid.persistence.core.migration.data.PluginPhase;
import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.entities.Group;
+import org.apache.usergrid.persistence.graph.Edge;
+import org.apache.usergrid.persistence.graph.GraphManager;
+import org.apache.usergrid.persistence.graph.GraphManagerFactory;
+import org.apache.usergrid.persistence.graph.SearchByEdgeType;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.model.entity.*;
import org.apache.usergrid.utils.UUIDUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import rx.Observable;
+import rx.functions.Func1;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_APPLICATION_ID;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_UUID;
+import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getApplicationScope;
+import static org.apache.usergrid.persistence.Schema.*;
/**
@@ -52,16 +67,50 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
public static String PLUGIN_NAME = "appinfo-migration";
@Inject
- protected MigrationInfoSerialization migrationInfoSerialization;
+ final private MigrationInfoSerialization migrationInfoSerialization;
@Inject
- protected EntityManagerFactory emf; // protected for test purposes only
+ final private EntityManagerFactory emf;
+
+ @Inject
+ final private EntityCollectionManagerFactory entityCollectionManagerFactory;
+
+ @Inject
+ final private GraphManagerFactory graphManagerFactory;
+
+
+ @Inject
+ public AppInfoMigrationPlugin(
+ EntityManagerFactory emf,
+ MigrationInfoSerialization migrationInfoSerialization,
+ EntityCollectionManagerFactory entityCollectionManagerFactory,
+ GraphManagerFactory graphManagerFactory ) {
+
+ this.emf = emf;
+ this.migrationInfoSerialization = migrationInfoSerialization;
+ this.entityCollectionManagerFactory = entityCollectionManagerFactory;
+ this.graphManagerFactory = graphManagerFactory;
+ }
+
@Override
public String getName() {
return PLUGIN_NAME;
}
+
+ @Override
+ public int getMaxVersion() {
+ return 1; // standalone plugin, happens once
+ }
+
+
+ @Override
+ public PluginPhase getPhase() {
+ return PluginPhase.MIGRATE;
+ }
+
+
@Override
public void run(ProgressObserver observer) {
@@ -74,21 +123,14 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
observer.start();
- // Search the old and now deprecated System App for appinfo entities
+ // Get appinfos from the Graph, we don't expect many so use iterator
- EntityManager systemAppEm = emf.getEntityManager( CpNamingUtils.SYSTEM_APP_ID );
- Query q = Query.fromQL("select *");
- Results results;
- try {
- results = systemAppEm.searchCollection(systemAppEm.getApplicationRef(), "appinfos", q);
- } catch (Exception e) {
- logger.error("Error reading old appinfos collection, not migrating", e);
- return;
- }
+ final Iterator<org.apache.usergrid.persistence.model.entity.Entity> iterator =
+ getOldAppInfos().toBlocking().getIterator();
- if ( !results.isEmpty() ) {
+ if ( iterator.hasNext() ) {
- // we found appinfos, let's migrate them to application_infos in the Management App
+ // we found appinfos, now migrate them to application_infos in the Management App
final EntityManager em = emf.getEntityManager( emf.getManagementAppId());
@@ -96,49 +138,14 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
try {
logger.info("Migrating old appinfos");
- for (Entity oldAppInfo : results.getEntities()) {
-
- final String appName = currentAppName = oldAppInfo.getName();
- final String orgName = appName.split("/")[0];
-
- UUID applicationId;
-
- Object uuidObject = oldAppInfo.getProperty("applicationUuid");
- if (uuidObject instanceof UUID) {
- applicationId = (UUID) uuidObject;
- } else {
- applicationId = UUIDUtils.tryExtractUUID(uuidObject.toString());
- }
-
- // create and connect new APPLICATION_INFO oldAppInfo to Organization
+ while ( iterator.hasNext() ) {
- final UUID appId = applicationId;
+ Map oldAppInfo = CpEntityMapUtils.toMap( iterator.next() );
+ currentAppName = (String)oldAppInfo.get( PROPERTY_NAME );
- Entity appInfo = getApplicationInfo( emf, appId );
- if ( appInfo == null ) {
- Map<String, Object> appInfoMap = new HashMap<String, Object>() {{
- put(PROPERTY_NAME, appName);
- put(PROPERTY_APPLICATION_ID, appId);
- }};
- appInfo = em.create(appId, CpNamingUtils.APPLICATION_INFO, appInfoMap);
- observer.update( getMaxVersion(), "Created application_info for " + appName);
-
- } else {
- appInfo.setProperty(PROPERTY_APPLICATION_ID, appId);
- em.update(appInfo);
- observer.update( getMaxVersion(), "Updated existing application_info for " + appName);
- }
-
- // create org->app connections, but not for apps in dummy "usergrid" internal organization
-
- if ( !orgName.equals("usergrid") ) {
- EntityRef orgRef = em.getAlias(Group.ENTITY_TYPE, appName.split("/")[0]);
- em.createConnection(orgRef, "owns", appInfo);
- }
+ migragrateOneAppInfo(em, oldAppInfo, observer);
}
- em.refreshIndex();
-
// note that the old appinfos are not deleted
migrationInfoSerialization.setVersion( getName(), getMaxVersion() );
@@ -160,25 +167,177 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
}
- private Entity getApplicationInfo( EntityManagerFactory emf, UUID appId ) throws Exception {
- UUID mgmtAppId = emf.getManagementAppId();
- EntityManager rootEm = emf.getEntityManager( mgmtAppId );
+ private void migragrateOneAppInfo(
+ EntityManager em, Map oldAppInfo, ProgressObserver observer) throws Exception {
+
+ final String name = (String)oldAppInfo.get( PROPERTY_NAME );
+ final String orgName = name.split("/")[0];
+ final String appName = name.split("/")[1];
+
+ UUID applicationId;
+
+ Object uuidObject = oldAppInfo.get("applicationUuid");
+ if (uuidObject instanceof UUID) {
+ applicationId = (UUID) uuidObject;
+ } else {
+ applicationId = UUIDUtils.tryExtractUUID(uuidObject.toString());
+ }
+
+ // create and connect new APPLICATION_INFO oldAppInfo to Organization
+
+ final UUID appId = applicationId;
+
+ Entity appInfo = getApplicationInfo( emf, appId );
+ if ( appInfo == null ) {
+ Map<String, Object> appInfoMap = new HashMap<String, Object>() {{
+ put(PROPERTY_NAME, name);
+ put(PROPERTY_APPLICATION_ID, appId);
+ }};
+ appInfo = em.create(appId, CpNamingUtils.APPLICATION_INFO, appInfoMap);
+ observer.update( getMaxVersion(), "Created application_info for " + appName);
+
+ } else {
+ appInfo.setProperty(PROPERTY_APPLICATION_ID, appId);
+ em.update(appInfo);
+ observer.update( getMaxVersion(), "Updated existing application_info for " + appName);
+ }
- final Results applicationInfoResults = rootEm.searchCollection(
- new SimpleEntityRef("application", mgmtAppId), "application_infos",
- Query.fromQL("select * where applicationId=" + appId.toString()));
+ // create org->app connections, but not for apps in dummy "usergrid" internal organization
- return applicationInfoResults.getEntity();
+ if ( !orgName.equals("usergrid") ) {
+ EntityRef orgRef = em.getAlias(Group.ENTITY_TYPE, orgName );
+ em.createConnection(orgRef, "owns", appInfo);
+ }
}
- @Override
- public int getMaxVersion() {
- return 1; // standalone plugin, happens once
+
+ /**
+ * TODO: Use Graph to get application_info for an specified Application.
+ */
+ private Entity getApplicationInfo( final EntityManagerFactory emf, final UUID appId ) throws Exception {
+
+ final ApplicationScope appScope = getApplicationScope( emf.getManagementAppId() );
+
+ final CollectionScope appInfoCollectionScope =
+ new CollectionScopeImpl( appScope.getApplication(), appScope.getApplication(),
+ CpNamingUtils.getCollectionScopeNameFromCollectionName( CpNamingUtils.APPLICATION_INFOS ));
+
+ final EntityCollectionManager collectionManager =
+ entityCollectionManagerFactory.createCollectionManager( appInfoCollectionScope );
+
+ final GraphManager gm = graphManagerFactory.createEdgeManager(appScope);
+
+ String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( CpNamingUtils.APPLICATION_INFOS );
+
+ Id rootAppId = appScope.getApplication();
+
+ final SimpleSearchByEdgeType simpleSearchByEdgeType = new SimpleSearchByEdgeType(
+ rootAppId, edgeType, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null);
+
+ // TODO: is there a better way?
+
+ Observable<org.apache.usergrid.persistence.model.entity.Entity> entityObs =
+ gm.loadEdgesFromSource( simpleSearchByEdgeType )
+ .flatMap(new Func1<Edge, Observable<org.apache.usergrid.persistence.model.entity.Entity>>() {
+
+ @Override
+ public Observable<org.apache.usergrid.persistence.model.entity.Entity> call(final Edge edge) {
+
+ final Id appInfoId = edge.getTargetNode();
+
+ return collectionManager.load(appInfoId)
+ .filter(new Func1<org.apache.usergrid.persistence.model.entity.Entity, Boolean>() {
+ @Override
+ public Boolean call(final org.apache.usergrid.persistence.model.entity.Entity entity) {
+ if (entity == null) {
+ logger.warn("Encountered a null application info for id {}", appInfoId);
+ return false;
+ }
+ if ( entity.getId().getUuid().equals( appId )) {
+ return true;
+ }
+ return false;
+ }
+ });
+ }
+ });
+
+ // don't expect many applications, so we block
+
+ org.apache.usergrid.persistence.model.entity.Entity applicationInfo =
+ entityObs.toBlocking().lastOrDefault(null);
+
+ if ( applicationInfo == null ) {
+ return null;
+ }
+
+ Class clazz = Schema.getDefaultSchema().getEntityClass(applicationInfo.getId().getType());
+
+ Entity entity = EntityFactory.newEntity(
+ applicationInfo.getId().getUuid(), applicationInfo.getId().getType(), clazz );
+
+ entity.setProperties( CpEntityMapUtils.toMap( applicationInfo ) );
+
+ return entity;
+
+// UUID mgmtAppId = emf.getManagementAppId();
+// EntityManager rootEm = emf.getEntityManager( mgmtAppId );
+//
+// final Results applicationInfoResults = rootEm.searchCollection(
+// new SimpleEntityRef("application", mgmtAppId), "application_infos",
+// Query.fromQL("select * where applicationId=" + appId.toString()));
+//
+// return applicationInfoResults.getEntity();
}
- @Override
- public PluginPhase getPhase() {
- return PluginPhase.MIGRATE;
+
+ /**
+ * Use Graph to get old appinfos from the old and deprecated System App.
+ */
+ public Observable<org.apache.usergrid.persistence.model.entity.Entity> getOldAppInfos( ) {
+
+ final ApplicationScope appScope = getApplicationScope( CpNamingUtils.SYSTEM_APP_ID );
+
+ final CollectionScope appInfoCollectionScope =
+ new CollectionScopeImpl( appScope.getApplication(), appScope.getApplication(),
+ CpNamingUtils.getCollectionScopeNameFromCollectionName( "appinfos" ));
+
+ final EntityCollectionManager collectionManager =
+ entityCollectionManagerFactory.createCollectionManager( appInfoCollectionScope );
+
+ final GraphManager gm = graphManagerFactory.createEdgeManager(appScope);
+
+ String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( "appinfos" );
+
+ Id rootAppId = appScope.getApplication();
+
+ final SimpleSearchByEdgeType simpleSearchByEdgeType = new SimpleSearchByEdgeType(
+ rootAppId, edgeType, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null);
+
+ Observable<org.apache.usergrid.persistence.model.entity.Entity> entityObs =
+ gm.loadEdgesFromSource( simpleSearchByEdgeType )
+ .flatMap(new Func1<Edge, Observable<org.apache.usergrid.persistence.model.entity.Entity>>() {
+
+ @Override
+ public Observable<org.apache.usergrid.persistence.model.entity.Entity> call(final Edge edge) {
+
+ final Id appInfoId = edge.getTargetNode();
+
+ return collectionManager.load(appInfoId)
+ .filter(new Func1<org.apache.usergrid.persistence.model.entity.Entity, Boolean>() {
+ @Override
+ public Boolean call(final org.apache.usergrid.persistence.model.entity.Entity entity) {
+ if (entity == null) {
+ logger.warn("Encountered a null application info for id {}", appInfoId);
+ return false;
+ }
+ return true;
+ }
+ });
+ }
+ });
+
+ return entityObs;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/285230f3/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 6557b02..efa6a47 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,8 @@ package org.apache.usergrid;
import java.util.UUID;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.utils.UUIDUtils;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.slf4j.Logger;
@@ -36,6 +38,8 @@ import org.apache.usergrid.utils.JsonUtils;
import com.google.inject.Injector;
+import static org.apache.usergrid.persistence.Schema.PROPERTY_APPLICATION_ID;
+
public class CoreITSetupImpl implements CoreITSetup {
private static final Logger LOG = LoggerFactory.getLogger( CoreITSetupImpl.class );
@@ -129,7 +133,10 @@ public class CoreITSetupImpl implements CoreITSetup {
@Override
public UUID createApplication( String organizationName, String applicationName ) throws Exception {
- return emf.createApplication( organizationName, applicationName );
+ Entity appInfo = emf.createApplicationV2(organizationName, applicationName);
+ UUID applicationId = UUIDUtils.tryExtractUUID(
+ appInfo.getProperty(PROPERTY_APPLICATION_ID).toString());
+ return applicationId;
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/285230f3/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
index 00e81d3..a5e1493 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
@@ -45,6 +45,7 @@ import org.apache.usergrid.utils.UUIDUtils;
import net.jcip.annotations.NotThreadSafe;
+import static org.apache.usergrid.persistence.Schema.PROPERTY_APPLICATION_ID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -218,7 +219,9 @@ public class CounterIT extends AbstractCoreIT {
organizationEntity.setProperty( "name", orgName );
organizationEntity = em.create( organizationEntity );
- UUID applicationId = setup.getEmf().createApplication( orgName, appName );
+ Entity appInfo = setup.getEmf().createApplicationV2( orgName, appName );
+ UUID applicationId = UUIDUtils.tryExtractUUID(
+ appInfo.getProperty(PROPERTY_APPLICATION_ID).toString());
Map<String, Object> properties = new LinkedHashMap<String, Object>();
properties.put( "name", orgName + "/" + appName );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/285230f3/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 e0d3ffb..6681b2c 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
@@ -42,6 +42,7 @@ import org.apache.usergrid.persistence.index.query.Query.Level;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import org.apache.usergrid.utils.UUIDUtils;
+import static org.apache.usergrid.persistence.Schema.PROPERTY_APPLICATION_ID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -388,8 +389,10 @@ public class EntityManagerIT extends AbstractCoreIT {
organizationEntity.setProperty( "name", "testCounterOrg" );
organizationEntity = em.create( organizationEntity );
- UUID applicationId = setup.getEmf().createApplication(
+ Entity appInfo = setup.getEmf().createApplicationV2(
"testCounterOrg", "testEntityCounters" + UUIDGenerator.newTimeUUID() );
+ UUID applicationId = UUIDUtils.tryExtractUUID(
+ appInfo.getProperty(PROPERTY_APPLICATION_ID).toString());
Map<String, Object> properties = new LinkedHashMap<String, Object>();
properties.put( "name", "testEntityCounters" );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/285230f3/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 08267ee..d554f45 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
@@ -24,6 +24,7 @@ import java.util.Map;
import java.util.UUID;
import org.apache.usergrid.persistence.*;
+import org.apache.usergrid.utils.UUIDUtils;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -45,6 +46,7 @@ import rx.functions.Func2;
import javax.annotation.concurrent.NotThreadSafe;
+import static org.apache.usergrid.persistence.Schema.PROPERTY_APPLICATION_ID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@@ -82,7 +84,10 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
public UUID createApplication( String organizationName, String applicationName ) throws Exception {
- return emf.createApplication( organizationName, applicationName );
+ Entity appInfo = emf.createApplicationV2(organizationName, applicationName);
+ UUID appId = UUIDUtils.tryExtractUUID(
+ appInfo.getProperty(PROPERTY_APPLICATION_ID).toString());
+ return appId;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/285230f3/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..5145b65 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
@@ -59,6 +59,7 @@ import static org.apache.usergrid.TestHelper.uniqueEmail;
import static org.apache.usergrid.TestHelper.uniqueOrg;
import static org.apache.usergrid.TestHelper.uniqueUsername;
import static org.apache.usergrid.persistence.Schema.DICTIONARY_CREDENTIALS;
+import static org.apache.usergrid.persistence.Schema.PROPERTY_APPLICATION_ID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -637,7 +638,9 @@ public class ManagementServiceIT {
String orgName = uniqueOrg();
String appName = uniqueApp();
- UUID appId = setup.getEmf().createApplication( orgName, appName );
+ Entity appInfo = setup.getEmf().createApplicationV2( orgName, appName );
+ UUID appId = UUIDUtils.tryExtractUUID(
+ appInfo.getProperty(PROPERTY_APPLICATION_ID).toString());
User user = new User();
user.setActivated( true );
@@ -681,7 +684,9 @@ public class ManagementServiceIT {
String orgName = "testAppUserPasswordChangeShaType"+newUUIDString();
String appName = "testAppUserPasswordChangeShaType"+newUUIDString();
- UUID appId = setup.getEmf().createApplication( orgName, appName );
+ Entity appInfo = setup.getEmf().createApplicationV2(orgName, appName);
+ UUID appId = UUIDUtils.tryExtractUUID(
+ appInfo.getProperty(PROPERTY_APPLICATION_ID).toString());
User user = new User();
user.setActivated( true );
@@ -740,7 +745,9 @@ public class ManagementServiceIT {
String orgName = uniqueOrg();
String appName = uniqueApp();
- UUID appId = setup.getEmf().createApplication( orgName, appName );
+ Entity appInfo = setup.getEmf().createApplicationV2( orgName, appName );
+ UUID appId = UUIDUtils.tryExtractUUID(
+ appInfo.getProperty(PROPERTY_APPLICATION_ID).toString());
User user = new User();
user.setActivated( true );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/285230f3/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
index 3a6d8f9..0e73a82 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
@@ -28,6 +28,7 @@ import com.google.common.util.concurrent.Service;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.usergrid.batch.service.JobSchedulerService;
+import org.apache.usergrid.utils.UUIDUtils;
import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
@@ -61,6 +62,7 @@ import com.google.inject.Module;
import static org.apache.usergrid.TestHelper.newUUIDString;
import static org.apache.usergrid.TestHelper.uniqueApp;
import static org.apache.usergrid.TestHelper.uniqueOrg;
+import static org.apache.usergrid.persistence.Schema.PROPERTY_APPLICATION_ID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -404,10 +406,12 @@ public class ExportServiceIT {
f.deleteOnExit();
- UUID appId = setup.getEmf().createApplication( orgName, appName );
+ Entity appInfo = setup.getEmf().createApplicationV2(orgName, appName);
+ UUID applicationId = UUIDUtils.tryExtractUUID(
+ appInfo.getProperty(PROPERTY_APPLICATION_ID).toString());
- EntityManager em = setup.getEmf().getEntityManager( appId );
+ EntityManager em = setup.getEmf().getEntityManager( applicationId );
//intialize user object to be posted
Map<String, Object> userProperties = null;
Entity[] entity;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/285230f3/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java b/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
index c4603ff..cc05451 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/ServiceFactoryIT.java
@@ -19,6 +19,8 @@ package org.apache.usergrid.services;
import java.util.UUID;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.utils.UUIDUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -28,6 +30,7 @@ import org.apache.usergrid.services.simple.SimpleService;
import static org.apache.usergrid.TestHelper.uniqueApp;
import static org.apache.usergrid.TestHelper.uniqueOrg;
+import static org.apache.usergrid.persistence.Schema.PROPERTY_APPLICATION_ID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -42,7 +45,10 @@ public class ServiceFactoryIT extends AbstractServiceIT {
public void testPackagePrefixes() throws Exception {
logger.info( "test package prefixes" );
- UUID applicationId = setup.getEmf().createApplication(uniqueOrg(), uniqueApp() );
+ Entity appInfo = setup.getEmf().createApplicationV2(uniqueOrg(), uniqueApp());
+ UUID applicationId = UUIDUtils.tryExtractUUID(
+ appInfo.getProperty(PROPERTY_APPLICATION_ID).toString());
+
ServiceManager sm = setup.getSmf().getServiceManager( applicationId );
Service service = sm.getService( "simple" );
assertEquals( "/simple", service.getServiceType() );