Package adams.core.io.fileoperations
Class SftpFileOperations
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.io.fileoperations.AbstractFileOperations
-
- adams.core.io.fileoperations.AbstractRemoteFileOperations
-
- adams.core.io.fileoperations.SftpFileOperations
-
- All Implemented Interfaces:
FileOperations
,RemoteFileOperations
,LoggingLevelHandler
,LoggingSupporter
,SizeOfHandler
,Serializable
public class SftpFileOperations extends AbstractRemoteFileOperations
SFTP file operations.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected SSHSessionProvider
m_Provider
the session provider to use.-
Fields inherited from class adams.core.io.fileoperations.AbstractRemoteFileOperations
m_Direction, m_LocalOperations
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description SftpFileOperations()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
copyFile(String source, String target)
Copies a file.protected String
deleteRemote(String path)
Deletes a remote file/dir.protected String
deleteRemoteDir(com.jcraft.jsch.ChannelSftp channel, String path)
Deletes a remote dir.protected String
deleteRemoteFile(com.jcraft.jsch.ChannelSftp channel, String path)
Deletes a remote file.SSHSessionProvider
getProvider()
Returns the SSH session provider in use.protected boolean
isDirRemote(String path)
Checks whether the remote path is a directory.boolean
isSupported(Operation op)
Checks whether the given operation is supported.protected String
mkdirRemote(String dir)
Creates the remote directory.protected DirectoryLister
newRemoteDirectoryLister()
Returns an instance of the remote directory lister.protected String
renameRemote(String source, String target)
Renames a remote file/dir.void
setProvider(SSHSessionProvider value)
Sets the SSH session provider to use.-
Methods inherited from class adams.core.io.fileoperations.AbstractRemoteFileOperations
copy, copyDir, delete, deleteLocal, duplicate, getDirection, initialize, isDir, isDirLocal, mkdir, mkdirLocal, move, rename, renameLocal, setDirection
-
Methods inherited from class adams.core.logging.CustomLoggingLevelObject
setLoggingLevel
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Provider
protected SSHSessionProvider m_Provider
the session provider to use.
-
-
Method Detail
-
setProvider
public void setProvider(SSHSessionProvider value)
Sets the SSH session provider to use.- Parameters:
value
- the provider
-
getProvider
public SSHSessionProvider getProvider()
Returns the SSH session provider in use.- Returns:
- the provider, null if none set
-
isSupported
public boolean isSupported(Operation op)
Checks whether the given operation is supported.- Parameters:
op
- the operation to check- Returns:
- true if supported
-
copyFile
protected String copyFile(String source, String target)
Copies a file.- Specified by:
copyFile
in classAbstractRemoteFileOperations
- Parameters:
source
- the source filetarget
- the target file- Returns:
- null if successful, otherwise error message
-
newRemoteDirectoryLister
protected DirectoryLister newRemoteDirectoryLister()
Returns an instance of the remote directory lister.- Specified by:
newRemoteDirectoryLister
in classAbstractRemoteFileOperations
- Returns:
- the directory lister
-
renameRemote
protected String renameRemote(String source, String target)
Renames a remote file/dir.- Specified by:
renameRemote
in classAbstractRemoteFileOperations
- Parameters:
source
- the source file/dir (old)target
- the target file/dir (new)- Returns:
- null if successful, otherwise error message
-
deleteRemoteDir
protected String deleteRemoteDir(com.jcraft.jsch.ChannelSftp channel, String path)
Deletes a remote dir. Must be empty.- Parameters:
channel
- the channel to usepath
- the file/dir to delete- Returns:
- null if successful, otherwise error message
-
deleteRemoteFile
protected String deleteRemoteFile(com.jcraft.jsch.ChannelSftp channel, String path)
Deletes a remote file.- Parameters:
channel
- the channel to usepath
- the file/dir to delete- Returns:
- null if successful, otherwise error message
-
deleteRemote
protected String deleteRemote(String path)
Deletes a remote file/dir.- Specified by:
deleteRemote
in classAbstractRemoteFileOperations
- Parameters:
path
- the file/dir to delete- Returns:
- null if successful, otherwise error message
-
mkdirRemote
protected String mkdirRemote(String dir)
Creates the remote directory.- Specified by:
mkdirRemote
in classAbstractRemoteFileOperations
- Parameters:
dir
- the directory to create- Returns:
- null if successful, otherwise error message
-
isDirRemote
protected boolean isDirRemote(String path)
Checks whether the remote path is a directory.- Specified by:
isDirRemote
in classAbstractRemoteFileOperations
- Parameters:
path
- the path to check- Returns:
- true if path exists and is a directory
-
-