Class FtpOperations
- java.lang.Object
-
- org.apache.camel.component.file.remote.FtpOperations
-
- All Implemented Interfaces:
org.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>,RemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
- Direct Known Subclasses:
FtpsOperations
public class FtpOperations extends Object implements RemoteFileOperations<org.apache.commons.net.ftp.FTPFile>
FTP remote file operations
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.net.ftp.FTPClientclientprotected FtpClientActivityListenerclientActivityListenerprotected org.apache.commons.net.ftp.FTPClientConfigclientConfigprotected FtpEndpoint<org.apache.commons.net.ftp.FTPFile>endpointprotected org.slf4j.Loggerlog
-
Constructor Summary
Constructors Constructor Description FtpOperations(org.apache.commons.net.ftp.FTPClient client, org.apache.commons.net.ftp.FTPClientConfig clientConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbuildDirectory(String directory, boolean absolute)voidchangeCurrentDirectory(String path)voidchangeToParentDirectory()booleanconnect(RemoteFileConfiguration configuration, org.apache.camel.Exchange exchange)Connects to the remote serverbooleandeleteFile(String name)voiddisconnect()Disconnects from the remote serverprotected booleandoConnect(RemoteFileConfiguration configuration, org.apache.camel.Exchange exchange)protected voiddoDisconnect()booleanexistsFile(String name)protected booleanfastExistsFile(String name)voidforceDisconnect()Forces a hard disconnect from the remote server and cause the client to be re-created on next poll.org.apache.commons.net.ftp.FTPClientgetClient()FtpClientActivityListenergetClientActivityListener()StringgetCurrentDirectory()protected org.apache.commons.net.ftp.FTPClientgetFtpClient()booleanisConnected()Returns whether we are connected to the remote server or notorg.apache.commons.net.ftp.FTPFile[]listFiles()org.apache.commons.net.ftp.FTPFile[]listFiles(String path)org.apache.camel.component.file.GenericFile<org.apache.commons.net.ftp.FTPFile>newGenericFile()voidreleaseRetrievedFileResources(org.apache.camel.Exchange exchange)booleanrenameFile(String from, String to)booleanretrieveFile(String name, org.apache.camel.Exchange exchange, long size)booleansendNoop()Sends a noop command to the remote serverbooleansendSiteCommand(String command)Sends a site command to the remote servervoidsetClientActivityListener(FtpClientActivityListener clientActivityListener)voidsetEndpoint(org.apache.camel.component.file.GenericFileEndpoint<org.apache.commons.net.ftp.FTPFile> endpoint)booleanstoreFile(String name, org.apache.camel.Exchange exchange, long size)
-
-
-
Field Detail
-
log
protected final org.slf4j.Logger log
-
client
protected final org.apache.commons.net.ftp.FTPClient client
-
clientConfig
protected final org.apache.commons.net.ftp.FTPClientConfig clientConfig
-
endpoint
protected FtpEndpoint<org.apache.commons.net.ftp.FTPFile> endpoint
-
clientActivityListener
protected FtpClientActivityListener clientActivityListener
-
-
Method Detail
-
setEndpoint
public void setEndpoint(org.apache.camel.component.file.GenericFileEndpoint<org.apache.commons.net.ftp.FTPFile> endpoint)
- Specified by:
setEndpointin interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>
-
getClientActivityListener
public FtpClientActivityListener getClientActivityListener()
-
setClientActivityListener
public void setClientActivityListener(FtpClientActivityListener clientActivityListener)
-
newGenericFile
public org.apache.camel.component.file.GenericFile<org.apache.commons.net.ftp.FTPFile> newGenericFile()
- Specified by:
newGenericFilein interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>
-
connect
public boolean connect(RemoteFileConfiguration configuration, org.apache.camel.Exchange exchange) throws org.apache.camel.component.file.GenericFileOperationFailedException
Description copied from interface:RemoteFileOperationsConnects to the remote server- Specified by:
connectin interfaceRemoteFileOperations<org.apache.commons.net.ftp.FTPFile>- Parameters:
configuration- configurationexchange- the exchange that trigger the connect (if any)- Returns:
- true if connected
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException- can be thrown
-
doConnect
protected boolean doConnect(RemoteFileConfiguration configuration, org.apache.camel.Exchange exchange) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
isConnected
public boolean isConnected() throws org.apache.camel.component.file.GenericFileOperationFailedExceptionDescription copied from interface:RemoteFileOperationsReturns whether we are connected to the remote server or not- Specified by:
isConnectedin interfaceRemoteFileOperations<org.apache.commons.net.ftp.FTPFile>- Returns:
- true if connected, false if not
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException- can be thrown
-
disconnect
public void disconnect() throws org.apache.camel.component.file.GenericFileOperationFailedExceptionDescription copied from interface:RemoteFileOperationsDisconnects from the remote server- Specified by:
disconnectin interfaceRemoteFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException- can be thrown
-
forceDisconnect
public void forceDisconnect() throws org.apache.camel.component.file.GenericFileOperationFailedExceptionDescription copied from interface:RemoteFileOperationsForces a hard disconnect from the remote server and cause the client to be re-created on next poll.- Specified by:
forceDisconnectin interfaceRemoteFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException- can be thrown
-
doDisconnect
protected void doDisconnect() throws org.apache.camel.component.file.GenericFileOperationFailedException- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
deleteFile
public boolean deleteFile(String name) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
deleteFilein interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
renameFile
public boolean renameFile(String from, String to) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
renameFilein interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
buildDirectory
public boolean buildDirectory(String directory, boolean absolute) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
buildDirectoryin interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
retrieveFile
public boolean retrieveFile(String name, org.apache.camel.Exchange exchange, long size) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
retrieveFilein interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
releaseRetrievedFileResources
public void releaseRetrievedFileResources(org.apache.camel.Exchange exchange) throws org.apache.camel.component.file.GenericFileOperationFailedException- Specified by:
releaseRetrievedFileResourcesin interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
storeFile
public boolean storeFile(String name, org.apache.camel.Exchange exchange, long size) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
storeFilein interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
existsFile
public boolean existsFile(String name) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
existsFilein interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
fastExistsFile
protected boolean fastExistsFile(String name) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
getCurrentDirectory
public String getCurrentDirectory() throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
getCurrentDirectoryin interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
changeCurrentDirectory
public void changeCurrentDirectory(String path) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
changeCurrentDirectoryin interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
changeToParentDirectory
public void changeToParentDirectory() throws org.apache.camel.component.file.GenericFileOperationFailedException- Specified by:
changeToParentDirectoryin interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
listFiles
public org.apache.commons.net.ftp.FTPFile[] listFiles() throws org.apache.camel.component.file.GenericFileOperationFailedException- Specified by:
listFilesin interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
listFiles
public org.apache.commons.net.ftp.FTPFile[] listFiles(String path) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
listFilesin interfaceorg.apache.camel.component.file.GenericFileOperations<org.apache.commons.net.ftp.FTPFile>- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
sendNoop
public boolean sendNoop() throws org.apache.camel.component.file.GenericFileOperationFailedExceptionDescription copied from interface:RemoteFileOperationsSends a noop command to the remote server- Specified by:
sendNoopin interfaceRemoteFileOperations<org.apache.commons.net.ftp.FTPFile>- Returns:
- true if the noop was a success, false otherwise
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException- can be thrown
-
sendSiteCommand
public boolean sendSiteCommand(String command) throws org.apache.camel.component.file.GenericFileOperationFailedException
Description copied from interface:RemoteFileOperationsSends a site command to the remote server- Specified by:
sendSiteCommandin interfaceRemoteFileOperations<org.apache.commons.net.ftp.FTPFile>- Parameters:
command- the command- Returns:
- true if the command was a success, false otherwise
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException- can be thrown
-
getFtpClient
protected org.apache.commons.net.ftp.FTPClient getFtpClient()
-
getClient
public org.apache.commons.net.ftp.FTPClient getClient()
-
-