Class FtpRemoteFileTemplate
java.lang.Object
org.springframework.integration.file.remote.RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile>
org.springframework.integration.ftp.session.FtpRemoteFileTemplate
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanFactoryAware
,org.springframework.beans.factory.InitializingBean
,org.springframework.integration.file.remote.RemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
public class FtpRemoteFileTemplate
extends org.springframework.integration.file.remote.RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile>
FTP version of
RemoteFileTemplate
providing type-safe access to
the underlying FTPClient object.- Since:
- 4.1
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FtpRemoteFileTemplate.ExistsMode
Theexists(String)
operation mode. -
Field Summary
-
Constructor Summary
Constructors Constructor Description FtpRemoteFileTemplate(org.springframework.integration.file.remote.session.SessionFactory<org.apache.commons.net.ftp.FTPFile> sessionFactory)
-
Method Summary
Modifier and Type Method Description protected <T> T
doExecuteWithClient(org.springframework.integration.file.remote.ClientCallback<org.apache.commons.net.ftp.FTPClient,T> callback)
<T, C> T
executeWithClient(org.springframework.integration.file.remote.ClientCallback<C,T> callback)
boolean
exists(java.lang.String path)
This particular FTP implementation is based on theFTPClient.getStatus(String)
by default, but since not all FTP servers properly implement theSTAT
command, the framework internalFtpRemoteFileTemplate
instances are switched to theFTPClient.listNames(String)
for only files operations.void
setExistsMode(FtpRemoteFileTemplate.ExistsMode existsMode)
Specify anFtpRemoteFileTemplate.ExistsMode
forexists(String)
operation.Methods inherited from class org.springframework.integration.file.remote.RemoteFileTemplate
afterPropertiesSet, append, append, execute, get, get, getDirectoryExpressionProcessor, getRemoteFileSeparator, getSession, getSessionFactory, getTemporaryFileSuffix, invoke, isUseTemporaryFileName, list, remove, rename, send, send, setAutoCreateDirectory, setBeanFactory, setCharset, setFileNameExpression, setFileNameGenerator, setRemoteDirectoryExpression, setRemoteFileSeparator, setTemporaryFileSuffix, setTemporaryRemoteDirectoryExpression, setUseTemporaryFileName
-
Constructor Details
-
FtpRemoteFileTemplate
public FtpRemoteFileTemplate(org.springframework.integration.file.remote.session.SessionFactory<org.apache.commons.net.ftp.FTPFile> sessionFactory)
-
-
Method Details
-
executeWithClient
public <T, C> T executeWithClient(org.springframework.integration.file.remote.ClientCallback<C,T> callback)- Specified by:
executeWithClient
in interfaceorg.springframework.integration.file.remote.RemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
- Overrides:
executeWithClient
in classorg.springframework.integration.file.remote.RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile>
-
setExistsMode
Specify anFtpRemoteFileTemplate.ExistsMode
forexists(String)
operation. Defaults toFtpRemoteFileTemplate.ExistsMode.STAT
. When used internally by framework components for file operation, switched toFtpRemoteFileTemplate.ExistsMode.NLST
.- Parameters:
existsMode
- theFtpRemoteFileTemplate.ExistsMode
to use.- Since:
- 4.1.9
-
doExecuteWithClient
protected <T> T doExecuteWithClient(org.springframework.integration.file.remote.ClientCallback<org.apache.commons.net.ftp.FTPClient,T> callback) -
exists
public boolean exists(java.lang.String path)This particular FTP implementation is based on theFTPClient.getStatus(String)
by default, but since not all FTP servers properly implement theSTAT
command, the framework internalFtpRemoteFileTemplate
instances are switched to theFTPClient.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
.- Specified by:
exists
in interfaceorg.springframework.integration.file.remote.RemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
- Overrides:
exists
in classorg.springframework.integration.file.remote.RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile>
- Parameters:
path
- the remote file path to check.- Returns:
- true or false if remote file exists or not.
-