Class ScpRemote2RemoteTransferHelper


  • public class ScpRemote2RemoteTransferHelper
    extends AbstractLoggingBean
    Helps transfer files between 2 servers rather than between server and local file system by using 2 ClientSession-s and simply copying from one server to the other
    • Method Detail

      • getDestinationSession

        public ClientSession getDestinationSession()
      • transferFile

        public void transferFile​(java.lang.String source,
                                 java.lang.String destination,
                                 boolean preserveAttributes)
                          throws java.io.IOException
        Transfers a single file
        Parameters:
        source - Source path in the source session
        destination - Destination path in the destination session
        preserveAttributes - Whether to preserve the attributes of the transferred file (e.g., permissions, file associated timestamps, etc.)
        Throws:
        java.io.IOException - If failed to transfer
      • transferDirectory

        public void transferDirectory​(java.lang.String source,
                                      java.lang.String destination,
                                      boolean preserveAttributes)
                               throws java.io.IOException
        Transfers a directory
        Parameters:
        source - Source path in the source session
        destination - Destination path in the destination session
        preserveAttributes - Whether to preserve the attributes of the transferred file (e.g., permissions, file associated timestamps, etc.)
        Throws:
        java.io.IOException - If failed to transfer
      • executeTransfer

        protected void executeTransfer​(java.lang.String source,
                                       java.util.Collection<ScpClient.Option> srcOptions,
                                       java.lang.String destination,
                                       java.util.Collection<ScpClient.Option> dstOptions)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • redirectFileTransfer

        protected long redirectFileTransfer​(java.lang.String source,
                                            java.io.InputStream srcIn,
                                            java.io.OutputStream srcOut,
                                            java.lang.String destination,
                                            java.io.InputStream dstIn,
                                            java.io.OutputStream dstOut)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • handleFileTransferRequest

        protected long handleFileTransferRequest​(java.lang.String source,
                                                 java.io.InputStream srcIn,
                                                 java.io.OutputStream srcOut,
                                                 java.lang.String destination,
                                                 java.io.InputStream dstIn,
                                                 java.io.OutputStream dstOut,
                                                 ScpTimestampCommandDetails fileTime,
                                                 java.lang.String header)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • redirectDirectoryTransfer

        protected void redirectDirectoryTransfer​(java.lang.String source,
                                                 java.io.InputStream srcIn,
                                                 java.io.OutputStream srcOut,
                                                 java.lang.String destination,
                                                 java.io.InputStream dstIn,
                                                 java.io.OutputStream dstOut,
                                                 int depth)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • handleDirectoryTransferRequest

        protected void handleDirectoryTransferRequest​(java.lang.String srcPath,
                                                      java.io.InputStream srcIn,
                                                      java.io.OutputStream srcOut,
                                                      java.lang.String dstPath,
                                                      java.io.InputStream dstIn,
                                                      java.io.OutputStream dstOut,
                                                      int depth,
                                                      ScpTimestampCommandDetails dirTime,
                                                      java.lang.String header)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • transferSimpleFile

        protected long transferSimpleFile​(java.lang.String source,
                                          java.io.InputStream srcIn,
                                          java.io.OutputStream srcOut,
                                          java.lang.String destination,
                                          java.io.InputStream dstIn,
                                          java.io.OutputStream dstOut,
                                          java.lang.String header,
                                          long length)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • transferTimestampCommand

        protected java.lang.String transferTimestampCommand​(java.lang.String source,
                                                            java.io.InputStream srcIn,
                                                            java.io.OutputStream srcOut,
                                                            java.lang.String destination,
                                                            java.io.InputStream dstIn,
                                                            java.io.OutputStream dstOut,
                                                            java.lang.String header)
                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • transferStatusCode

        protected ScpAckInfo transferStatusCode​(java.lang.Object logHint,
                                                java.io.InputStream in,
                                                java.io.OutputStream out)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • receiveNextCmd

        protected java.lang.Object receiveNextCmd​(java.lang.Object logHint,
                                                  java.io.InputStream in)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • signalReceivedCommand

        protected void signalReceivedCommand​(AbstractScpCommandDetails details)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object