Return-Path: X-Original-To: apmail-usergrid-commits-archive@minotaur.apache.org Delivered-To: apmail-usergrid-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8F0651773A for ; Tue, 31 Mar 2015 22:57:46 +0000 (UTC) Received: (qmail 43513 invoked by uid 500); 31 Mar 2015 22:57:46 -0000 Delivered-To: apmail-usergrid-commits-archive@usergrid.apache.org Received: (qmail 43445 invoked by uid 500); 31 Mar 2015 22:57:46 -0000 Mailing-List: contact commits-help@usergrid.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@usergrid.incubator.apache.org Delivered-To: mailing list commits@usergrid.incubator.apache.org Received: (qmail 42708 invoked by uid 99); 31 Mar 2015 22:57:45 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Mar 2015 22:57:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9F02BE2F27; Tue, 31 Mar 2015 22:57:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: toddnine@apache.org To: commits@usergrid.apache.org Date: Tue, 31 Mar 2015 22:58:02 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [18/50] incubator-usergrid git commit: Use constants for Group type and collection names instead of quoted strings. Use constants for Group type and collection names instead of quoted strings. Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/055eb916 Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/055eb916 Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/055eb916 Branch: refs/heads/USERGRID-509 Commit: 055eb91685f0f6ec0e2356964e4ab49119d52230 Parents: fd43a1d Author: Dave Johnson Authored: Fri Mar 13 11:42:55 2015 -0400 Committer: Dave Johnson Committed: Fri Mar 13 11:42:55 2015 -0400 ---------------------------------------------------------------------- .../corepersistence/CpEntityManagerFactory.java | 5 +-- .../cassandra/ManagementServiceImpl.java | 42 ++++++++++---------- 2 files changed, 24 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/055eb916/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 36bbd12..010672e 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 @@ -634,7 +634,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application // refresh special indexes without calling EntityManager refresh because stack overflow maybeCreateIndexes(); - // system app for ( EntityIndex index : getManagementIndexes() ) { index.refresh(); @@ -643,7 +642,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application private void maybeCreateIndexes() { - // system app if ( indexInitialized.getAndSet( true ) ) { return; } @@ -684,7 +682,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application @Override public void rebuildInternalIndexes( ProgressObserver po ) throws Exception { - rebuildApplicationIndexes( getManagementAppId(), po ); + rebuildApplicationIndexes( CpNamingUtils.SYSTEM_APP_ID, po); + rebuildApplicationIndexes( CpNamingUtils.MANAGEMENT_APPLICATION_ID, po ); } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/055eb916/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java ---------------------------------------------------------------------- diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java index ab70810..43617c4 100644 --- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java +++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java @@ -386,7 +386,7 @@ public class ManagementServiceImpl implements ManagementService { } } ); - sm.newRequest( ServiceAction.POST, parameters( "groups", organizationId, "activities" ), payload( properties ) ) + sm.newRequest( ServiceAction.POST, parameters( Schema.COLLECTION_GROUPS, organizationId, "activities" ), payload( properties ) ) .execute().getEntity(); } @@ -394,7 +394,7 @@ public class ManagementServiceImpl implements ManagementService { @Override public ServiceResults getOrganizationActivity( OrganizationInfo organization ) throws Exception { ServiceManager sm = smf.getServiceManager( smf.getManagementAppId() ); - return sm.newRequest( ServiceAction.GET, parameters( "groups", organization.getUuid(), "feed" ) ).execute(); + return sm.newRequest( ServiceAction.GET, parameters( Schema.COLLECTION_GROUPS, organization.getUuid(), "feed" ) ).execute(); } @@ -403,7 +403,7 @@ public class ManagementServiceImpl implements ManagementService { throws Exception { ServiceManager sm = smf.getServiceManager( smf.getManagementAppId() ); return sm.newRequest( ServiceAction.GET, - parameters( "groups", organization.getUuid(), "users", user.getUuid(), "feed" ) ).execute(); + parameters( Schema.COLLECTION_GROUPS, organization.getUuid(), "users", user.getUuid(), "feed" ) ).execute(); } @@ -452,7 +452,7 @@ public class ManagementServiceImpl implements ManagementService { * node is trying to set the property do a different value */ Lock groupLock = - getUniqueUpdateLock( lockManager, smf.getManagementAppId(), organizationName, "groups", PROPERTY_PATH ); + getUniqueUpdateLock( lockManager, smf.getManagementAppId(), organizationName, Schema.COLLECTION_GROUPS, PROPERTY_PATH ); Lock userLock = getUniqueUpdateLock( lockManager, smf.getManagementAppId(), username, "users", "username" ); @@ -467,8 +467,8 @@ public class ManagementServiceImpl implements ManagementService { userLock.lock(); emailLock.lock(); EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); - if ( !em.isPropertyValueUniqueForEntity( "group", PROPERTY_PATH, organizationName ) ) { - throw new DuplicateUniquePropertyExistsException( "group", PROPERTY_PATH, organizationName ); + if ( !em.isPropertyValueUniqueForEntity( Group.ENTITY_TYPE, PROPERTY_PATH, organizationName ) ) { + throw new DuplicateUniquePropertyExistsException( Group.ENTITY_TYPE, PROPERTY_PATH, organizationName ); } if ( !validateAdminInfo( username, name, email, password ) ) { return null; @@ -558,11 +558,12 @@ public class ManagementServiceImpl implements ManagementService { return null; } - Lock groupLock = - getUniqueUpdateLock( lockManager, smf.getManagementAppId(), organizationName, "groups", PROPERTY_PATH ); - EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); - if ( !em.isPropertyValueUniqueForEntity( "group", PROPERTY_PATH, organizationName ) ) { - throw new DuplicateUniquePropertyExistsException( "group", PROPERTY_PATH, organizationName ); + Lock groupLock = getUniqueUpdateLock( + lockManager, smf.getManagementAppId(), organizationName, Schema.COLLECTION_GROUPS, PROPERTY_PATH ); + + EntityManager em = emf.getEntityManager(smf.getManagementAppId()); + if ( !em.isPropertyValueUniqueForEntity( Group.ENTITY_TYPE, PROPERTY_PATH, organizationName ) ) { + throw new DuplicateUniquePropertyExistsException( Group.ENTITY_TYPE, PROPERTY_PATH, organizationName ); } try { groupLock.lock(); @@ -599,8 +600,8 @@ public class ManagementServiceImpl implements ManagementService { Map properties ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); - if ( !em.isPropertyValueUniqueForEntity( "group", PROPERTY_PATH, organizationInfo.getName() ) ) { - throw new DuplicateUniquePropertyExistsException( "group", PROPERTY_PATH, organizationInfo.getName() ); + if ( !em.isPropertyValueUniqueForEntity( Group.ENTITY_TYPE, PROPERTY_PATH, organizationInfo.getName() ) ) { + throw new DuplicateUniquePropertyExistsException( Group.ENTITY_TYPE, PROPERTY_PATH, organizationInfo.getName() ); } if ( properties == null ) { properties = new HashMap(); @@ -660,9 +661,9 @@ public class ManagementServiceImpl implements ManagementService { public List getOrganizations( UUID startResult, int count ) throws Exception { // still need the bimap to search for existing BiMap organizations = HashBiMap.create(); - EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); + EntityManager em = emf.getEntityManager(smf.getManagementAppId()); Results results = - em.getCollection( em.getApplicationRef(), "groups", startResult, count, Level.ALL_PROPERTIES, false ); + em.getCollection(em.getApplicationRef(), Schema.COLLECTION_GROUPS, startResult, count, Level.ALL_PROPERTIES, false); List orgs = new ArrayList( results.size() ); OrganizationInfo orgInfo; for ( Entity entity : results.getEntities() ) { @@ -715,7 +716,7 @@ public class ManagementServiceImpl implements ManagementService { } EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); - EntityRef ref = em.getAlias( "group", organizationName ); + EntityRef ref = em.getAlias( Group.ENTITY_TYPE, organizationName ); if ( ref == null ) { return null; } @@ -1205,7 +1206,7 @@ public class ManagementServiceImpl implements ManagementService { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); Results orgResults = em.getCollection( new SimpleEntityRef( User.ENTITY_TYPE, userId ), - "groups", null, 10000, Level.REFS, false ); + Schema.COLLECTION_GROUPS, null, 10000, Level.REFS, false ); logger.debug( " orgResults.size() = " + orgResults.size() ); @@ -1445,8 +1446,9 @@ public class ManagementServiceImpl implements ManagementService { BiMap organizations = HashBiMap.create(); EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); - Results results = em.getCollection( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "groups", null, 10000, - Level.ALL_PROPERTIES, false ); + Results results = em.getCollection( + new SimpleEntityRef( User.ENTITY_TYPE, userId ), Schema.COLLECTION_GROUPS, null, 10000, + Level.ALL_PROPERTIES, false ); String path = null; @@ -1712,7 +1714,7 @@ public class ManagementServiceImpl implements ManagementService { Results r = em.getConnectingEntities( new SimpleEntityRef(CpNamingUtils.APPLICATION_INFO, applicationInfoId), - "owns", "group", Level.ALL_PROPERTIES ); + "owns", Group.ENTITY_TYPE, Level.ALL_PROPERTIES ); Entity entity = r.getEntity(); if ( entity != null ) {