usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [4/6] usergrid git commit: Readded previous put by Name logic for the case that the entity ref is null. Also fixed some of the existing functionality which was included in the null check.
Date Thu, 04 Feb 2016 00:27:10 GMT
Readded previous put by Name logic for the case that the entity ref is null. Also fixed some
of the existing functionality which was included in the null check.


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

Branch: refs/heads/1.x
Commit: b09a5e4d4d4638a1537c67fafaa4bdc5fd667c74
Parents: 234472c
Author: George Reyes <grey@apache.org>
Authored: Fri Jan 29 16:45:10 2016 -0800
Committer: George Reyes <grey@apache.org>
Committed: Fri Jan 29 16:45:10 2016 -0800

----------------------------------------------------------------------
 .../usergrid/services/AbstractCollectionService.java  | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/b09a5e4d/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
b/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
index 72625be..2ad51f2 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
@@ -291,6 +291,20 @@ public class AbstractCollectionService extends AbstractService {
     public ServiceResults putItemByName( ServiceContext context, String name ) throws Exception
{
 
         EntityRef ref = em.getAlias( getEntityType(), name );
+        if(ref == null){
+            logger.error("The following name wasn't found in entity_unique column family.
{}",name);
+
+            checkPermissionsForCollection(context);
+
+            Map<String, Object> properties = context.getPayload().getProperties();
+            if ( !properties.containsKey( "name" ) || !( ( String ) properties.get( "name"
) ).trim().equalsIgnoreCase(
+                    name ) ) {
+                properties.put( "name", name );
+            }
+            Entity entity = em.create( getEntityType(), properties );
+            return new ServiceResults( this, context, Type.COLLECTION, Results.fromEntity(
entity ), null, null );
+        }
+
         return putItemById( context, ref.getUuid() );
     }
 


Mime
View raw message