Class FTPClientWrapper
java.lang.Object
org.apache.commons.vfs2.provider.ftp.FTPClientWrapper
- All Implemented Interfaces:
FtpClient
A wrapper to the FTPClient to allow automatic reconnect on connection loss.
I decided to not to use eg. noop() to determine the state of the connection to avoid unnecessary server round-trips.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FileSystemOptions
private org.apache.commons.net.ftp.FTPClient
private static final org.apache.commons.logging.Log
private final GenericFileName
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
FTPClientWrapper
(GenericFileName root, FileSystemOptions fileSystemOptions) -
Method Summary
Modifier and TypeMethodDescriptionboolean
abort()
appendFileStream
(String relPath) boolean
private org.apache.commons.net.ftp.FTPClient
protected org.apache.commons.net.ftp.FTPClient
createClient
(GenericFileName rootName, UserAuthenticationData authData) boolean
deleteFile
(String relPath) void
private org.apache.commons.net.ftp.FTPClient
int
getRoot()
boolean
hasFeature
(String feature) Queries the server for a supported feature.boolean
org.apache.commons.net.ftp.FTPFile[]
private org.apache.commons.net.ftp.FTPFile[]
listFilesInDirectory
(String relPath) boolean
makeDirectory
(String relPath) mdtmInstant
(String relPath) Sends the MDTM command to get a file's date and time information after file transfer.boolean
removeDirectory
(String relPath) boolean
retrieveFileStream
(String relPath) retrieveFileStream
(String relPath, int bufferSize) retrieveFileStream
(String relPath, long restartOffset) void
setBufferSize
(int bufferSize) storeFileStream
(String relPath)
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
fileSystemOptions
-
ftpClient
private org.apache.commons.net.ftp.FTPClient ftpClient -
root
-
-
Constructor Details
-
FTPClientWrapper
protected FTPClientWrapper(GenericFileName root, FileSystemOptions fileSystemOptions) throws FileSystemException - Throws:
FileSystemException
-
-
Method Details
-
abort
- Specified by:
abort
in interfaceFtpClient
- Throws:
IOException
-
appendFileStream
- Specified by:
appendFileStream
in interfaceFtpClient
- Throws:
IOException
-
completePendingCommand
- Specified by:
completePendingCommand
in interfaceFtpClient
- Throws:
IOException
-
createClient
- Throws:
FileSystemException
-
createClient
protected org.apache.commons.net.ftp.FTPClient createClient(GenericFileName rootName, UserAuthenticationData authData) throws FileSystemException - Throws:
FileSystemException
-
deleteFile
- Specified by:
deleteFile
in interfaceFtpClient
- Throws:
IOException
-
disconnect
- Specified by:
disconnect
in interfaceFtpClient
- Throws:
IOException
-
getFileSystemOptions
-
getFtpClient
- Throws:
FileSystemException
-
getReplyCode
- Specified by:
getReplyCode
in interfaceFtpClient
- Throws:
IOException
-
getReplyString
- Specified by:
getReplyString
in interfaceFtpClient
- Throws:
IOException
-
getRoot
-
hasFeature
Queries the server for a supported feature.- Specified by:
hasFeature
in interfaceFtpClient
- Parameters:
feature
- the name of the feature, converted to upper case.- Returns:
true
if the feature is present,false
if the feature is not present or the FTP command failed.- Throws:
IOException
- on error
-
isConnected
- Specified by:
isConnected
in interfaceFtpClient
- Throws:
FileSystemException
-
listFiles
- Specified by:
listFiles
in interfaceFtpClient
- Throws:
IOException
-
listFilesInDirectory
private org.apache.commons.net.ftp.FTPFile[] listFilesInDirectory(String relPath) throws IOException - Throws:
IOException
-
makeDirectory
- Specified by:
makeDirectory
in interfaceFtpClient
- Throws:
IOException
-
mdtmInstant
Sends the MDTM command to get a file's date and time information after file transfer. It is typically more accurate than the"LIST"
command response. Time values are always represented in UTC (GMT), and in the Gregorian calendar regardless of what calendar may have been in use at the date and time the file was last modified.NOTE: not all remote FTP servers support
MDTM
.- Specified by:
mdtmInstant
in interfaceFtpClient
- Parameters:
relPath
- The relative path of the file object to executeMDTM
command against- Returns:
- new
Instant
object containing theMDTM
timestamp. - Throws:
IOException
- If the underlying FTP client encountered an error.
-
removeDirectory
- Specified by:
removeDirectory
in interfaceFtpClient
- Throws:
IOException
-
rename
- Specified by:
rename
in interfaceFtpClient
- Throws:
IOException
-
retrieveFileStream
- Specified by:
retrieveFileStream
in interfaceFtpClient
- Throws:
IOException
-
retrieveFileStream
- Specified by:
retrieveFileStream
in interfaceFtpClient
- Throws:
IOException
-
retrieveFileStream
- Specified by:
retrieveFileStream
in interfaceFtpClient
- Throws:
IOException
-
setBufferSize
- Specified by:
setBufferSize
in interfaceFtpClient
- Throws:
FileSystemException
-
storeFileStream
- Specified by:
storeFileStream
in interfaceFtpClient
- Throws:
IOException
-