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

Class AbstractSshMessage

public abstract class AbstractSshMessage extends 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 voidexecute()
Carry out the transfer.
protected SftpProgressMonitorgetProgressMonitor()
Get the progress monitor.
protected booleangetVerbose()
Is the verbose attribute set.
protected voidlog(String message)
Log a message to the log listener.
protected voidlogStats(long timeStarted, long timeEnded, long totalLength)
Log transfer stats to the log listener.
protected ChannelopenExecChannel(String command)
Open an ssh channel.
protected ChannelSftpopenSftpChannel()
Open an ssh sftp channel.
protected voidsendAck(OutputStream out)
Send an ack.
voidsetLogListener(LogListener aListener)
Set a log listener.
protected inttrackProgress(long filesize, long totalLength, int percentTransmitted)
Track progress every 10% if 100kb < filesize < 1mb.
protected voidwaitForAck(InputStream in)
Reads the response, throws a BuildException if the response indicates an error.

Constructor Detail

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 Detail

execute

public abstract void execute()
Carry out the transfer.

Throws: IOException on I/O errors JSchException on ssh errors

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)
Open an ssh channel.

Parameters: command the command to use

Returns: the channel

Throws: JSchException on error

openSftpChannel

protected ChannelSftp openSftpChannel()
Open an ssh sftp channel.

Returns: the channel

Throws: JSchException on error

sendAck

protected void sendAck(OutputStream out)
Send an ack.

Parameters: out the output stream to use

Throws: IOException on error

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 < filesize < 1mb. 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)
Reads the response, throws a BuildException if the response indicates an error.

Parameters: in the input stream to use

Throws: IOException on I/O error BuildException on other errors