usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [05/22] incubator-usergrid git commit: rename vars
Date Tue, 26 May 2015 18:13:04 GMT
rename vars


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

Branch: refs/heads/USERGRID-608
Commit: e3ba2b0bca060b59c854e82502bade67ce01ae77
Parents: f5cb788
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed May 13 10:35:18 2015 -0700
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed May 13 10:35:18 2015 -0700

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      | 77 ++++++++++----------
 .../cassandra/ManagementServiceImpl.java        |  3 +-
 2 files changed, 38 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e3ba2b0b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index fb66b97..bd3d137 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -19,6 +19,8 @@ package org.apache.usergrid.corepersistence;
 
 import java.util.*;
 
+import org.apache.usergrid.persistence.graph.*;
+import org.apache.usergrid.utils.UUIDUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.Assert;
@@ -48,10 +50,6 @@ import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.entities.Group;
 import org.apache.usergrid.persistence.entities.User;
-import org.apache.usergrid.persistence.graph.Edge;
-import org.apache.usergrid.persistence.graph.GraphManager;
-import org.apache.usergrid.persistence.graph.SearchByEdge;
-import org.apache.usergrid.persistence.graph.SearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleEdge;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
@@ -270,11 +268,11 @@ public class CpRelationManager implements RelationManager {
 
     @SuppressWarnings( "unchecked" )
     @Override
-    public boolean isCollectionMember( String collName, EntityRef entity ) throws Exception
{
+    public boolean isCollectionMember( String collectionName, EntityRef entity ) throws Exception
{
 
         Id entityId = new SimpleId( entity.getUuid(), entity.getType() );
 
-        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName(collName);
+        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName(collectionName);
 
         logger.debug( "isCollectionMember(): Checking for edge type {} from {}:{} to {}:{}",
new Object[] {
             edgeType, headEntity.getType(), headEntity.getUuid(), entity.getType(), entity.getUuid()
@@ -313,7 +311,6 @@ public class CpRelationManager implements RelationManager {
     public Results getCollection( String collectionName, UUID startResult, int count, Level
resultsLevel,
                                   boolean reversed ) throws Exception {
 
-
         final String ql;
 
         if ( startResult != null ) {
@@ -332,35 +329,35 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public Results getCollection( String collName, Query query, Level level ) throws Exception
{
+    public Results getCollection( String collectionName, Query query, Level level ) throws
Exception {
 
-        return searchCollection( collName, query );
+        return searchCollection( collectionName, query );
     }
 
 
     // add to a named collection of the head entity
     @Override
-    public Entity addToCollection( String collName, EntityRef itemRef ) throws Exception
{
+    public Entity addToCollection( String collectionName, EntityRef itemRef ) throws Exception
{
 
-        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(),
collName );
+        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(),
collectionName );
         if ( ( collection != null ) && !collection.getType().equals( itemRef.getType()
) ) {
             return null;
         }
 
-        return addToCollection( collName, itemRef, ( collection != null && collection.getLinkedCollection()
!= null ) );
+        return addToCollection( collectionName, itemRef, ( collection != null &&
collection.getLinkedCollection() != null ) );
     }
 
 
-    public Entity addToCollection( String collName, EntityRef itemRef, boolean connectBack
) throws Exception {
+    public Entity addToCollection( String collectionName, EntityRef itemRef, boolean connectBack
) throws Exception {
 
         Id entityId = new SimpleId( itemRef.getUuid(), itemRef.getType() );
         org.apache.usergrid.persistence.model.entity.Entity memberEntity = ( ( CpEntityManager
) em ).load( entityId );
 
-        return addToCollection( collName, itemRef, memberEntity, connectBack );
+        return addToCollection( collectionName, itemRef, memberEntity, connectBack );
     }
 
 
-    public Entity addToCollection( final String collName, final EntityRef itemRef,
+    public Entity addToCollection( final String collectionName, final EntityRef itemRef,
                                    final org.apache.usergrid.persistence.model.entity.Entity
memberEntity,
                                    final boolean connectBack ) throws Exception {
 
@@ -377,7 +374,7 @@ public class CpRelationManager implements RelationManager {
             return null;
         }
 
-        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(),
collName );
+        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(),
collectionName );
         if ( ( collection != null ) && !collection.getType().equals( itemRef.getType()
) ) {
             return null;
         }
@@ -396,7 +393,7 @@ public class CpRelationManager implements RelationManager {
 
 
         // create graph edge connection from head entity to member entity
-        final Edge edge = createCollectionEdge( cpHeadEntity.getId(), collName, memberEntity.getId()
);
+        final Edge edge = createCollectionEdge( cpHeadEntity.getId(), collectionName, memberEntity.getId()
);
         GraphManager gm = managerCache.getGraphManager( applicationScope );
         gm.writeEdge( edge ).toBlocking().last();
 
@@ -412,7 +409,7 @@ public class CpRelationManager implements RelationManager {
 
         if ( logger.isDebugEnabled() ) {
             logger.debug( "Added entity {}:{} to collection {}", new Object[] {
-                itemRef.getUuid().toString(), itemRef.getType(), collName
+                itemRef.getUuid().toString(), itemRef.getType(), collectionName
             } );
         }
 
@@ -422,11 +419,11 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public Entity addToCollections( List<EntityRef> owners, String collName ) throws
Exception {
+    public Entity addToCollections( List<EntityRef> owners, String collectionName )
throws Exception {
 
         // TODO: this addToCollections() implementation seems wrong.
         for ( EntityRef eref : owners ) {
-            addToCollection( collName, eref );
+            addToCollection( collectionName, eref );
         }
 
         return null;
@@ -434,12 +431,12 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public Entity createItemInCollection( String collName, String itemType, Map<String,
Object> properties )
+    public Entity createItemInCollection( String collectionName, String itemType, Map<String,
Object> properties )
         throws Exception {
 
         if ( headEntity.getUuid().equals( applicationId ) ) {
             if ( itemType.equals( TYPE_ENTITY ) ) {
-                itemType = singularize( collName );
+                itemType = singularize( collectionName );
             }
 
             if ( itemType.equals( TYPE_ROLE ) ) {
@@ -453,13 +450,13 @@ public class CpRelationManager implements RelationManager {
             return em.create( itemType, properties );
         }
 
-        else if ( headEntity.getType().equals( Group.ENTITY_TYPE ) && ( collName.equals(
COLLECTION_ROLES ) ) ) {
+        else if ( headEntity.getType().equals( Group.ENTITY_TYPE ) && ( collectionName.equals(
COLLECTION_ROLES ) ) ) {
             UUID groupId = headEntity.getUuid();
             String roleName = ( String ) properties.get( PROPERTY_NAME );
             return em.createGroupRole( groupId, roleName, ( Long ) properties.get( PROPERTY_INACTIVITY
) );
         }
 
-        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(),
collName );
+        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(),
collectionName );
         if ( ( collection != null ) && !collection.getType().equals( itemType ) )
{
             return null;
         }
@@ -470,11 +467,11 @@ public class CpRelationManager implements RelationManager {
 
         if ( itemEntity != null ) {
 
-            addToCollection( collName, itemEntity );
+            addToCollection( collectionName, itemEntity );
 
             if ( collection != null && collection.getLinkedCollection() != null )
{
                 Id itemEntityId = new SimpleId( itemEntity.getUuid(), itemEntity.getType()
);
-                final Edge edge = createCollectionEdge( cpHeadEntity.getId(), collName, itemEntityId
);
+                final Edge edge = createCollectionEdge( cpHeadEntity.getId(), collectionName,
itemEntityId );
 
                 GraphManager gm = managerCache.getGraphManager( applicationScope );
                 gm.writeEdge( edge );
@@ -486,11 +483,11 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public void removeFromCollection( String collName, EntityRef itemRef ) throws Exception
{
+    public void removeFromCollection( String collectionName, EntityRef itemRef ) throws Exception
{
 
         // special handling for roles collection of the application
         if ( headEntity.getUuid().equals( applicationId ) ) {
-            if ( collName.equals( COLLECTION_ROLES ) ) {
+            if ( collectionName.equals( COLLECTION_ROLES ) ) {
                 Entity itemEntity = em.get( itemRef );
                 if ( itemEntity != null ) {
                     RoleRef roleRef = SimpleRoleRef.forRoleEntity( itemEntity );
@@ -522,7 +519,7 @@ public class CpRelationManager implements RelationManager {
 
 
         //run our delete
-        final Edge collectionToItemEdge = createCollectionEdge( cpHeadEntity.getId(), collName,
memberEntity.getId() );
+        final Edge collectionToItemEdge = createCollectionEdge( cpHeadEntity.getId(), collectionName,
memberEntity.getId() );
         gm.markEdge( collectionToItemEdge ).toBlocking().last();
 
 
@@ -535,7 +532,7 @@ public class CpRelationManager implements RelationManager {
         final EntityIndexBatch batch = ei.createBatch();
 
         // remove item from collection index
-        SearchEdge indexScope = createCollectionSearchEdge( cpHeadEntity.getId(), collName
);
+        SearchEdge indexScope = createCollectionSearchEdge( cpHeadEntity.getId(), collectionName
);
 
         batch.deindex( indexScope, memberEntity );
 
@@ -546,7 +543,7 @@ public class CpRelationManager implements RelationManager {
         // special handling for roles collection of a group
         if ( headEntity.getType().equals( Group.ENTITY_TYPE ) ) {
 
-            if ( collName.equals( COLLECTION_ROLES ) ) {
+            if ( collectionName.equals( COLLECTION_ROLES ) ) {
                 String path = ( String ) ( ( Entity ) itemRef ).getMetadata( "path" );
 
                 if ( path.startsWith( "/roles/" ) ) {
@@ -599,20 +596,20 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public Results searchCollection( String collName, Query query ) throws Exception {
+    public Results searchCollection( String collectionName, Query query ) throws Exception
{
 
         if ( query == null ) {
             query = new Query();
-            query.setCollection( collName );
+            query.setCollection( collectionName );
         }
 
         headEntity = em.validate( headEntity );
 
-        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(),
collName );
+        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(),
collectionName );
 
         if ( collection == null ) {
             throw new RuntimeException(
-                "Cannot find collection-info for '" + collName + "' of " + headEntity.getType()
+ ":" + headEntity
+                "Cannot find collection-info for '" + collectionName + "' of " + headEntity.getType()
+ ":" + headEntity
                     .getUuid() );
         }
 
@@ -627,18 +624,18 @@ public class CpRelationManager implements RelationManager {
 
         //set our fields applicable to both operations
         readPipelineBuilder.withCursor(query.getCursor());
-        readPipelineBuilder.withLimit( Optional.of( query.getLimit() ));
+        readPipelineBuilder.withLimit( Optional.of(query.getLimit()));
 
         //TODO, this should be removed when the CP relation manager is removed
         readPipelineBuilder.setStartId( cpHeadEntity.getId() );
 
         if ( query.isGraphSearch() ) {
-            readPipelineBuilder.getCollection( collName );
+            readPipelineBuilder.getCollection( collectionName );
         }
         else {
             final String entityType = collection.getType();
 
-            readPipelineBuilder.getCollectionWithQuery( collName, entityType, query.getQl().get()
);
+            readPipelineBuilder.getCollectionWithQuery( collectionName, entityType, query.getQl().get()
);
         }
 
 
@@ -648,14 +645,14 @@ public class CpRelationManager implements RelationManager {
     }
 
     @Override
-    public Results searchCollectionConsistent( String collName, Query query, int expectedResults
) throws Exception {
+    public Results searchCollectionConsistent( String collectionName, Query query, int expectedResults
) throws Exception {
         Results results;
         long maxLength = entityManagerFig.pollForRecordsTimeout();
         long sleepTime = entityManagerFig.sleep();
         boolean found;
         long current = System.currentTimeMillis(), length = 0;
         do {
-            results = searchCollection(collName, query);
+            results = searchCollection(collectionName, query);
             length = System.currentTimeMillis() - current;
             found = expectedResults == results.size();
             if(found){

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e3ba2b0b/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 ebc1008..7909439 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
@@ -540,8 +540,7 @@ public class ManagementServiceImpl implements ManagementService {
         organizationEntity = em.create( organizationEntity );
 
         em.addToCollection( organizationEntity, "users", new SimpleEntityRef( User.ENTITY_TYPE,
user.getUuid() ) );
-      //  em.addToCollection( new SimpleEntityRef( User.ENTITY_TYPE, user.getUuid() ), Schema.COLLECTION_GROUPS,
organizationEntity );
-
+//        em.addToCollection( new SimpleEntityRef( User.ENTITY_TYPE, user.getUuid() ), Schema.COLLECTION_GROUPS,
organizationEntity );
 
         writeUserToken( smf.getManagementAppId(), organizationEntity, encryptionService
                 .plainTextCredentials( generateOAuthSecretKey( AuthPrincipalType.ORGANIZATION
), user.getUuid(),


Mime
View raw message