Repository: ranger
Updated Branches:
  refs/heads/ranger-0.7 30b1188fe -> 29cd16cbb


RANGER-1937: Ranger tagsync should process ENTITY_CREATE notification, to 
support Atlas import feature


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

Branch: refs/heads/ranger-0.7
Commit: 29cd16cbb690d6972e7ce24558350b5dee3468ba
Parents: 30b1188
Author: Abhay Kulkarni <akulka...@hortonworks.com>
Authored: Wed Dec 20 19:41:25 2017 -0800
Committer: Abhay Kulkarni <akulka...@hortonworks.com>
Committed: Wed Dec 20 19:41:25 2017 -0800

----------------------------------------------------------------------
 .../source/atlas/AtlasNotificationMapper.java   | 37 ++++++++++----------
 1 file changed, 18 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/29cd16cb/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasNotificationMapper.java
----------------------------------------------------------------------
diff --git 
a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasNotificationMapper.java
 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasNotificationMapper.java
index f42c908..8641d60 100644
--- 
a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasNotificationMapper.java
+++ 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasNotificationMapper.java
@@ -103,26 +103,18 @@ public class AtlasNotificationMapper {
                        try {
                                IReferenceableInstance entity = 
entityNotification.getEntity();
 
-                               if (entity != null && 
AtlasResourceMapperUtil.isEntityTypeHandled(entity.getTypeName())) {
-                                       AtlasEntityWithTraits entityWithTraits 
= new AtlasEntityWithTraits(entity, entityNotification.getAllTraits());
-                                       if 
(entityNotification.getOperationType() == 
EntityNotification.OperationType.ENTITY_DELETE) {
-                                               ret = 
buildServiceTagsForEntityDeleteNotification(entityWithTraits);
-                                       } else {
-                                               if (entity.getId().getState() 
== Id.EntityState.ACTIVE) {
-                                                       ret = 
buildServiceTags(entityWithTraits, null);
-                                               } else {
-                                                       if 
(LOG.isDebugEnabled()) {
-                                                               
LOG.debug("Ignoring entityNotification for entity that is not ACTIVE: " + 
entityWithTraits);
-                                                       }
-                                               }
-                                       }
+                               AtlasEntityWithTraits entityWithTraits = new 
AtlasEntityWithTraits(entity, entityNotification.getAllTraits());
+
+                               if (entityNotification.getOperationType() == 
EntityNotification.OperationType.ENTITY_DELETE) {
+                                       ret = 
buildServiceTagsForEntityDeleteNotification(entityWithTraits);
                                } else {
-                                       
logUnhandledEntityNotification(entityNotification);
+                                       ret = 
buildServiceTags(entityWithTraits, null);
                                }
-
                        } catch (Exception exception) {
                                LOG.error("createServiceTags() failed!! ", 
exception);
                        }
+               } else {
+                       logUnhandledEntityNotification(entityNotification);
                }
                return ret;
        }
@@ -144,12 +136,11 @@ public class AtlasNotificationMapper {
 
                EntityNotification.OperationType opType = 
entityNotification.getOperationType();
 
-               if(opType != null) {
+               if (opType != null) {
                        switch (opType) {
-                               case ENTITY_CREATE: {
-                                       LOG.debug("ENTITY_CREATE notification 
is not handled, as Ranger will get necessary information from any subsequent 
TRAIT_ADDED notification");
+                               case ENTITY_CREATE:
+                                       ret = 
CollectionUtils.isNotEmpty(entityNotification.getAllTraits());
                                        break;
-                               }
                                case ENTITY_UPDATE:
                                case ENTITY_DELETE:
                                case TRAIT_ADD:
@@ -160,6 +151,14 @@ public class AtlasNotificationMapper {
                                }
                                default:
                                        LOG.error(opType + ": unknown 
notification received - not handled");
+                                       break;
+                       }
+                       if (ret) {
+                               final IReferenceableInstance entity = 
entityNotification.getEntity();
+
+                               ret = entity != null
+                                               && entity.getId().getState() == 
Id.EntityState.ACTIVE
+                                               && 
AtlasResourceMapperUtil.isEntityTypeHandled(entity.getTypeName());
                        }
                }
 

Reply via email to