Package org.apache.sshd.scp.client
Class ScpRemote2RemoteTransferHelper
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.scp.client.ScpRemote2RemoteTransferHelper
-
public class ScpRemote2RemoteTransferHelper extends AbstractLoggingBean
Helps transfer files between 2 servers rather than between server and local file system by using 2ClientSession
-s and simply copying from one server to the other
-
-
Field Summary
Fields Modifier and Type Field Description private ClientSession
destSession
protected ScpRemote2RemoteTransferListener
listener
private ClientSession
sourceSession
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description ScpRemote2RemoteTransferHelper(ClientSession sourceSession, ClientSession destSession)
ScpRemote2RemoteTransferHelper(ClientSession sourceSession, ClientSession destSession, ScpRemote2RemoteTransferListener listener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
executeTransfer(java.lang.String source, java.util.Collection<ScpClient.Option> srcOptions, java.lang.String destination, java.util.Collection<ScpClient.Option> dstOptions)
ClientSession
getDestinationSession()
ClientSession
getSourceSession()
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)
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)
protected java.lang.Object
receiveNextCmd(java.lang.Object logHint, java.io.InputStream in)
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)
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)
protected void
signalReceivedCommand(AbstractScpCommandDetails details)
java.lang.String
toString()
void
transferDirectory(java.lang.String source, java.lang.String destination, boolean preserveAttributes)
Transfers a directoryvoid
transferFile(java.lang.String source, java.lang.String destination, boolean preserveAttributes)
Transfers a single fileprotected 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)
protected ScpAckInfo
transferStatusCode(java.lang.Object logHint, java.io.InputStream in, java.io.OutputStream out)
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)
-
-
-
Field Detail
-
listener
protected final ScpRemote2RemoteTransferListener listener
-
sourceSession
private final ClientSession sourceSession
-
destSession
private final ClientSession destSession
-
-
Constructor Detail
-
ScpRemote2RemoteTransferHelper
public ScpRemote2RemoteTransferHelper(ClientSession sourceSession, ClientSession destSession)
-
ScpRemote2RemoteTransferHelper
public ScpRemote2RemoteTransferHelper(ClientSession sourceSession, ClientSession destSession, ScpRemote2RemoteTransferListener listener)
- Parameters:
sourceSession
- The sourceClientSession
destSession
- The destinationClientSession
listener
- An optionalScpRemote2RemoteTransferListener
-
-
Method Detail
-
getSourceSession
public ClientSession getSourceSession()
-
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 sessiondestination
- Destination path in the destination sessionpreserveAttributes
- 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 sessiondestination
- Destination path in the destination sessionpreserveAttributes
- 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 classjava.lang.Object
-
-