From 57947d64cd3ac4602d9376595cbc39c2578bb9fb Mon Sep 17 00:00:00 2001 From: Koji Kawamura Date: Thu, 14 Dec 2017 11:22:41 +0900 Subject: [PATCH] NIFI-4694: Make PutSFTP Disable Directory Listing a normal property. This closes #2338. --- .../apache/nifi/processors/standard/PutSFTP.java | 9 +-------- .../processors/standard/util/SFTPTransfer.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutSFTP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutSFTP.java index 48cfc269e7..fbaeba455b 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutSFTP.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutSFTP.java @@ -54,6 +54,7 @@ public class PutSFTP extends PutFileTransfer { properties.add(SFTPTransfer.PRIVATE_KEY_PASSPHRASE); properties.add(SFTPTransfer.REMOTE_PATH); properties.add(SFTPTransfer.CREATE_DIRECTORY); + properties.add(SFTPTransfer.DISABLE_DIRECTORY_LISTING); properties.add(SFTPTransfer.BATCH_SIZE); properties.add(SFTPTransfer.CONNECTION_TIMEOUT); properties.add(SFTPTransfer.DATA_TIMEOUT); @@ -77,14 +78,6 @@ public class PutSFTP extends PutFileTransfer { return properties; } - @Override - protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) { - if (SFTPTransfer.DISABLE_DIRECTORY_LISTING.getName().equalsIgnoreCase(propertyDescriptorName)) { - return SFTPTransfer.DISABLE_DIRECTORY_LISTING; - } - return super.getSupportedDynamicPropertyDescriptor(propertyDescriptorName); - } - @Override protected SFTPTransfer getFileTransfer(final ProcessContext context) { return new SFTPTransfer(context, getLogger()); diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java index 0f287b4ad9..99de60cd94 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java @@ -96,17 +96,22 @@ public class SFTPTransfer implements FileTransfer { .build(); /** - * Dynamic property which is used to decide if the {@link #ensureDirectoryExists(FlowFile, File)} method should perform a {@link ChannelSftp#ls(String)} before calling + * Property which is used to decide if the {@link #ensureDirectoryExists(FlowFile, File)} method should perform a {@link ChannelSftp#ls(String)} before calling * {@link ChannelSftp#mkdir(String)}. In most cases, the code should call ls before mkdir, but some weird permission setups (chmod 100) on a directory would cause the 'ls' to throw a permission * exception. - *

- * This property is dynamic until deemed a worthy inclusion as proper. */ public static final PropertyDescriptor DISABLE_DIRECTORY_LISTING = new PropertyDescriptor.Builder() .name("Disable Directory Listing") - .description("Disables directory listings before operations which might fail, such as configurations which create directory structures.") + .description("If set to 'true', directory listing is not performed prior to create missing directories." + + " By default, this processor executes a directory listing command" + + " to see target directory existence before creating missing directories." + + " However, there are situations that you might need to disable the directory listing such as followings." + + " Directory listing might fail with some permission setups (e.g. chmod 100) on a directory." + + " Also, if any other SFTP client created the directory after this processor performed a listing" + + " and before a directory creation request by this processor is finished," + + " then an error is returned because the directory already exists.") .addValidator(StandardValidators.BOOLEAN_VALIDATOR) - .dynamic(true) + .allowableValues("true", "false") .defaultValue("false") .build();