Interface RemoteFileOperations<F>

All Known Implementing Classes:
FtpRemoteFileTemplate, RemoteFileTemplate, SftpRemoteFileTemplate

public interface RemoteFileOperations<F>
Strategy for performing operations on remote files.
Since:
3.0
Author:
Gary Russell
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Interface Description
    static interface  RemoteFileOperations.OperationsCallback<F,​T>
    Callback for using the same session for multiple RemoteFileTemplate operations.
  • Method Summary

    Modifier and Type Method Description
    String append​(Message<?> message)
    Send a file to a remote server, based on information in a message, appending.
    String append​(Message<?> message, String subDirectory)
    Send a file to a remote server, based on information in a message, appending.
    <T> T execute​(SessionCallback<F,​T> callback)
    Execute the callback's doInSession method after obtaining a session.
    <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)
    Check if a file exists on the remote server.
    boolean get​(String remotePath, InputStreamCallback callback)
    Retrieve a remote file as an InputStream.
    boolean get​(Message<?> message, InputStreamCallback callback)
    Retrieve a remote file as an InputStream, based on information in a message.
    Session<F> getSession()
    Obtain a raw Session object.
    <T> T invoke​(RemoteFileOperations.OperationsCallback<F,​T> action)
    Invoke the callback and run all operations on the template argument in a dedicated thread-bound session and reliably close the it afterwards.
    F[] list​(String path)
    List the files at the remote path.
    boolean remove​(String path)
    Remove a remote file.
    void rename​(String fromPath, String toPath)
    Rename a remote file, creating directories if needed.
    String send​(Message<?> message, String subDirectory, FileExistsMode... mode)
    Send a file to a remote server, based on information in a message.
    String send​(Message<?> message, FileExistsMode... mode)
    Send a file to a remote server, based on information in a message.
  • Method Details

    • send

      String send​(Message<?> message, FileExistsMode... mode)
      Send a file to a remote server, based on information in a message.
      Parameters:
      message - The message.
      mode - See FileExistsMode (optional; default REPLACE). A vararg is used to make the argument optional; only the first will be used if more than one is provided.
      Returns:
      The remote path, or null if no local file was found.
    • send

      String send​(Message<?> message, String subDirectory, FileExistsMode... mode)
      Send a file to a remote server, based on information in a message. The subDirectory is appended to the remote directory evaluated from the message.
      Parameters:
      message - The message.
      subDirectory - The sub directory.
      mode - See FileExistsMode (optional; default REPLACE). A vararg is used to make the argument optional; only the first will be used if more than one is provided.
      Returns:
      The remote path, or null if no local file was found.
    • append

      String append​(Message<?> message)
      Send a file to a remote server, based on information in a message, appending.
      Parameters:
      message - The message.
      Returns:
      The remote path, or null if no local file was found.
      Since:
      4.1
    • append

      String append​(Message<?> message, String subDirectory)
      Send a file to a remote server, based on information in a message, appending. The subDirectory is appended to the remote directory evaluated from the message.
      Parameters:
      message - The message.
      subDirectory - The sub directory.
      Returns:
      The remote path, or null if no local file was found.
      Since:
      4.1
    • get

      boolean get​(String remotePath, InputStreamCallback callback)
      Retrieve a remote file as an InputStream.
      Parameters:
      remotePath - The remote path to the file.
      callback - the callback.
      Returns:
      true if the operation was successful.
    • get

      boolean get​(Message<?> message, InputStreamCallback callback)
      Retrieve a remote file as an InputStream, based on information in a message.
      Parameters:
      message - The message which will be evaluated to generate the remote path.
      callback - the callback.
      Returns:
      true if the operation was successful.
    • exists

      boolean exists​(String path)
      Check if a file exists on the remote server.
      Parameters:
      path - The full path to the file.
      Returns:
      true when the file exists.
      Since:
      4.1
    • remove

      boolean remove​(String path)
      Remove a remote file.
      Parameters:
      path - The full path to the file.
      Returns:
      true when successful.
    • rename

      void rename​(String fromPath, String toPath)
      Rename a remote file, creating directories if needed.
      Parameters:
      fromPath - The current path.
      toPath - The new path.
    • list

      F[] list​(String path)
      List the files at the remote path.
      Parameters:
      path - the path.
      Returns:
      the list.
    • execute

      <T> T execute​(SessionCallback<F,​T> callback)
      Execute the callback's doInSession method after obtaining a session. Reliably closes the session when the method exits.
      Type Parameters:
      T - The type returned by SessionCallback.doInSession(org.springframework.integration.file.remote.session.Session).
      Parameters:
      callback - the SessionCallback.
      Returns:
      The result of the callback method.
    • invoke

      <T> T invoke​(RemoteFileOperations.OperationsCallback<F,​T> action)
      Invoke the callback and run all operations on the template argument in a dedicated thread-bound session and reliably close the it afterwards.
      Type Parameters:
      T - the return type.
      Parameters:
      action - the call back.
      Returns:
      the result from the RemoteFileOperations.OperationsCallback.doInOperations(RemoteFileOperations)
      Since:
      5.0
    • executeWithClient

      <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. Reliably closes the session when the method exits.
      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.
      Since:
      4.1
    • getSession

      Session<F> getSession()
      Obtain a raw Session object. User must close the session when it is no longer needed.
      Returns:
      a session.
      Since:
      4.3