public class SFTPTransfer extends Object implements FileTransfer
BATCH_SIZE, CONFLICT_RESOLUTION, CONFLICT_RESOLUTION_FAIL, CONFLICT_RESOLUTION_IGNORE, CONFLICT_RESOLUTION_NONE, CONFLICT_RESOLUTION_REJECT, CONFLICT_RESOLUTION_RENAME, CONFLICT_RESOLUTION_REPLACE, CONNECTION_TIMEOUT, CREATE_DIRECTORY, DATA_TIMEOUT, DELETE_ORIGINAL, DOT_RENAME, FILE_FILTER_REGEX, FILE_MODIFY_DATE_ATTR_FORMAT, FOLLOW_SYMLINK, HOSTNAME, IGNORE_DOTTED_FILES, LAST_MODIFIED_TIME, MAX_SELECTS, PASSWORD, PATH_FILTER_REGEX, PERMISSIONS, POLLING_INTERVAL, RECURSIVE_SEARCH, REJECT_ZERO_BYTE, REMOTE_GROUP, REMOTE_OWNER, REMOTE_PATH, REMOTE_POLL_BATCH_SIZE, TEMP_FILENAME, USE_COMPRESSION, USE_NATURAL_ORDERING, USERNAME| Constructor and Description |
|---|
SFTPTransfer(PropertyContext propertyContext,
ComponentLog logger) |
| Modifier and Type | Method and Description |
|---|---|
private void |
appendPermission(StringBuilder builder,
Set<net.schmizz.sshj.xfer.FilePermission> permissions,
net.schmizz.sshj.xfer.FilePermission filePermission,
String permString) |
void |
close() |
private static String |
convertFactorySetToString(Set<String> factorySetNames)
Converts a set of names into an alphabetically ordered comma separated value list.
|
void |
deleteDirectory(FlowFile flowFile,
String remoteDirectoryName) |
void |
deleteFile(FlowFile flowFile,
String path,
String remoteFileName) |
void |
ensureDirectoryExists(FlowFile flowFile,
File directoryName) |
String |
getHomeDirectory(FlowFile flowFile) |
List<FileInfo> |
getListing(boolean applyFilters) |
protected void |
getListing(String path,
int depth,
int maxResults,
List<FileInfo> listing,
boolean applyFilters) |
private String |
getMessage(net.schmizz.sshj.sftp.SFTPException e) |
String |
getProtocolName() |
FlowFile |
getRemoteFile(String remoteFileName,
FlowFile origFlowFile,
ProcessSession session) |
FileInfo |
getRemoteFileInfo(FlowFile flowFile,
String path,
String filename) |
protected net.schmizz.sshj.sftp.SFTPClient |
getSFTPClient(FlowFile flowFile) |
boolean |
isClosed() |
private boolean |
isIncludedDirectory(net.schmizz.sshj.sftp.RemoteResourceInfo remoteResourceInfo,
boolean recursionEnabled,
boolean symlinksEnabled)
Include remote resources when recursion is enabled or when symbolic links are enabled and the resource is a directory link
|
private boolean |
isIncludedFile(net.schmizz.sshj.sftp.RemoteResourceInfo remoteResourceInfo,
boolean symlinksEnabled)
Include remote resources when regular file found or when symbolic links are enabled and the resource is a link
|
private boolean |
isSymlink(net.schmizz.sshj.sftp.RemoteResourceInfo remoteResourceInfo) |
private FileInfo |
newFileInfo(net.schmizz.sshj.sftp.RemoteResourceInfo entry,
String path) |
protected int |
numberPermissions(String perms) |
String |
put(FlowFile flowFile,
String path,
String filename,
InputStream content) |
void |
rename(FlowFile flowFile,
String source,
String target) |
static void |
validateProxySpec(ValidationContext context,
Collection<ValidationResult> results) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAbsolutePathprivate static final SSHClientProvider SSH_CLIENT_PROVIDER
private static final String DOT_PREFIX
private static final String RELATIVE_CURRENT_DIRECTORY
private static final String RELATIVE_PARENT_DIRECTORY
private static final Set<String> DEFAULT_MESSAGE_AUTHENTICATION_CODE_NAMES
private static final Set<String> DEFAULT_KEY_EXCHANGE_ALGORITHM_NAMES
public static final PropertyDescriptor PRIVATE_KEY_PATH
public static final PropertyDescriptor PRIVATE_KEY_PASSPHRASE
public static final PropertyDescriptor HOST_KEY_FILE
public static final PropertyDescriptor STRICT_HOST_KEY_CHECKING
public static final PropertyDescriptor PORT
public static final PropertyDescriptor USE_KEEPALIVE_ON_TIMEOUT
public static final PropertyDescriptor KEY_ALGORITHMS_ALLOWED
public static final PropertyDescriptor CIPHERS_ALLOWED
public static final PropertyDescriptor MESSAGE_AUTHENTICATION_CODES_ALLOWED
public static final PropertyDescriptor KEY_EXCHANGE_ALGORITHMS_ALLOWED
public static final PropertyDescriptor DISABLE_DIRECTORY_LISTING
ensureDirectoryExists(FlowFile, File) method should perform a SFTPClient.ls(String) before calling
SFTPClient.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.private static final ProxySpec[] PROXY_SPECS
public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE
private final ComponentLog logger
private final PropertyContext ctx
private net.schmizz.sshj.SSHClient sshClient
private net.schmizz.sshj.sftp.SFTPClient sftpClient
private volatile boolean closed
private String homeDir
private String activeHostname
private String activePort
private String activeUsername
private String activePassword
private String activePrivateKeyPath
private String activePrivateKeyPassphrase
private final boolean disableDirectoryListing
public SFTPTransfer(PropertyContext propertyContext, ComponentLog logger)
private static String convertFactorySetToString(Set<String> factorySetNames)
factorySetNames - The set of namespublic static void validateProxySpec(ValidationContext context, Collection<ValidationResult> results)
public String getProtocolName()
getProtocolName in interface FileTransferpublic List<FileInfo> getListing(boolean applyFilters) throws IOException
getListing in interface FileTransferIOExceptionprotected void getListing(String path, int depth, int maxResults, List<FileInfo> listing, boolean applyFilters) throws IOException
IOExceptionprivate boolean isIncludedFile(net.schmizz.sshj.sftp.RemoteResourceInfo remoteResourceInfo,
boolean symlinksEnabled)
remoteResourceInfo - Remote Resource InformationsymlinksEnabled - Follow symbolic links enabledprivate boolean isIncludedDirectory(net.schmizz.sshj.sftp.RemoteResourceInfo remoteResourceInfo,
boolean recursionEnabled,
boolean symlinksEnabled)
remoteResourceInfo - Remote Resource InformationrecursionEnabled - Recursion enabled statussymlinksEnabled - Follow symbolic links enabledprivate boolean isSymlink(net.schmizz.sshj.sftp.RemoteResourceInfo remoteResourceInfo)
private FileInfo newFileInfo(net.schmizz.sshj.sftp.RemoteResourceInfo entry, String path)
private void appendPermission(StringBuilder builder, Set<net.schmizz.sshj.xfer.FilePermission> permissions, net.schmizz.sshj.xfer.FilePermission filePermission, String permString)
public FlowFile getRemoteFile(String remoteFileName, FlowFile origFlowFile, ProcessSession session) throws ProcessException, IOException
getRemoteFile in interface FileTransferProcessExceptionIOExceptionpublic void deleteFile(FlowFile flowFile, String path, String remoteFileName) throws IOException
deleteFile in interface FileTransferIOExceptionpublic void deleteDirectory(FlowFile flowFile, String remoteDirectoryName) throws IOException
deleteDirectory in interface FileTransferIOExceptionpublic void ensureDirectoryExists(FlowFile flowFile, File directoryName) throws IOException
ensureDirectoryExists in interface FileTransferIOExceptionprivate String getMessage(net.schmizz.sshj.sftp.SFTPException e)
protected net.schmizz.sshj.sftp.SFTPClient getSFTPClient(FlowFile flowFile) throws IOException
IOExceptionpublic String getHomeDirectory(FlowFile flowFile) throws IOException
getHomeDirectory in interface FileTransferIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic boolean isClosed()
isClosed in interface FileTransferpublic FileInfo getRemoteFileInfo(FlowFile flowFile, String path, String filename) throws IOException
getRemoteFileInfo in interface FileTransferIOExceptionpublic String put(FlowFile flowFile, String path, String filename, InputStream content) throws IOException
put in interface FileTransferIOExceptionpublic void rename(FlowFile flowFile, String source, String target) throws IOException
rename in interface FileTransferIOExceptionprotected int numberPermissions(String perms)
Copyright © 2023 Apache NiFi Project. All rights reserved.