Repository: incubator-ranger
Updated Branches:
  refs/heads/tag-policy 2fffd0256 -> 7f018c302


RANGER-726: Fixed handling of hive_table entity notifications changes 
introduced in 0.6 Atlas

Signed-off-by: Madhan Neethiraj <[email protected]>


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

Branch: refs/heads/tag-policy
Commit: 79d4fa41f23cb0929ea4071fc2f014f4b640e4b9
Parents: 7c185e1
Author: Abhay Kulkarni <[email protected]>
Authored: Thu Nov 12 09:45:25 2015 -0800
Committer: Madhan Neethiraj <[email protected]>
Committed: Thu Nov 12 11:29:10 2015 -0800

----------------------------------------------------------------------
 .../source/atlas/AtlasNotificationMapper.java   | 60 ++++++++------------
 1 file changed, 24 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/79d4fa41/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 7925b5c..15a511d 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
@@ -48,8 +48,10 @@ class AtlasNotificationMapper {
        public static final String RANGER_TYPE_HIVE_COLUMN = "column";
 
        public static final String ENTITY_ATTRIBUTE_QUALIFIED_NAME = 
"qualifiedName";
+       public static final String 
ENTITY_ATTRIBUTE_QUALIFIED_NAME_FOR_HIVE_TABLE = "name";
        public static final String QUALIFIED_NAME_FORMAT_DELIMITER_STRING = 
"\\.";
 
+       private static final int MAX_HIERARCHY_LEVELS = 5;
 
        private static Properties properties = null;
 
@@ -297,51 +299,37 @@ class AtlasNotificationMapper {
        }
 
        static private String[] 
getQualifiedNameComponents(IReferenceableInstance entity) {
-               String ret[] = new String[5];
+               String ret[] = new String[MAX_HIERARCHY_LEVELS];
 
-               if (StringUtils.equals(entity.getTypeName(), 
ENTITY_TYPE_HIVE_DB)) {
+               String qualifiedNameAttributeName = 
StringUtils.equals(entity.getTypeName(), ENTITY_TYPE_HIVE_TABLE) ?
+                               ENTITY_ATTRIBUTE_QUALIFIED_NAME_FOR_HIVE_TABLE 
: ENTITY_ATTRIBUTE_QUALIFIED_NAME;
 
-                       String clusterName = getEntityAttribute(entity, 
"clusterName", String.class);
-                       String name = getEntityAttribute(entity, "name", 
String.class);
+               String qualifiedName = getEntityAttribute(entity, 
qualifiedNameAttributeName, String.class);
 
-                       ret[1] = clusterName;
-                       ret[2] = name;
-                       ret[3] = null;
-                       ret[0] = ret[1] + "." + ret[2];
+               String nameHierarchy[] = 
qualifiedName.split(QUALIFIED_NAME_FORMAT_DELIMITER_STRING);
 
-                       if (LOG.isDebugEnabled()) {
-                               LOG.debug("----- Entity-Id:" + 
entity.getId()._getId());
-                               LOG.debug("----- Entity-Type-Name:" + 
entity.getTypeName());
-                               LOG.debug("----- Entity-Cluster-Name:" + 
clusterName);
-                               LOG.debug("----- Entity-Name:" + name);
-                       }
-               } else {
-                       String qualifiedName = getEntityAttribute(entity, 
ENTITY_ATTRIBUTE_QUALIFIED_NAME, String.class);
-
-                       String nameHierarchy[] = 
qualifiedName.split(QUALIFIED_NAME_FORMAT_DELIMITER_STRING);
-
-                       int hierarchyLevels = nameHierarchy.length;
+               int hierarchyLevels = nameHierarchy.length;
 
-                       if (LOG.isDebugEnabled()) {
-                               LOG.debug("----- Entity-Id:" + 
entity.getId()._getId());
-                               LOG.debug("----- Entity-Type-Name:" + 
entity.getTypeName());
-                               LOG.debug("----- Entity-Qualified-Name:" + 
qualifiedName);
-                               LOG.debug("-----        
Entity-Qualified-Name-Components -----");
-                               for (int i = 0; i < hierarchyLevels; i++) {
-                                       LOG.debug("-----                Index:" 
+ i + " Value:" + nameHierarchy[i]);
-                               }
+               if (LOG.isDebugEnabled()) {
+                       LOG.debug("----- Entity-Id:" + entity.getId()._getId());
+                       LOG.debug("----- Entity-Type-Name:" + 
entity.getTypeName());
+                       LOG.debug("----- Entity-Qualified-Name:" + 
qualifiedName);
+                       LOG.debug("-----        
Entity-Qualified-Name-Components -----");
+                       for (int i = 0; i < hierarchyLevels; i++) {
+                               LOG.debug("-----                Index:" + i + " 
Value:" + nameHierarchy[i]);
                        }
+               }
 
-                       int i;
-                       for (i = 0; i < ret.length; i++) {
-                               ret[i] = null;
-                       }
-                       ret[0] = qualifiedName;
+               int i;
+               for (i = 0; i < ret.length; i++) {
+                       ret[i] = null;
+               }
+               ret[0] = qualifiedName;
 
-                       for (i = 0; i < hierarchyLevels; i++) {
-                               ret[i + 1] = nameHierarchy[i];
-                       }
+               for (i = 0; i < hierarchyLevels; i++) {
+                       ret[i + 1] = nameHierarchy[i];
                }
+
                return ret;
        }
 

Reply via email to