public class SFTPTransfer extends Object implements FileTransfer
Modifier and Type | Field and Description |
---|---|
private boolean |
closed |
private PropertyContext |
ctx |
static PropertyDescriptor |
DISABLE_DIRECTORY_LISTING
Property which is used to decide if the
ensureDirectoryExists(FlowFile, File) method should perform a SFTPClient.ls(String) before calling
SFTPClient.mkdir(String) . |
private boolean |
disableDirectoryListing |
private String |
homeDir |
static PropertyDescriptor |
HOST_KEY_FILE |
private ComponentLog |
logger |
private static net.schmizz.keepalive.KeepAliveProvider |
NO_OP_KEEP_ALIVE |
static PropertyDescriptor |
PORT |
static PropertyDescriptor |
PRIVATE_KEY_PASSPHRASE |
static PropertyDescriptor |
PRIVATE_KEY_PATH |
static PropertyDescriptor |
PROXY_CONFIGURATION_SERVICE |
private static ProxySpec[] |
PROXY_SPECS |
private net.schmizz.sshj.sftp.SFTPClient |
sftpClient |
private net.schmizz.sshj.SSHClient |
sshClient |
static PropertyDescriptor |
STRICT_HOST_KEY_CHECKING |
static PropertyDescriptor |
USE_KEEPALIVE_ON_TIMEOUT |
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() |
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() |
private void |
getListing(String path,
int depth,
int maxResults,
List<FileInfo> listing) |
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 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, wait
getAbsolutePath
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 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 final boolean disableDirectoryListing
private static net.schmizz.keepalive.KeepAliveProvider NO_OP_KEEP_ALIVE
public SFTPTransfer(PropertyContext propertyContext, ComponentLog logger)
public static void validateProxySpec(ValidationContext context, Collection<ValidationResult> results)
public String getProtocolName()
getProtocolName
in interface FileTransfer
public List<FileInfo> getListing() throws IOException
getListing
in interface FileTransfer
IOException
private void getListing(String path, int depth, int maxResults, List<FileInfo> listing) throws IOException
IOException
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 FileTransfer
ProcessException
IOException
public void deleteFile(FlowFile flowFile, String path, String remoteFileName) throws IOException
deleteFile
in interface FileTransfer
IOException
public void deleteDirectory(FlowFile flowFile, String remoteDirectoryName) throws IOException
deleteDirectory
in interface FileTransfer
IOException
public void ensureDirectoryExists(FlowFile flowFile, File directoryName) throws IOException
ensureDirectoryExists
in interface FileTransfer
IOException
private String getMessage(net.schmizz.sshj.sftp.SFTPException e)
protected net.schmizz.sshj.sftp.SFTPClient getSFTPClient(FlowFile flowFile) throws IOException
IOException
public String getHomeDirectory(FlowFile flowFile) throws IOException
getHomeDirectory
in interface FileTransfer
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public boolean isClosed()
isClosed
in interface FileTransfer
public FileInfo getRemoteFileInfo(FlowFile flowFile, String path, String filename) throws IOException
getRemoteFileInfo
in interface FileTransfer
IOException
public String put(FlowFile flowFile, String path, String filename, InputStream content) throws IOException
put
in interface FileTransfer
IOException
public void rename(FlowFile flowFile, String source, String target) throws IOException
rename
in interface FileTransfer
IOException
protected int numberPermissions(String perms)
Copyright © 2020 Apache NiFi Project. All rights reserved.