Repository: ranger
Updated Branches:
  refs/heads/master b8bc69a92 -> 5d5dee08a


RANGER-1523 - Add AtlasResourceMapper implementation for Apache Storm

Signed-off-by: Colm O hEigeartaigh <cohei...@apache.org>


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

Branch: refs/heads/master
Commit: 5d5dee08a041e7366ecb9caa0e060ce4a74e0dde
Parents: b8bc69a
Author: Colm O hEigeartaigh <cohei...@apache.org>
Authored: Tue Apr 18 11:16:22 2017 +0100
Committer: Colm O hEigeartaigh <cohei...@apache.org>
Committed: Fri May 19 10:05:56 2017 +0100

----------------------------------------------------------------------
 .../source/atlas/AtlasResourceMapperUtil.java   |  1 +
 .../source/atlas/AtlasStormResourceMapper.java  | 73 ++++++++++++++++++++
 2 files changed, 74 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/5d5dee08/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasResourceMapperUtil.java
----------------------------------------------------------------------
diff --git 
a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasResourceMapperUtil.java
 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasResourceMapperUtil.java
index f9f0eaf..5227d8c 100644
--- 
a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasResourceMapperUtil.java
+++ 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasResourceMapperUtil.java
@@ -89,6 +89,7 @@ public class AtlasResourceMapperUtil {
                
mapperNames.add("org.apache.ranger.tagsync.source.atlas.AtlasHdfsResourceMapper");
                
mapperNames.add("org.apache.ranger.tagsync.source.atlas.AtlasHbaseResourceMapper");
                
mapperNames.add("org.apache.ranger.tagsync.source.atlas.AtlasKafkaResourceMapper");
+               
mapperNames.add("org.apache.ranger.tagsync.source.atlas.AtlasStormResourceMapper");
 
                if (StringUtils.isNotBlank(customMapperNames)) {
                        for (String customMapperName : 
customMapperNames.split(MAPPER_NAME_DELIMITER)) {

http://git-wip-us.apache.org/repos/asf/ranger/blob/5d5dee08/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasStormResourceMapper.java
----------------------------------------------------------------------
diff --git 
a/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasStormResourceMapper.java
 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasStormResourceMapper.java
new file mode 100644
index 0000000..4ed01ca
--- /dev/null
+++ 
b/tagsync/src/main/java/org/apache/ranger/tagsync/source/atlas/AtlasStormResourceMapper.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ranger.tagsync.source.atlas;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.atlas.typesystem.IReferenceableInstance;
+import org.apache.commons.lang.StringUtils;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource;
+import org.apache.ranger.plugin.model.RangerServiceResource;
+
+public class AtlasStormResourceMapper extends AtlasResourceMapper {
+       public static final String ENTITY_TYPE_STORM_TOPOLOGY = 
"storm_topology";
+       public static final String RANGER_TYPE_STORM_TOPOLOGY = "topology";
+
+       public static final String ENTITY_ATTRIBUTE_QUALIFIED_NAME = 
"qualifiedName";
+
+       public static final String[] SUPPORTED_ENTITY_TYPES = { 
ENTITY_TYPE_STORM_TOPOLOGY };
+
+       public AtlasStormResourceMapper() {
+               super("storm", SUPPORTED_ENTITY_TYPES);
+       }
+
+       @Override
+       public RangerServiceResource buildResource(final IReferenceableInstance 
entity) throws Exception {
+               String qualifiedName = getEntityAttribute(entity, 
ENTITY_ATTRIBUTE_QUALIFIED_NAME, String.class);
+
+               String topology = 
getResourceNameFromQualifiedName(qualifiedName);
+
+               if(StringUtils.isEmpty(topology)) {
+                       throwExceptionWithMessage("topology not found in 
attribute '" + ENTITY_ATTRIBUTE_QUALIFIED_NAME +  "'");
+               }
+
+               String clusterName = 
getClusterNameFromQualifiedName(qualifiedName);
+
+               if(StringUtils.isEmpty(clusterName)) {
+                       clusterName = defaultClusterName;
+               }
+
+               if(StringUtils.isEmpty(clusterName)) {
+                       throwExceptionWithMessage("attribute '" + 
ENTITY_ATTRIBUTE_QUALIFIED_NAME +  "' not found in entity");
+               }
+
+               Map<String, RangerPolicyResource> elements = new HashMap<>();
+               Boolean isExcludes  = Boolean.FALSE;
+               Boolean isRecursive = Boolean.TRUE;
+
+               elements.put(RANGER_TYPE_STORM_TOPOLOGY, new 
RangerPolicyResource(topology, isExcludes, isRecursive));
+
+               String entityGuid  = entity.getId() != null ? 
entity.getId()._getId() : null;
+               String serviceName = getRangerServiceName(clusterName);
+
+               return new RangerServiceResource(entityGuid, serviceName, 
elements);
+       }
+}

Reply via email to