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 protected java.nio.charset.CharsetcsInprotected java.nio.charset.CharsetcsOutprivate ClientSessiondestSessionprotected ScpRemote2RemoteTransferListenerlistenerprivate ClientSessionsourceSession-
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 voidexecuteTransfer(java.lang.String source, java.util.Collection<ScpClient.Option> srcOptions, java.lang.String destination, java.util.Collection<ScpClient.Option> dstOptions)ClientSessiongetDestinationSession()ClientSessiongetSourceSession()protected voidhandleDirectoryTransferRequest(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 longhandleFileTransferRequest(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.ObjectreceiveNextCmd(java.lang.Object logHint, java.io.InputStream in)protected voidredirectDirectoryTransfer(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 longredirectFileTransfer(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 voidsignalReceivedCommand(AbstractScpCommandDetails details)java.lang.StringtoString()voidtransferDirectory(java.lang.String source, java.lang.String destination, boolean preserveAttributes)Transfers a directoryvoidtransferFile(java.lang.String source, java.lang.String destination, boolean preserveAttributes)Transfers a single fileprotected longtransferSimpleFile(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 ScpAckInfotransferStatusCode(java.lang.Object logHint, java.io.InputStream in, java.io.OutputStream out)protected java.lang.StringtransferTimestampCommand(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
-
csIn
protected final java.nio.charset.Charset csIn
-
csOut
protected final java.nio.charset.Charset csOut
-
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 sourceClientSessiondestSession- The destinationClientSessionlistener- 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.IOExceptionTransfers 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.IOExceptionTransfers 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:
toStringin classjava.lang.Object
-
-