Class SftpOperations
- java.lang.Object
-
- org.apache.camel.component.file.remote.SftpOperations
-
- All Implemented Interfaces:
org.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
,RemoteFileOperations<SftpRemoteFile>
public class SftpOperations extends Object implements RemoteFileOperations<SftpRemoteFile>
SFTP remote file operations The JSCH session and channel are not thread-safe so we need to synchronize access to using this operation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SftpOperations.ExtendedUserInfo
Extended user info which supports interactive keyboard mode, by entering the password.
-
Constructor Summary
Constructors Constructor Description SftpOperations()
SftpOperations(com.jcraft.jsch.Proxy proxy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
buildDirectory(String directory, boolean absolute)
void
changeCurrentDirectory(String path)
void
changeToParentDirectory()
boolean
connect(RemoteFileConfiguration configuration, org.apache.camel.Exchange exchange)
Connects to the remote serverprotected com.jcraft.jsch.Session
createSession(RemoteFileConfiguration configuration)
boolean
deleteFile(String name)
void
disconnect()
Disconnects from the remote serverboolean
existsFile(String name)
protected boolean
fastExistsFile(String name)
void
forceDisconnect()
Forces a hard disconnect from the remote server and cause the client to be re-created on next poll.String
getCurrentDirectory()
boolean
isConnected()
Returns whether we are connected to the remote server or notSftpRemoteFile[]
listFiles()
SftpRemoteFile[]
listFiles(String path)
org.apache.camel.component.file.GenericFile<SftpRemoteFile>
newGenericFile()
void
releaseRetrievedFileResources(org.apache.camel.Exchange exchange)
boolean
renameFile(String from, String to)
boolean
retrieveFile(String name, org.apache.camel.Exchange exchange, long size)
boolean
sendNoop()
Sends a noop command to the remote serverboolean
sendSiteCommand(String command)
Sends a site command to the remote servervoid
setEndpoint(org.apache.camel.component.file.GenericFileEndpoint<SftpRemoteFile> endpoint)
boolean
storeFile(String name, org.apache.camel.Exchange exchange, long size)
-
-
-
Method Detail
-
setEndpoint
public void setEndpoint(org.apache.camel.component.file.GenericFileEndpoint<SftpRemoteFile> endpoint)
- Specified by:
setEndpoint
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
-
newGenericFile
public org.apache.camel.component.file.GenericFile<SftpRemoteFile> newGenericFile()
- Specified by:
newGenericFile
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
-
connect
public boolean connect(RemoteFileConfiguration configuration, org.apache.camel.Exchange exchange) throws org.apache.camel.component.file.GenericFileOperationFailedException
Description copied from interface:RemoteFileOperations
Connects to the remote server- Specified by:
connect
in interfaceRemoteFileOperations<SftpRemoteFile>
- 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
-
createSession
protected com.jcraft.jsch.Session createSession(RemoteFileConfiguration configuration) throws com.jcraft.jsch.JSchException
- Throws:
com.jcraft.jsch.JSchException
-
isConnected
public boolean isConnected() throws org.apache.camel.component.file.GenericFileOperationFailedException
Description copied from interface:RemoteFileOperations
Returns whether we are connected to the remote server or not- Specified by:
isConnected
in interfaceRemoteFileOperations<SftpRemoteFile>
- 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.GenericFileOperationFailedException
Description copied from interface:RemoteFileOperations
Disconnects from the remote server- Specified by:
disconnect
in interfaceRemoteFileOperations<SftpRemoteFile>
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
- can be thrown
-
forceDisconnect
public void forceDisconnect() throws org.apache.camel.component.file.GenericFileOperationFailedException
Description copied from interface:RemoteFileOperations
Forces a hard disconnect from the remote server and cause the client to be re-created on next poll.- Specified by:
forceDisconnect
in interfaceRemoteFileOperations<SftpRemoteFile>
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
- can be thrown
-
deleteFile
public boolean deleteFile(String name) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
deleteFile
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
renameFile
public boolean renameFile(String from, String to) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
renameFile
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
buildDirectory
public boolean buildDirectory(String directory, boolean absolute) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
buildDirectory
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
getCurrentDirectory
public String getCurrentDirectory() throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
getCurrentDirectory
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
changeCurrentDirectory
public void changeCurrentDirectory(String path) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
changeCurrentDirectory
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
changeToParentDirectory
public void changeToParentDirectory() throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
changeToParentDirectory
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
listFiles
public SftpRemoteFile[] listFiles() throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
listFiles
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
listFiles
public SftpRemoteFile[] listFiles(String path) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
listFiles
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- 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:
retrieveFile
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- 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:
releaseRetrievedFileResources
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- 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:
storeFile
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
-
existsFile
public boolean existsFile(String name) throws org.apache.camel.component.file.GenericFileOperationFailedException
- Specified by:
existsFile
in interfaceorg.apache.camel.component.file.GenericFileOperations<SftpRemoteFile>
- 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
-
sendNoop
public boolean sendNoop() throws org.apache.camel.component.file.GenericFileOperationFailedException
Description copied from interface:RemoteFileOperations
Sends a noop command to the remote server- Specified by:
sendNoop
in interfaceRemoteFileOperations<SftpRemoteFile>
- 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:RemoteFileOperations
Sends a site command to the remote server- Specified by:
sendSiteCommand
in interfaceRemoteFileOperations<SftpRemoteFile>
- Parameters:
command
- the command- Returns:
- true if the command was a success, false otherwise
- Throws:
org.apache.camel.component.file.GenericFileOperationFailedException
- can be thrown
-
-