public abstract class AbstractSshMessage
extends java.lang.Object
Constructor and Description |
---|
AbstractSshMessage(boolean verbose,
com.jcraft.jsch.Session session)
Constructor for AbstractSshMessage
|
AbstractSshMessage(com.jcraft.jsch.Session session)
Constructor for AbstractSshMessage
|
Modifier and Type | Method and Description |
---|---|
abstract void |
execute()
Carry out the transfer.
|
protected com.jcraft.jsch.SftpProgressMonitor |
getProgressMonitor()
Get the progress monitor.
|
protected boolean |
getVerbose()
Is the verbose attribute set.
|
protected void |
log(java.lang.String message)
Log a message to the log listener.
|
protected void |
logStats(long timeStarted,
long timeEnded,
long totalLength)
Log transfer stats to the log listener.
|
protected com.jcraft.jsch.Channel |
openExecChannel(java.lang.String command)
Open an ssh channel.
|
protected com.jcraft.jsch.ChannelSftp |
openSftpChannel()
Open an ssh sftp channel.
|
protected void |
sendAck(java.io.OutputStream out)
Send an ack.
|
void |
setLogListener(LogListener aListener)
Set a log listener.
|
protected int |
trackProgress(long filesize,
long totalLength,
int percentTransmitted)
Track progress every 10% if 100kb < filesize < 1mb.
|
protected void |
waitForAck(java.io.InputStream in)
Reads the response, throws a BuildException if the response
indicates an error.
|
public AbstractSshMessage(com.jcraft.jsch.Session session)
session
- the ssh session to usepublic AbstractSshMessage(boolean verbose, com.jcraft.jsch.Session session)
verbose
- if true do verbose loggingsession
- the ssh session to useprotected com.jcraft.jsch.Channel openExecChannel(java.lang.String command) throws com.jcraft.jsch.JSchException
command
- the command to usecom.jcraft.jsch.JSchException
- on errorprotected com.jcraft.jsch.ChannelSftp openSftpChannel() throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchException
- on errorprotected void sendAck(java.io.OutputStream out) throws java.io.IOException
out
- the output stream to usejava.io.IOException
- on errorprotected void waitForAck(java.io.InputStream in) throws java.io.IOException, BuildException
in
- the input stream to usejava.io.IOException
- on I/O errorBuildException
- on other errorspublic abstract void execute() throws java.io.IOException, com.jcraft.jsch.JSchException
java.io.IOException
- on I/O errorscom.jcraft.jsch.JSchException
- on ssh errorspublic void setLogListener(LogListener aListener)
aListener
- the log listenerprotected void log(java.lang.String message)
message
- the message to logprotected void logStats(long timeStarted, long timeEnded, long totalLength)
timeStarted
- the time startedtimeEnded
- the finishing timetotalLength
- the total lengthprotected final boolean getVerbose()
protected final int trackProgress(long filesize, long totalLength, int percentTransmitted)
filesize
- the size of the file been transmittedtotalLength
- the total transmission sizepercentTransmitted
- the current percent transmittedprotected com.jcraft.jsch.SftpProgressMonitor getProgressMonitor()