public abstract class FtpConnectionImp extends FileTransferConnectionUsingPassword
FileTransferConnection.UserInfo
DEFAULT_EXPIRATION, DEFAULT_MAX_CACHE_SIZE
log
Constructor and Description |
---|
FtpConnectionImp()
Default Constructor with the following default values.
|
Modifier and Type | Method and Description |
---|---|
protected FileTransferClient |
create(java.lang.String remoteHost,
int port,
FileTransferConnection.UserInfo ui)
Create an instance of the
FileTransferClient for use with the producer or consumer. |
protected abstract ApacheFtpClientImpl |
createFtpClient(java.lang.String remoteHost,
int port,
int seconds) |
int |
defaultControlPort() |
KeyValuePairSet |
getAdditionalSettings() |
java.lang.String |
getDefaultAccount() |
FtpDataMode |
getFtpDataMode() |
java.lang.String |
getServerTimezone() |
java.lang.Integer |
getSocketTimeout() |
TransferType |
getTransferType()
Get the transfer type.
|
protected void |
initConnection()
Initialise the underlying connection.
|
void |
setAdditionalSettings(KeyValuePairSet s)
Set any additional settings that might need to be applied.
|
void |
setDefaultAccount(java.lang.String defaultAccount)
Some FTP Servers force you to have an account which is separate from the username.
|
void |
setFtpDataMode(FtpDataMode s)
Set the FTP Data Mode.
|
void |
setServerTimezone(java.lang.String tz)
Specify the timezone which the server is in.
|
void |
setSocketTimeout(java.lang.Integer i)
The socket timeout in milliseconds for connect / read and write operations.
|
void |
setTransferType(TransferType s)
Set the transfer type.
|
createUserInfo, defaultPassword, getDefaultPassword, setDefaultPassword
acceptProtocol, additionalDebug, cacheConnection, closeConnection, connect, disconnect, expirationMillis, forceRelativePath, getAdditionalDebug, getCacheConnection, getCacheExpiration, getDefaultControlPort, getDefaultUserName, getDirectoryRoot, getForceRelativePath, getMaxClientCacheSize, getWindowsWorkAround, maxClientCacheSize, setAdditionalDebug, setCacheConnection, setCacheExpiration, setDefaultControlPort, setDefaultUserName, setForceRelativePath, setMaxClientCache, setWindowsWorkAround, windowsWorkaround, withCacheExpiration
prepareConnection, startConnection, stopConnection
addExceptionListener, addMessageConsumer, addMessageProducer, changeState, cloneForTesting, close, connectionErrorHandler, getConnectionErrorHandler, getLookupName, getUniqueId, getWorkersFirstOnShutdown, init, prepare, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveConnection, retrieveExceptionListeners, retrieveMessageConsumers, retrieveMessageProducers, setConnectionErrorHandler, setLookupName, setUniqueId, setWorkersFirstOnShutdown, start, stop, workersFirstOnShutdown
public FtpConnectionImp()
public TransferType getTransferType()
TransferType
public void setTransferType(TransferType s)
s
- the transfer type, default is TransferType.BINARY
TransferType
public java.lang.Integer getSocketTimeout()
public void setSocketTimeout(java.lang.Integer i)
i
- The socketTimeout to set; default is 60000public java.lang.String getServerTimezone()
public void setServerTimezone(java.lang.String tz)
If not explicitly specified then the server Timezone will be assumed to be the same as the client timezone. This might lead to incorrect modification timestamps.
tz
- any valid java timezone IDTimeZone.getTimeZone(String)
protected void initConnection() throws CoreException
AdaptrisConnectionImp
initConnection
in class FileTransferConnectionUsingPassword
CoreException
- wrapping any exception.AdaptrisConnectionImp.init()
protected abstract ApacheFtpClientImpl createFtpClient(java.lang.String remoteHost, int port, int seconds) throws java.io.IOException
java.io.IOException
protected FileTransferClient create(java.lang.String remoteHost, int port, FileTransferConnection.UserInfo ui) throws java.io.IOException, FileTransferException, PasswordException
FileTransferConnection
FileTransferClient
for use with the producer or consumer.create
in class FileTransferConnection
remoteHost
- the remote host.port
- the port to connect toui
- a local UserInfo containing username and passwordFileTransferClient
objectjava.io.IOException
- wrapping a general comms error.FileTransferException
- if a protocol specific exception occurred.PasswordException
public FtpDataMode getFtpDataMode()
public void setFtpDataMode(FtpDataMode s)
The following chart should help you remember how each FTP mode works:
Active FTP :
command : client >1023 -> server 21
data : client >1023 <- server 20
Passive FTP :
command : client >1023 -> server 21
data : client >1023 -> server >1023
Active FTP is beneficial to the FTP server admin, but detrimental to the client side admin. The FTP server attempts to make connections to random high ports on the client, this may not work for the following reasons
Passive FTP is beneficial to the client, but might be considered detrimental to the FTP server admin. The client will make both connections to the server, but one of them will be to a random high port, which would almost certainly be blocked by a firewall on the server side.
Since admins running FTP servers generally need to make their servers accessible to the greatest number of clients, they will almost certainly need to support passive FTP. Perhaps the FTP Server may be configured to use a limited range of ports for passive transfers (e.g. the ProFTPd PassivePorts directive) which can be added to the firewalls allowed list.
s
- either ACTIVE or PASSIVE, default is FtpDataMode.PASSIVE
FtpDataMode
public java.lang.String getDefaultAccount()
public void setDefaultAccount(java.lang.String defaultAccount)
Note that if a positive completion code is returned by the server when you submit the password, then the account is never submitted; so you can still share the same FtpConnection between multiple consumers provided that you have the same account name (or no account name) for each of the connections.
defaultAccount
- the defaultAccount to setpublic int defaultControlPort()
defaultControlPort
in class FileTransferConnection
public KeyValuePairSet getAdditionalSettings()
public void setAdditionalSettings(KeyValuePairSet s)
s
- any additional settings.ClientSettings.FTP
,
ClientSettings.FTPS