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
-
Nested Class Summary
Nested classes/interfaces inherited from interface RemoteFileOperations
RemoteFileOperations.OperationsCallback<F,T> -
Field Summary
FieldsFields inherited from class RemoteFileTemplate
logger, sessionFactory -
Constructor Summary
ConstructorsConstructorDescriptionSftpRemoteFileTemplate(SessionFactory<org.apache.sshd.sftp.client.SftpClient.DirEntry> sessionFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> @Nullable TdoExecuteWithClient(ClientCallback<org.apache.sshd.sftp.client.SftpClient, T> callback) <T,C> @Nullable T executeWithClient(ClientCallback<C, T> callback) Execute the callback's doWithClient method after obtaining a session's client, providing access to low level methods.protected booleanisStatusDirty(int status) Check ifSftpException.getStatus()is treated as fatal.protected booleanDetermine whetherSession.dirty()should be called in theRemoteFileTemplate.execute(SessionCallback)when an exception is thrown from the callback.Methods inherited from class RemoteFileTemplate
afterPropertiesSet, append, append, execute, exists, get, get, getDirectoryExpressionProcessor, getRemoteFileSeparator, getSession, getSessionFactory, getTemporaryFileSuffix, invoke, isUseTemporaryFileName, list, remove, rename, send, send, setAutoCreateDirectory, setBeanFactory, setCharset, setFileNameExpression, setFileNameGenerator, setRemoteDirectoryExpression, setRemoteFileSeparator, setTemporaryFileSuffix, setTemporaryRemoteDirectoryExpression, setUseTemporaryFileName
-
Field Details
-
NOT_DIRTY_STATUSES
-
-
Constructor Details
-
SftpRemoteFileTemplate
public SftpRemoteFileTemplate(SessionFactory<org.apache.sshd.sftp.client.SftpClient.DirEntry> sessionFactory)
-
-
Method Details
-
executeWithClient
Description copied from interface:RemoteFileOperationsExecute 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:
executeWithClientin interfaceRemoteFileOperations<org.apache.sshd.sftp.client.SftpClient.DirEntry>- Overrides:
executeWithClientin classRemoteFileTemplate<org.apache.sshd.sftp.client.SftpClient.DirEntry>- Type Parameters:
T- The type returned byClientCallback.doWithClient(Object).C- The type of the underlying client object.- Parameters:
callback- the ClientCallback.- Returns:
- The result of the callback method.
-
doExecuteWithClient
protected <T> @Nullable T doExecuteWithClient(ClientCallback<org.apache.sshd.sftp.client.SftpClient, T> callback) -
shouldMarkSessionAsDirty
Description copied from class:RemoteFileTemplateDetermine whetherSession.dirty()should be called in theRemoteFileTemplate.execute(SessionCallback)when an exception is thrown from the callback. By default, this method returnstrue. Remote file protocol extensions can override this method to provide a specific strategy against the thrown exception, e.g.file not founderror is not a signal that session is broken.- Overrides:
shouldMarkSessionAsDirtyin classRemoteFileTemplate<org.apache.sshd.sftp.client.SftpClient.DirEntry>- Parameters:
ex- the exception to check ifSessionmust be marked as dirty.- Returns:
- true if
Session.dirty()should be called.
-
isStatusDirty
protected boolean isStatusDirty(int status) Check ifSftpException.getStatus()is treated as fatal.- Parameters:
status- the value fromSftpException.getStatus().- Returns:
- true if
SftpException.getStatus()is treated as fatal. - Since:
- 6.0.8
-