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 enum 
    The exists(String) operation mode.

    Nested classes/interfaces inherited from interface org.springframework.integration.file.remote.RemoteFileOperations

    org.springframework.integration.file.remote.RemoteFileOperations.OperationsCallback<F extends Object,T extends Object>
  • Field Summary

    Fields inherited from class org.springframework.integration.file.remote.RemoteFileTemplate

    logger, sessionFactory
  • 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(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

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 interface org.springframework.integration.file.remote.RemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
      Overrides:
      executeWithClient in class org.springframework.integration.file.remote.RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile>
    • setExistsMode

      public void setExistsMode(FtpRemoteFileTemplate.ExistsMode existsMode)
      Specify an 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.
      Parameters:
      existsMode - the FtpRemoteFileTemplate.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(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.

      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 interface org.springframework.integration.file.remote.RemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
      Overrides:
      exists in class org.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.