public class FtpRemoteFileTemplate extends RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile>
RemoteFileTemplate
providing type-safe access to
the underlying FTPClient object.Modifier and Type | Class and Description |
---|---|
static class |
FtpRemoteFileTemplate.ExistsMode
The
exists(String) operation mode. |
RemoteFileOperations.OperationsCallback<F,T>
sessionFactory
Constructor and Description |
---|
FtpRemoteFileTemplate(SessionFactory<org.apache.commons.net.ftp.FTPFile> sessionFactory) |
Modifier and Type | Method and Description |
---|---|
protected <T> T |
doExecuteWithClient(ClientCallback<org.apache.commons.net.ftp.FTPClient,T> callback) |
<T,C> T |
executeWithClient(ClientCallback<C,T> callback)
Execute the callback's doWithClient method after obtaining a session's
client, providing access to low level methods.
|
boolean |
exists(String path)
This particular FTP implementation is based on the
FTPClient.getStatus(String)
by default, but since not all FTP servers properly implement the STAT command,
the framework internal FtpRemoteFileTemplate instances are switched to the
FTPClient.listNames(String) for only files operations. |
void |
setExistsMode(FtpRemoteFileTemplate.ExistsMode existsMode)
Specify an
FtpRemoteFileTemplate.ExistsMode for exists(String) operation. |
afterPropertiesSet, append, append, execute, get, get, getRemoteFileSeparator, getSession, getSessionFactory, getTemporaryFileSuffix, invoke, isUseTemporaryFileName, list, remove, rename, send, send, setAutoCreateDirectory, setBeanFactory, setCharset, setFileNameExpression, setFileNameGenerator, setRemoteDirectoryExpression, setRemoteFileSeparator, setTemporaryFileSuffix, setTemporaryRemoteDirectoryExpression, setUseTemporaryFileName
public FtpRemoteFileTemplate(SessionFactory<org.apache.commons.net.ftp.FTPFile> sessionFactory)
public <T,C> T executeWithClient(ClientCallback<C,T> callback)
RemoteFileOperations
executeWithClient
in interface RemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
executeWithClient
in class RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile>
T
- The type returned by ClientCallback.doWithClient(Object)
.C
- The type of the underlying client object.callback
- the ClientCallback.public void setExistsMode(FtpRemoteFileTemplate.ExistsMode existsMode)
FtpRemoteFileTemplate.ExistsMode
for exists(String)
operation.
Defaults to FtpRemoteFileTemplate.ExistsMode.STAT
.
When used internally by framework components for file operation,
switched to FtpRemoteFileTemplate.ExistsMode.NLST
.existsMode
- the FtpRemoteFileTemplate.ExistsMode
to use.protected <T> T doExecuteWithClient(ClientCallback<org.apache.commons.net.ftp.FTPClient,T> callback)
public boolean exists(String path)
FTPClient.getStatus(String)
by default, but since not all FTP servers properly implement the STAT
command,
the framework internal FtpRemoteFileTemplate
instances are switched to the
FTPClient.listNames(String)
for only files operations.
The mode can be switched with the setExistsMode(ExistsMode)
property.
Any custom implementation can be done in an extension of the FtpRemoteFileTemplate
.
exists
in interface RemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
exists
in class RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile>
path
- the remote file path to check.