You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/02/22 13:55:47 UTC

[GitHub] [nifi] turcsanyip commented on a change in pull request #4813: NIFI-8030: Added property to ReportLineageToAtlas to configure file/d…

turcsanyip commented on a change in pull request #4813:
URL: https://github.com/apache/nifi/pull/4813#discussion_r580266652



##########
File path: nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/provenance/FilesystemPathsLevel.java
##########
@@ -0,0 +1,21 @@
+/*
+ * 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.nifi.atlas.provenance;
+
+public enum FilesystemPathsLevel {
+    File, Directory

Review comment:
       done

##########
File path: nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/provenance/analyzer/FilePath.java
##########
@@ -56,11 +59,18 @@ public DataSetRefs analyze(AnalysisContext context, ProvenanceEventRecord event)
             final String hostname = StringUtils.isEmpty(uriHost) ? InetAddress.getLocalHost().getHostName() : uriHost;
             namespace = context.getNamespaceResolver().fromHostNames(hostname);
         } catch (UnknownHostException e) {
-            logger.warn("Failed to get localhost name due to " + e, e);
+            LOGGER.warn("Failed to get localhost name due to " + e, e);
             return null;
         }
 
-        final String path = uri.getPath();
+        final String path;
+        if (context.getFilesystemPathsLevel() == FilesystemPathsLevel.Directory) {
+            final String dirPath = StringUtils.substringBeforeLast(uri.getPath(), PATH_SEPARATOR);
+            path = dirPath.isEmpty() ? PATH_SEPARATOR : dirPath;
+        } else {
+            path = uri.getPath();
+        }
+
         ref.set(ATTR_NAME, path);
         ref.set(ATTR_PATH, path);

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org