NIFI-673: Added sftp.listing.user attribute to FlowFiles created by ListSFTP; ensure that FetchSFTP indicates that the username supports Expression Language

This commit is contained in:
Mark Payne 2015-10-23 16:13:52 -04:00
parent b0322d9ffe
commit 4e38288062
4 changed files with 18 additions and 2 deletions

View File

@ -77,6 +77,13 @@ public abstract class FetchFileTransfer extends AbstractProcessor {
.expressionLanguageSupported(true) .expressionLanguageSupported(true)
.required(true) .required(true)
.build(); .build();
public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder()
.name("Username")
.description("Username")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.expressionLanguageSupported(true)
.required(true)
.build();
public static final PropertyDescriptor REMOTE_FILENAME = new PropertyDescriptor.Builder() public static final PropertyDescriptor REMOTE_FILENAME = new PropertyDescriptor.Builder()
.name("Remote File") .name("Remote File")
.description("The fully qualified filename on the remote system") .description("The fully qualified filename on the remote system")

View File

@ -53,7 +53,7 @@ public class FetchSFTP extends FetchFileTransfer {
final List<PropertyDescriptor> properties = new ArrayList<>(); final List<PropertyDescriptor> properties = new ArrayList<>();
properties.add(HOSTNAME); properties.add(HOSTNAME);
properties.add(port); properties.add(port);
properties.add(SFTPTransfer.USERNAME); properties.add(USERNAME);
properties.add(SFTPTransfer.PASSWORD); properties.add(SFTPTransfer.PASSWORD);
properties.add(SFTPTransfer.PRIVATE_KEY_PATH); properties.add(SFTPTransfer.PRIVATE_KEY_PATH);
properties.add(SFTPTransfer.PRIVATE_KEY_PASSPHRASE); properties.add(SFTPTransfer.PRIVATE_KEY_PASSPHRASE);

View File

@ -45,6 +45,13 @@ public abstract class ListFileTransfer extends AbstractListProcessor<FileInfo> {
.expressionLanguageSupported(true) .expressionLanguageSupported(true)
.required(true) .required(true)
.build(); .build();
public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder()
.name("Username")
.description("Username")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.expressionLanguageSupported(true)
.required(true)
.build();
public static final PropertyDescriptor REMOTE_PATH = new PropertyDescriptor.Builder() public static final PropertyDescriptor REMOTE_PATH = new PropertyDescriptor.Builder()
.name("Remote Path") .name("Remote Path")
.description("The path on the remote system from which to pull or push files") .description("The path on the remote system from which to pull or push files")
@ -64,6 +71,7 @@ public abstract class ListFileTransfer extends AbstractListProcessor<FileInfo> {
attributes.put("file.group", fileInfo.getGroup()); attributes.put("file.group", fileInfo.getGroup());
attributes.put("file.permissions", fileInfo.getPermissions()); attributes.put("file.permissions", fileInfo.getPermissions());
attributes.put(CoreAttributes.FILENAME.key(), fileInfo.getFileName()); attributes.put(CoreAttributes.FILENAME.key(), fileInfo.getFileName());
attributes.put(getProtocolName() + ".listing.user", context.getProperty(USERNAME).evaluateAttributeExpressions().getValue());
final String fullPath = fileInfo.getFullPathFileName(); final String fullPath = fileInfo.getFullPathFileName();
if (fullPath != null) { if (fullPath != null) {

View File

@ -39,6 +39,7 @@ import org.apache.nifi.processors.standard.util.SFTPTransfer;
@WritesAttributes({ @WritesAttributes({
@WritesAttribute(attribute = "sftp.remote.host", description = "The hostname of the SFTP Server"), @WritesAttribute(attribute = "sftp.remote.host", description = "The hostname of the SFTP Server"),
@WritesAttribute(attribute = "sftp.remote.port", description = "The port that was connected to on the SFTP Server"), @WritesAttribute(attribute = "sftp.remote.port", description = "The port that was connected to on the SFTP Server"),
@WritesAttribute(attribute = "sftp.listing.user", description = "The username of the user that performed the SFTP Listing"),
@WritesAttribute(attribute = "file.owner", description = "The numeric owner id of the source file"), @WritesAttribute(attribute = "file.owner", description = "The numeric owner id of the source file"),
@WritesAttribute(attribute = "file.group", description = "The numeric group id of the source file"), @WritesAttribute(attribute = "file.group", description = "The numeric group id of the source file"),
@WritesAttribute(attribute = "file.permissions", description = "The read/write/execute permissions of the source file"), @WritesAttribute(attribute = "file.permissions", description = "The read/write/execute permissions of the source file"),
@ -54,7 +55,7 @@ public class ListSFTP extends ListFileTransfer {
final List<PropertyDescriptor> properties = new ArrayList<>(); final List<PropertyDescriptor> properties = new ArrayList<>();
properties.add(HOSTNAME); properties.add(HOSTNAME);
properties.add(port); properties.add(port);
properties.add(SFTPTransfer.USERNAME); properties.add(USERNAME);
properties.add(SFTPTransfer.PASSWORD); properties.add(SFTPTransfer.PASSWORD);
properties.add(SFTPTransfer.PRIVATE_KEY_PATH); properties.add(SFTPTransfer.PRIVATE_KEY_PATH);
properties.add(SFTPTransfer.PRIVATE_KEY_PASSPHRASE); properties.add(SFTPTransfer.PRIVATE_KEY_PASSPHRASE);