public abstract class FtpCommand extends org.mule.extension.file.common.api.command.FileCommand<FtpFileSystem>
FileCommand implementations that target a FTP/SFTP server| Modifier and Type | Field and Description |
|---|---|
protected org.apache.commons.net.ftp.FTPClient |
client |
protected static String |
ROOT |
| Modifier | Constructor and Description |
|---|---|
protected |
FtpCommand(FtpFileSystem fileSystem) |
protected |
FtpCommand(FtpFileSystem fileSystem,
org.apache.commons.net.ftp.FTPClient client)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
changeWorkingDirectory(Path path)
Changes the current working directory to the given
path |
protected void |
changeWorkingDirectory(String path)
Changes the current working directory to the given
path |
protected void |
copy(org.mule.extension.file.common.api.FileConnectorConfig config,
String source,
String target,
boolean overwrite,
boolean createParentDirectory,
String renameTo,
FtpCopyDelegate delegate)
Performs the base logic and delegates into
FtpCopyDelegate.doCopy(FileConnectorConfig, FileAttributes, Path, boolean) to perform the actual
copying logic |
protected void |
createDirectory(String directoryPath) |
protected void |
doMkDirs(Path directoryPath)
Creates the directory pointed by
directoryPath also creating any missing parent directories |
RuntimeException |
exception(String message,
Exception cause)
Same as the super method but adding the FTP rely code
|
protected boolean |
exists(Path path) |
protected Path |
getBasePath(org.mule.extension.file.common.api.FileSystem fileSystem) |
protected String |
getCurrentWorkingDirectory() |
protected FtpFileAttributes |
getExistingFile(String filePath)
|
FtpFileAttributes |
getFile(String filePath)
Obtains a
FtpFileAttributes for the given filePath by using the FTPClient.mlistFile(String) FTP
command |
protected FtpFileAttributes |
getFile(String filePath,
boolean requireExistence) |
protected void |
makeDirectory(String directoryName)
Creates the directory of the given
directoryName in the current working directory |
protected void |
rename(String filePath,
String newName,
boolean overwrite)
Renames the file at
filePath to newName. |
protected Path |
resolvePath(String filePath)
|
protected boolean |
tryChangeWorkingDirectory(String path)
Attempts to change the current working directory.
|
protected static final String ROOT
protected final org.apache.commons.net.ftp.FTPClient client
protected FtpCommand(FtpFileSystem fileSystem)
protected FtpCommand(FtpFileSystem fileSystem, org.apache.commons.net.ftp.FTPClient client)
fileSystem - the FileSystem on which the operation is performedclient - a ready to use FTPClient to perform the operationsprotected FtpFileAttributes getExistingFile(String filePath)
filePath - the path to the file you wantFtpFileAttributesIllegalArgumentException - if the filePath doesn't existpublic FtpFileAttributes getFile(String filePath)
FtpFileAttributes for the given filePath by using the FTPClient.mlistFile(String) FTP
commandfilePath - the path to the file you wantFtpFileAttributes or null if it doesn't existprotected FtpFileAttributes getFile(String filePath, boolean requireExistence)
protected boolean exists(Path path)
exists in class org.mule.extension.file.common.api.command.FileCommand<FtpFileSystem>protected Path getBasePath(org.mule.extension.file.common.api.FileSystem fileSystem)
getBasePath in class org.mule.extension.file.common.api.command.FileCommand<FtpFileSystem>protected void changeWorkingDirectory(Path path)
pathpath - the Path to which you wish to moveIllegalArgumentException - if the CWD could not be changedprotected void changeWorkingDirectory(String path)
pathpath - the path to which you wish to moveIllegalArgumentException - if the CWD could not be changedprotected Path resolvePath(String filePath)
resolvePath in class org.mule.extension.file.common.api.command.FileCommand<FtpFileSystem>filePath - the path to a file or directoryPathprotected boolean tryChangeWorkingDirectory(String path)
falsepath - the path to which you wish to movetrue if the CWD was changed. false otherwiseprotected void makeDirectory(String directoryName)
directoryName in the current working directorydirectoryName - the name of the directory you want to createprotected void rename(String filePath, String newName, boolean overwrite)
filePath to newName.filePath - the path of the file to be renamednewName - the new nameoverwrite - whether to overwrite the target file if it already existsprotected void createDirectory(String directoryPath)
protected final void copy(org.mule.extension.file.common.api.FileConnectorConfig config,
String source,
String target,
boolean overwrite,
boolean createParentDirectory,
String renameTo,
FtpCopyDelegate delegate)
FtpCopyDelegate.doCopy(FileConnectorConfig, FileAttributes, Path, boolean) to perform the actual
copying logicconfig - the config that is parameterizing this operationsource - the path to be copiedtarget - the path to the target destinationoverwrite - whether to overwrite existing target pathscreateParentDirectory - whether to create the target's parent directory if it doesn't existprotected String getCurrentWorkingDirectory()
protected void doMkDirs(Path directoryPath)
directoryPath also creating any missing parent directoriesdoMkDirs in class org.mule.extension.file.common.api.command.FileCommand<FtpFileSystem>directoryPath - the Path to the directory you want to createpublic RuntimeException exception(String message, Exception cause)
exception in class org.mule.extension.file.common.api.command.FileCommand<FtpFileSystem>Copyright © 2018 MuleSoft, Inc.. All rights reserved.