Class FtpConnectionImp
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisConnection,ComponentLifecycle,ComponentLifecycleExtension,StateManagedComponent
- Direct Known Subclasses:
FtpConnection,FtpSslConnection
-
Nested Class Summary
Nested classes/interfaces inherited from class com.adaptris.core.ftp.FileTransferConnection
FileTransferConnection.UserInfo -
Field Summary
Fields inherited from class com.adaptris.core.ftp.FileTransferConnection
DEFAULT_EXPIRATION, DEFAULT_MAX_CACHE_SIZEFields inherited from class com.adaptris.core.AdaptrisConnectionImp
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected FileTransferClientcreate(String remoteHost, int port, FileTransferConnection.UserInfo ui) Create an instance of theFileTransferClientfor use with the producer or consumer.protected abstract ApacheFtpClientImplcreateFtpClient(String remoteHost, int port, int seconds) intGet the transfer type.protected voidInitialise the underlying connection.voidSet any additional settings that might need to be applied.voidsetDefaultAccount(String defaultAccount) Some FTP Servers force you to have an account which is separate from the username.voidSet the FTP Data Mode.voidSpecify the timezone which the server is in.voidThe socket timeout in milliseconds for connect / read and write operations.voidSet the transfer type.Methods inherited from class com.adaptris.core.ftp.FileTransferConnectionUsingPassword
createUserInfo, defaultPassword, getDefaultPassword, setDefaultPasswordMethods inherited from class com.adaptris.core.ftp.FileTransferConnection
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, withCacheExpirationMethods inherited from class com.adaptris.core.NoOpConnection
prepareConnection, startConnection, stopConnectionMethods inherited from class com.adaptris.core.AdaptrisConnectionImp
addExceptionListener, addMessageConsumer, addMessageProducer, changeState, cloneForTesting, close, connectionErrorHandler, getConnectionErrorHandler, getUniqueId, getWorkersFirstOnShutdown, init, prepare, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveConnection, retrieveExceptionListeners, retrieveMessageConsumers, retrieveMessageProducers, setConnectionErrorHandler, setUniqueId, setWorkersFirstOnShutdown, start, stop, workersFirstOnShutdown
-
Constructor Details
-
FtpConnectionImp
public FtpConnectionImp()Default Constructor with the following default values.- ftpDebug is false
- defaultControlPort is 21
- See Also:
-
-
Method Details
-
getTransferType
Get the transfer type.- Returns:
- the transfer type.
- See Also:
-
setTransferType
Set the transfer type.- Parameters:
s- the transfer type, default isTransferType.BINARY- See Also:
-
getSocketTimeout
- Returns:
- Returns the socketTimeout.
-
setSocketTimeout
The socket timeout in milliseconds for connect / read and write operations.- Parameters:
i- The socketTimeout to set; default is 60000
-
getServerTimezone
- Returns:
- the serverTimezone
-
setServerTimezone
Specify the timezone which the server is in.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.
- Parameters:
tz- any valid java timezone ID- See Also:
-
initConnection
Description copied from class:AdaptrisConnectionImpInitialise the underlying connection.- Overrides:
initConnectionin classFileTransferConnectionUsingPassword- Throws:
CoreException- wrapping any exception.- See Also:
-
createFtpClient
protected abstract ApacheFtpClientImpl createFtpClient(String remoteHost, int port, int seconds) throws IOException - Throws:
IOException
-
create
protected FileTransferClient create(String remoteHost, int port, FileTransferConnection.UserInfo ui) throws IOException, FileTransferException, PasswordException Description copied from class:FileTransferConnectionCreate an instance of theFileTransferClientfor use with the producer or consumer.- Specified by:
createin classFileTransferConnection- Parameters:
remoteHost- the remote host.port- the port to connect toui- a local UserInfo containing username and password- Returns:
- a
FileTransferClientobject - Throws:
IOException- wrapping a general comms error.FileTransferException- if a protocol specific exception occurred.PasswordException
-
getFtpDataMode
-
setFtpDataMode
Set the FTP Data Mode.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 >1023Active 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
- The client has a firewall
- The client is connected in conjunction with a NAT device
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.
- Parameters:
s- either ACTIVE or PASSIVE, default isFtpDataMode.PASSIVE- See Also:
-
getDefaultAccount
- Returns:
- the defaultAccount
-
setDefaultAccount
Some FTP Servers force you to have an account which is separate from the username.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.
- Parameters:
defaultAccount- the defaultAccount to set
-
defaultControlPort
public int defaultControlPort()- Specified by:
defaultControlPortin classFileTransferConnection
-
getAdditionalSettings
-
setAdditionalSettings
Set any additional settings that might need to be applied.- Parameters:
s- any additional settings.- See Also:
-