Class SftpRemoteFileTemplate

java.lang.Object
org.springframework.integration.file.remote.RemoteFileTemplate<org.apache.sshd.sftp.client.SftpClient.DirEntry>
org.springframework.integration.sftp.session.SftpRemoteFileTemplate
All Implemented Interfaces:
Aware, BeanFactoryAware, InitializingBean, RemoteFileOperations<org.apache.sshd.sftp.client.SftpClient.DirEntry>

public class SftpRemoteFileTemplate extends RemoteFileTemplate<org.apache.sshd.sftp.client.SftpClient.DirEntry>
SFTP version of RemoteFileTemplate providing type-safe access to the underlying ChannelSftp object.
Since:
4.1
Author:
Gary Russell, Artem Bilan
  • Field Details

    • NOT_DIRTY_STATUSES

      protected static final List<Integer> NOT_DIRTY_STATUSES
  • Constructor Details

    • SftpRemoteFileTemplate

      public SftpRemoteFileTemplate(SessionFactory<org.apache.sshd.sftp.client.SftpClient.DirEntry> sessionFactory)
  • Method Details

    • executeWithClient

      public <T, C> T executeWithClient(ClientCallback<C,T> callback)
      Description copied from interface: RemoteFileOperations
      Execute the callback's doWithClient method after obtaining a session's client, providing access to low level methods. Reliably closes the session when the method exits.
      Specified by:
      executeWithClient in interface RemoteFileOperations<org.apache.sshd.sftp.client.SftpClient.DirEntry>
      Overrides:
      executeWithClient in class RemoteFileTemplate<org.apache.sshd.sftp.client.SftpClient.DirEntry>
      Type Parameters:
      T - The type returned by ClientCallback.doWithClient(Object).
      C - The type of the underlying client object.
      Parameters:
      callback - the ClientCallback.
      Returns:
      The result of the callback method.
    • doExecuteWithClient

      protected <T> T doExecuteWithClient(ClientCallback<org.apache.sshd.sftp.client.SftpClient,T> callback)
    • shouldMarkSessionAsDirty

      protected boolean shouldMarkSessionAsDirty(Exception ex)
      Description copied from class: RemoteFileTemplate
      Determine whether Session.dirty() should be called in the RemoteFileTemplate.execute(SessionCallback) when an exception is thrown from the callback. By default, this method returns true. Remote file protocol extensions can override this method to provide a specific strategy against the thrown exception, e.g. file not found error is not a signal that session is broken.
      Overrides:
      shouldMarkSessionAsDirty in class RemoteFileTemplate<org.apache.sshd.sftp.client.SftpClient.DirEntry>
      Parameters:
      ex - the exception to check if Session must be marked as dirty.
      Returns:
      true if Session.dirty() should be called.
    • isStatusDirty

      protected boolean isStatusDirty(int status)
      Check if SftpException.getStatus() is treated as fatal.
      Parameters:
      status - the value from SftpException.getStatus().
      Returns:
      true if SftpException.getStatus() is treated as fatal.
      Since:
      6.0.8