diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListFileTransfer.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListFileTransfer.java index 2cc3aae383..f4557dc37d 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListFileTransfer.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListFileTransfer.java @@ -18,10 +18,8 @@ package org.apache.nifi.processors.standard; import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import org.apache.commons.io.IOUtils; import org.apache.nifi.components.PropertyDescriptor; @@ -30,6 +28,12 @@ import org.apache.nifi.processor.ProcessContext; import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.processors.standard.util.FileInfo; import org.apache.nifi.processors.standard.util.FileTransfer; +import java.util.Map; +import java.util.HashMap; +import java.util.List; +import java.util.Iterator; +import java.util.Date; +import java.util.Locale; public abstract class ListFileTransfer extends AbstractListProcessor { public static final PropertyDescriptor HOSTNAME = new PropertyDescriptor.Builder() @@ -66,14 +70,15 @@ public abstract class ListFileTransfer extends AbstractListProcessor { @Override protected Map createAttributes(final FileInfo fileInfo, final ProcessContext context) { final Map attributes = new HashMap<>(); + final DateFormat formatter = new SimpleDateFormat(ListFile.FILE_MODIFY_DATE_ATTR_FORMAT, Locale.US); attributes.put(getProtocolName() + ".remote.host", context.getProperty(HOSTNAME).evaluateAttributeExpressions().getValue()); attributes.put(getProtocolName() + ".remote.port", context.getProperty(UNDEFAULTED_PORT).evaluateAttributeExpressions().getValue()); - attributes.put("file.owner", fileInfo.getOwner()); - attributes.put("file.group", fileInfo.getGroup()); - attributes.put("file.permissions", fileInfo.getPermissions()); - attributes.put(CoreAttributes.FILENAME.key(), fileInfo.getFileName()); attributes.put(getProtocolName() + ".listing.user", context.getProperty(USERNAME).evaluateAttributeExpressions().getValue()); - + attributes.put(ListFile.FILE_LAST_MODIFY_TIME_ATTRIBUTE, formatter.format(new Date(fileInfo.getLastModifiedTime()))); + attributes.put(ListFile.FILE_PERMISSIONS_ATTRIBUTE, fileInfo.getPermissions()); + attributes.put(ListFile.FILE_OWNER_ATTRIBUTE, fileInfo.getOwner()); + attributes.put(ListFile.FILE_GROUP_ATTRIBUTE, fileInfo.getGroup()); + attributes.put(CoreAttributes.FILENAME.key(), fileInfo.getFileName()); final String fullPath = fileInfo.getFullPathFileName(); if (fullPath != null) { final int index = fullPath.lastIndexOf("/"); diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListSFTP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListSFTP.java index f2df7da248..a14532957d 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListSFTP.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListSFTP.java @@ -45,9 +45,11 @@ import org.apache.nifi.processors.standard.util.SFTPTransfer; @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.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.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 = ListFile.FILE_OWNER_ATTRIBUTE, description = "The numeric owner id of the source file"), + @WritesAttribute(attribute = ListFile.FILE_GROUP_ATTRIBUTE, description = "The numeric group id of the source file"), + @WritesAttribute(attribute = ListFile.FILE_PERMISSIONS_ATTRIBUTE, description = "The read/write/execute permissions of the source file"), + @WritesAttribute(attribute = ListFile.FILE_LAST_MODIFY_TIME_ATTRIBUTE, description = "The timestamp of when the file in the filesystem was" + + "last modified as 'yyyy-MM-dd'T'HH:mm:ssZ'"), @WritesAttribute(attribute = "filename", description = "The name of the file on the SFTP Server"), @WritesAttribute(attribute = "path", description = "The fully qualified name of the directory on the SFTP Server from which the file was pulled"), })