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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate Threadprivate static final intprivate static final intprivate static final intprivate Readerprivate static final intprivate StringBuilderprivate longprivate Threadprivate static final SimpleDateFormatprivate static final intprivate Stringprivate Readerprivate booleanprivate Ivyprivate longprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate PrintWriterprivate Processprivate static final Stringprivate static final intprivate static final intprivate longprivate static final intprivate longprivate String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate static StringBuilderchomp(StringBuilder str) private voidcleanup()Called whenever an api level method endprivate voidCalled whenever an api level method endprivate voidprivate booleanvoidprotected voidprivate voidvoidFetch a resource from the repository.protected Stringprotected PatterngetExpectedDownloadMessage(String source, File to) protected PatterngetExpectedRemoveMessage(String destination) protected PatterngetExpectedUploadMessage(File source, String to) getHost()protected ResourcegetInitResource(String source) longgetResource(String source) Return the resource associated with a specified identifier.protected StringgetSingleCommand(String command) private voidinitIvy()Return a listing of resources namesprotected ResourcelslToResource(String file, String responseLine) Parses a ls -l line and transforms it in a resourceprivate voidvoidprotected StringreadResponse(boolean sendErrorAsResponse) protected StringreadResponse(boolean sendErrorAsResponse, long timeout) protected StringsendCommand(String command) protected StringsendCommand(String command, boolean sendErrorAsResponse) protected StringsendCommand(String command, boolean sendErrorAsResponse, boolean single) protected StringsendCommand(String command, boolean sendErrorAsResponse, boolean single, long timeout) protected StringsendCommand(String command, boolean sendErrorAsResponse, long timeout) 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.private voidsendSingleCommand(String command) voidsetAuthentication(String authentication) voidvoidsetReadTimeout(long readTimeout) voidsetReuseConnection(long time) Sets the reuse connection time.voidsetUsername(String username) toString()private voidMethods 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
-
Field Details
-
LS_DATE_INDEX4
private static final int LS_DATE_INDEX4- See Also:
-
LS_DATE_INDEX3
private static final int LS_DATE_INDEX3- See Also:
-
LS_DATE_INDEX2
private static final int LS_DATE_INDEX2- See Also:
-
LS_DATE_INDEX1
private static final int LS_DATE_INDEX1- See Also:
-
LS_SIZE_INDEX
private static final int LS_SIZE_INDEX- See Also:
-
LS_PARTS_NUMBER
private static final int LS_PARTS_NUMBER- See Also:
-
DISCONNECT_COMMAND_TIMEOUT
private static final int DISCONNECT_COMMAND_TIMEOUT- See Also:
-
REUSE_CONNECTION_SLEEP_TIME
private static final int REUSE_CONNECTION_SLEEP_TIME- See Also:
-
READER_ALIVE_SLEEP_TIME
private static final int READER_ALIVE_SLEEP_TIME- See Also:
-
MAX_READER_ALIVE_ATTEMPT
private static final int MAX_READER_ALIVE_ATTEMPT- See Also:
-
ERROR_SLEEP_TIME
private static final int ERROR_SLEEP_TIME- See Also:
-
PROMPT_SLEEP_TIME
private static final int PROMPT_SLEEP_TIME- See Also:
-
MAX_READ_PROMPT_ATTEMPT
private static final int MAX_READ_PROMPT_ATTEMPT- See Also:
-
GET_JOIN_MAX_TIME
private static final int GET_JOIN_MAX_TIME- See Also:
-
DEFAULT_REUSE_CONNECTION_TIME
private static final int DEFAULT_REUSE_CONNECTION_TIME- See Also:
-
DEFAULT_READ_TIMEOUT
private static final int DEFAULT_READ_TIMEOUT- See Also:
-
PROMPT
- See Also:
-
FORMAT
-
host
-
username
-
authentication
-
in
-
err
-
out
-
errors
-
readTimeout
private long readTimeout -
reuseConnection
private long reuseConnection -
lastCommand
private volatile long lastCommand -
inCommand
private volatile boolean inCommand -
process
-
connectionCleaner
-
errorsReader
-
errorsLastUpdateTime
private volatile long errorsLastUpdateTime -
ivy
-
-
Constructor Details
-
VsftpRepository
public VsftpRepository() -
VsftpRepository
-
-
Method Details
-
getResource
Description copied from interface:RepositoryReturn 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.
-
initIvy
private void initIvy() -
getInitResource
- Throws:
IOException
-
get
Description copied from interface:RepositoryFetch 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:RepositoryReturn 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:
putin classAbstractRepository- Throws:
IOException
-
mkdirs
- Throws:
IOException
-
dirExists
- 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
-
sendSingleCommand
- Throws:
IOException
-
ensureConnectionOpened
- Throws:
IOException
-
updateLastCommandTime
private void updateLastCommandTime() -
exec
- Throws:
IOException
-
checkInterrupted
private void checkInterrupted() -
cleanup
Called whenever an api level method end -
cleanup
private void cleanup()Called whenever an api level method end -
disconnect
public void disconnect() -
closeConnection
private void closeConnection() -
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
-
chomp
-
toString
- Overrides:
toStringin 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)
-