Class VsftpRepository
java.lang.Object
org.apache.ivy.plugins.repository.AbstractRepository
org.apache.ivy.plugins.repository.vsftp.VsftpRepository
- All Implemented Interfaces:
Repository
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 cases where
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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
void
Fetch a resource from the repository.protected String
protected Pattern
getExpectedDownloadMessage
(String source, File to) protected Pattern
getExpectedRemoveMessage
(String destination) protected Pattern
getExpectedUploadMessage
(File source, String to) getHost()
protected Resource
getInitResource
(String source) long
getResource
(String source) Return the resource associated with a specified identifier.protected String
getSingleCommand
(String command) Return a listing of resources namesprotected Resource
lslToResource
(String file, String responseLine) Parses a ls -l line and transforms it in a resourcevoid
protected String
readResponse
(boolean sendErrorAsResponse) protected String
readResponse
(boolean sendErrorAsResponse, long timeout) protected String
sendCommand
(String command) protected String
sendCommand
(String command, boolean sendErrorAsResponse) protected String
sendCommand
(String command, boolean sendErrorAsResponse, boolean single) protected String
sendCommand
(String command, boolean sendErrorAsResponse, boolean single, long timeout) protected String
sendCommand
(String command, boolean sendErrorAsResponse, long timeout) protected void
sendCommand
(String command, Pattern expectedResponse) 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.void
setAuthentication
(String authentication) void
void
setReadTimeout
(long readTimeout) void
setReuseConnection
(long time) Sets the reuse connection time.void
setUsername
(String username) toString()
Methods inherited from class org.apache.ivy.plugins.repository.AbstractRepository
addTransferListener, fireTransferCompleted, fireTransferCompleted, fireTransferError, fireTransferError, fireTransferEvent, fireTransferInitiated, fireTransferProgress, fireTransferStarted, fireTransferStarted, getFileSeparator, getName, getTimeoutConstraint, hasTransferListener, put, removeTransferListener, setName, standardize
-
Constructor Details
-
VsftpRepository
public VsftpRepository() -
VsftpRepository
-
-
Method Details
-
getResource
Description copied from interface:Repository
Return the resource associated with a specified identifier. If the resource does not exist, it should return a Resource with exists() returning false. An IOException should only be thrown when a real IO problem occurs, like the impossibility to connect to a server.- Parameters:
source
- A string identifying the resource.- Returns:
- The resource associated with the resource identifier.
- Throws:
IOException
- On error while trying to get resource.
-
getInitResource
- Throws:
IOException
-
get
Description copied from interface:Repository
Fetch a resource from the repository.- Parameters:
source
- A string identifying the resource to be fetched.destination
- Where to place the fetched resource.- Throws:
IOException
- On retrieval failure.
-
list
Description copied from interface:Repository
Return a listing of resources names- Parameters:
parent
- The parent directory from which to generate the listing.- Returns:
- A listing of the parent directory's file content
- Throws:
IOException
- On listing failure.
-
put
- Overrides:
put
in classAbstractRepository
- Throws:
IOException
-
sendCommand
- Throws:
IOException
-
sendCommand
- Throws:
IOException
-
sendCommand
protected void sendCommand(String command, Pattern expectedResponse, long timeout) throws IOException 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 overriddable protected methods.- Parameters:
command
- StringexpectedResponse
- Patterntimeout
- long- Throws:
IOException
- if something goes wrong
-
sendCommand
- Throws:
IOException
-
sendCommand
protected String sendCommand(String command, boolean sendErrorAsResponse, boolean single) throws IOException - Throws:
IOException
-
sendCommand
protected String sendCommand(String command, boolean sendErrorAsResponse, long timeout) throws IOException - Throws:
IOException
-
sendCommand
protected String sendCommand(String command, boolean sendErrorAsResponse, boolean single, long timeout) throws IOException - Throws:
IOException
-
readResponse
- Throws:
IOException
-
readResponse
- Throws:
IOException
-
ensureConnectionOpened
- Throws:
IOException
-
disconnect
public void disconnect() -
lslToResource
Parses a ls -l line and transforms it in a resource- Parameters:
file
- dittoresponseLine
- ditto- Returns:
- Resource
-
getSingleCommand
-
getConnectionCommand
-
getExpectedDownloadMessage
-
getExpectedRemoveMessage
-
getExpectedUploadMessage
-
getAuthentication
-
setAuthentication
-
getHost
-
setHost
-
getUsername
-
setUsername
-
toString
- Overrides:
toString
in classAbstractRepository
-
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
- long
-
getReadTimeout
public long getReadTimeout() -
setReadTimeout
public void setReadTimeout(long readTimeout)
-