org.apache.tools.ant.taskdefs.optional.ssh

Class AbstractSshMessage

Known Direct Subclasses:
ScpFromMessage, ScpToMessage

public abstract class AbstractSshMessage
extends java.lang.Object

Abstract class for ssh upload and download

Constructor Summary

AbstractSshMessage(Session session)
Constructor for AbstractSshMessage
AbstractSshMessage(boolean verbose, Session session)
Constructor for AbstractSshMessage

Method Summary

abstract void
execute()
Carry out the transfer.
protected SftpProgressMonitor
getProgressMonitor()
Get the progress monitor.
protected boolean
getVerbose()
Is the verbose attribute set.
protected void
log(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 Channel
openExecChannel(String command)
Open an ssh channel.
protected ChannelSftp
openSftpChannel()
Open an ssh sftp channel.
protected void
sendAck(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 <32filesize <321mb.
protected void
waitForAck(InputStream in)
Reads the response, throws a BuildException if the response indicates an error.

Constructor Details

AbstractSshMessage

public AbstractSshMessage(Session session)
Constructor for AbstractSshMessage
Parameters:
session - the ssh session to use

AbstractSshMessage

public AbstractSshMessage(boolean verbose,
                          Session session)
Constructor for AbstractSshMessage
Parameters:
verbose - if true do verbose logging
session - the ssh session to use
Since:
Ant 1.6.2

Method Details

execute

public abstract void execute()
            throws IOException,
                   JSchException
Carry out the transfer.

getProgressMonitor

protected SftpProgressMonitor getProgressMonitor()
Get the progress monitor.
Returns:
the progress monitor.

getVerbose

protected final boolean getVerbose()
Is the verbose attribute set.
Returns:
true if the verbose attribute is set
Since:
Ant 1.6.2

log

protected void log(String message)
Log a message to the log listener.
Parameters:
message - the message to log

logStats

protected void logStats(long timeStarted,
                        long timeEnded,
                        long totalLength)
Log transfer stats to the log listener.
Parameters:
timeStarted - the time started
timeEnded - the finishing time
totalLength - the total length

openExecChannel

protected Channel openExecChannel(String command)
            throws JSchException
Open an ssh channel.
Parameters:
command - the command to use
Returns:
the channel

openSftpChannel

protected ChannelSftp openSftpChannel()
            throws JSchException
Open an ssh sftp channel.
Returns:
the channel

sendAck

protected void sendAck(OutputStream out)
            throws IOException
Send an ack.
Parameters:
out - the output stream to use

setLogListener

public void setLogListener(LogListener aListener)
Set a log listener.
Parameters:
aListener - the log listener

trackProgress

protected final int trackProgress(long filesize,
                                  long totalLength,
                                  int percentTransmitted)
Track progress every 10% if 100kb <32filesize <321mb. For larger files track progress for every percent transmitted.
Parameters:
filesize - the size of the file been transmitted
totalLength - the total transmission size
percentTransmitted - the current percent transmitted
Returns:
the percent that the file is of the total

waitForAck

protected void waitForAck(InputStream in)
            throws IOException,
                   BuildException
Reads the response, throws a BuildException if the response indicates an error.
Parameters:
in - the input stream to use
Throws:
BuildException - on other errors