From 345b8bd05965f118a450a2ff89637889db72bbe9 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Fri, 19 Jan 2024 15:48:16 -0500 Subject: [PATCH] NIFI-12647 Added MultiProcessorUseCase for ListFile/FetchFile together This closes #8276 Signed-off-by: David Handermann --- .../nifi/processors/standard/FetchFile.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FetchFile.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FetchFile.java index e16eec7189..8e90fe9815 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FetchFile.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FetchFile.java @@ -23,6 +23,8 @@ import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; import org.apache.nifi.annotation.behavior.Restricted; import org.apache.nifi.annotation.behavior.Restriction; import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.MultiProcessorUseCase; +import org.apache.nifi.annotation.documentation.ProcessorConfiguration; import org.apache.nifi.annotation.documentation.SeeAlso; import org.apache.nifi.annotation.documentation.Tags; import org.apache.nifi.components.AllowableValue; @@ -71,6 +73,50 @@ import java.util.concurrent.TimeUnit; explanation = "Provides operator the ability to delete any file that NiFi has access to.") } ) +@MultiProcessorUseCase( + description = "Ingest all files from a directory into NiFi", + keywords = {"local", "files", "filesystem", "ingest", "ingress", "get", "source", "input", "fetch"}, + configurations = { + @ProcessorConfiguration(processorClass = ListFile.class, + configuration = """ + Configure the "Input Directory" property to point to the directory that you want to ingest files from. + Set the "Input Directory Location" property to "Local" + Optionally, set "Minimum File Age" to a small value such as "1 min" to avoid ingesting files that are still being written to. + + Connect the 'success' Relationship to the FetchFile processor. + """ + ), + @ProcessorConfiguration(processorClass = FetchFile.class, + configuration = """ + Set the "File to Fetch" property to `${absolute.path}/${filename}` + Set the "Completion Strategy" property to `None` + """ + ) + } +) +@MultiProcessorUseCase( + description = "Ingest specific files from a directory into NiFi, filtering on filename", + keywords = {"local", "files", "filesystem", "ingest", "ingress", "get", "source", "input", "fetch", "filter"}, + configurations = { + @ProcessorConfiguration(processorClass = ListFile.class, + configuration = """ + Configure the "Input Directory" property to point to the directory that you want to ingest files from. + Set the "Input Directory Location" property to "Local" + Set the "File Filter" property to a Regular Expression that matches the filename (without path) of the files that you want to ingest. \ + For example, to ingest all .jpg files, set the value to `.*\\.jpg` + Optionally, set "Minimum File Age" to a small value such as "1 min" to avoid ingesting files that are still being written to. + + Connect the 'success' Relationship to the FetchFile processor. + """ + ), + @ProcessorConfiguration(processorClass = FetchFile.class, + configuration = """ + Set the "File to Fetch" property to `${absolute.path}/${filename}` + Set the "Completion Strategy" property to `None` + """ + ) + } +) public class FetchFile extends AbstractProcessor { static final AllowableValue COMPLETION_NONE = new AllowableValue("None", "None", "Leave the file as-is"); static final AllowableValue COMPLETION_MOVE = new AllowableValue("Move File", "Move File", "Moves the file to the directory specified by the property");