org.apache.ivy.plugins.repository.vsftp

Class VsftpRepository

public class VsftpRepository extends AbstractRepository

Repository using SecureCRT vsftp command line program to access an sftp repository This is especially useful to leverage the gssapi authentication supported by SecureCRT. In caseswhere usual sftp is enough, prefer the 100% java solution of sftp repository. This requires SecureCRT to be in the PATH. Tested with SecureCRT 5.0.5
Method Summary
voiddisconnect()
protected voidensureConnectionOpened()
voidget(String source, File destination)
StringgetAuthentication()
protected StringgetConnectionCommand()
protected PatterngetExpectedDownloadMessage(String source, File to)
protected PatterngetExpectedRemoveMessage(String destination)
protected PatterngetExpectedUploadMessage(File source, String to)
StringgetHost()
protected ResourcegetInitResource(String source)
longgetReadTimeout()
ResourcegetResource(String source)
protected StringgetSingleCommand(String command)
StringgetUsername()
Listlist(String parent)
protected ResourcelslToResource(String file, String responseLine)
Parses a ls -l line and transforms it in a resource
voidput(File source, String destination, boolean overwrite)
protected StringreadResponse(boolean sendErrorAsResponse)
protected StringreadResponse(boolean sendErrorAsResponse, long timeout)
protected StringsendCommand(String command)
protected voidsendCommand(String command, Pattern expectedResponse)
protected voidsendCommand(String command, Pattern expectedResponse, long timeout)
The behaviour of vsftp with some commands is to log the resulting message on the error stream, even if everything is ok.
protected StringsendCommand(String command, boolean sendErrorAsResponse)
protected StringsendCommand(String command, boolean sendErrorAsResponse, boolean single)
protected StringsendCommand(String command, boolean sendErrorAsResponse, long timeout)
protected StringsendCommand(String command, boolean sendErrorAsResponse, boolean single, long timeout)
voidsetAuthentication(String authentication)
voidsetHost(String host)
voidsetReadTimeout(long readTimeout)
voidsetReuseConnection(long time)
Sets the reuse connection time.
voidsetUsername(String username)
StringtoString()

Method Detail

disconnect

public void disconnect()

ensureConnectionOpened

protected void ensureConnectionOpened()

get

public void get(String source, File destination)

getAuthentication

public String getAuthentication()

getConnectionCommand

protected String getConnectionCommand()

getExpectedDownloadMessage

protected Pattern getExpectedDownloadMessage(String source, File to)

getExpectedRemoveMessage

protected Pattern getExpectedRemoveMessage(String destination)

getExpectedUploadMessage

protected Pattern getExpectedUploadMessage(File source, String to)

getHost

public String getHost()

getInitResource

protected Resource getInitResource(String source)

getReadTimeout

public long getReadTimeout()

getResource

public Resource getResource(String source)

getSingleCommand

protected String getSingleCommand(String command)

getUsername

public String getUsername()

list

public List list(String parent)

lslToResource

protected Resource lslToResource(String file, String responseLine)
Parses a ls -l line and transforms it in a resource

Parameters: file responseLine

Returns:

put

public void put(File source, String destination, boolean overwrite)

readResponse

protected String readResponse(boolean sendErrorAsResponse)

readResponse

protected String readResponse(boolean sendErrorAsResponse, long timeout)

sendCommand

protected String sendCommand(String command)

sendCommand

protected void sendCommand(String command, Pattern expectedResponse)

sendCommand

protected void sendCommand(String command, Pattern expectedResponse, long timeout)
The behaviour of vsftp with some commands is to log the resulting message on the error stream, even if everything is ok. So it's quite difficult if there was an error or not. Hence we compare the response with the expected message and deal with it. The problem is that this is very specific to the version of vsftp used for the test, That's why expected messages are obtained using overridable protected methods.

sendCommand

protected String sendCommand(String command, boolean sendErrorAsResponse)

sendCommand

protected String sendCommand(String command, boolean sendErrorAsResponse, boolean single)

sendCommand

protected String sendCommand(String command, boolean sendErrorAsResponse, long timeout)

sendCommand

protected String sendCommand(String command, boolean sendErrorAsResponse, boolean single, long timeout)

setAuthentication

public void setAuthentication(String authentication)

setHost

public void setHost(String host)

setReadTimeout

public void setReadTimeout(long readTimeout)

setReuseConnection

public void setReuseConnection(long time)
Sets the reuse connection time. The same connection will be reused if the time here does not last between two commands. O indicates that the connection should never be reused

Parameters: time

setUsername

public void setUsername(String username)

toString

public String toString()