public abstract class AbstractSftpClient extends AbstractLoggingBean implements SftpClient, RawSftpClient
SftpClient.Attribute, SftpClient.Attributes, SftpClient.CloseableHandle, SftpClient.CopyMode, SftpClient.DirEntry, SftpClient.Handle, SftpClient.OpenModeNamedResource.UtilslogDEFAULT_CHANNEL_OPEN_TIMEOUT, DEFAULT_READ_BUFFER_SIZE, DEFAULT_WAIT_TIMEOUT, DEFAULT_WRITE_BUFFER_SIZE, IO_BUFFER_SIZE, MIN_BUFFER_SIZE, MIN_READ_BUFFER_SIZE, MIN_WRITE_BUFFER_SIZE, SFTP_CHANNEL_OPEN_TIMEOUTBY_NAME_COMPARATOR, NAME_EXTRACTOR| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSftpClient() |
| Modifier and Type | Method and Description |
|---|---|
String |
canonicalPath(String path) |
protected SftpClient.Attributes |
checkAttributes(Buffer buffer) |
protected SftpClient.Attributes |
checkAttributes(int cmd,
Buffer request) |
protected int |
checkData(Buffer buffer,
int dstoff,
byte[] dst) |
protected int |
checkData(int cmd,
Buffer request,
int dstOffset,
byte[] dst) |
protected List<SftpClient.DirEntry> |
checkDir(Buffer buffer) |
protected byte[] |
checkHandle(Buffer buffer) |
protected byte[] |
checkHandle(int cmd,
Buffer request) |
protected String |
checkOneName(Buffer buffer) |
protected String |
checkOneName(int cmd,
Buffer request) |
protected void |
checkStatus(Buffer buffer)
Checks if the incoming response is an
SSH_FXP_STATUS one,
and if so whether the substatus is SSH_FX_OK. |
protected void |
checkStatus(int cmd,
Buffer request)
Sends the specified command, waits for the response and then invokes
checkStatus(Buffer) |
protected void |
checkStatus(int id,
int substatus,
String msg,
String lang) |
void |
close(SftpClient.Handle handle) |
<E extends SftpClientExtension> |
getExtension(Class<? extends E> extensionType) |
protected SftpClientExtension |
getExtension(SftpClientExtensionFactory factory) |
SftpClientExtension |
getExtension(String extensionName) |
String |
getName() |
protected Map<String,Object> |
getParsedServerExtensions() |
protected Map<String,Object> |
getParsedServerExtensions(Map<String,byte[]> extensions) |
void |
link(String linkPath,
String targetPath,
boolean symbolic) |
void |
lock(SftpClient.Handle handle,
long offset,
long length,
int mask) |
SftpClient.Attributes |
lstat(String path) |
void |
mkdir(String path) |
SftpClient.CloseableHandle |
open(String path)
Opens a remote file for read
|
SftpClient.CloseableHandle |
open(String path,
Collection<SftpClient.OpenMode> options)
Opens a remote file with the specified mode(s)
|
SftpClient.CloseableHandle |
open(String path,
SftpClient.OpenMode... options)
Opens a remote file with the specified mode(s)
|
SftpClient.CloseableHandle |
openDir(String path) |
int |
read(SftpClient.Handle handle,
long fileOffset,
byte[] dst) |
int |
read(SftpClient.Handle handle,
long fileOffset,
byte[] dst,
int dstOffset,
int len) |
InputStream |
read(String path) |
InputStream |
read(String path,
Collection<SftpClient.OpenMode> mode) |
InputStream |
read(String path,
int bufferSize) |
InputStream |
read(String path,
int bufferSize,
Collection<SftpClient.OpenMode> mode) |
InputStream |
read(String path,
int bufferSize,
SftpClient.OpenMode... mode) |
InputStream |
read(String path,
SftpClient.OpenMode... mode) |
protected SftpClient.Attributes |
readAttributes(Buffer buffer) |
List<SftpClient.DirEntry> |
readDir(SftpClient.Handle handle) |
Iterable<SftpClient.DirEntry> |
readDir(String path) |
String |
readLink(String path) |
protected FileTime |
readTime(Buffer buffer,
int flags) |
void |
remove(String path) |
void |
rename(String oldPath,
String newPath) |
void |
rename(String oldPath,
String newPath,
Collection<SftpClient.CopyMode> options) |
void |
rename(String oldPath,
String newPath,
SftpClient.CopyMode... options) |
void |
rmdir(String path) |
void |
setStat(SftpClient.Handle handle,
SftpClient.Attributes attributes) |
void |
setStat(String path,
SftpClient.Attributes attributes) |
SftpClient.Attributes |
stat(SftpClient.Handle handle) |
SftpClient.Attributes |
stat(String path) |
void |
symLink(String linkPath,
String targetPath) |
protected void |
throwStatusException(int id,
int substatus,
String msg,
String lang) |
void |
unlock(SftpClient.Handle handle,
long offset,
long length) |
void |
write(SftpClient.Handle handle,
long fileOffset,
byte[] src) |
void |
write(SftpClient.Handle handle,
long fileOffset,
byte[] src,
int srcOffset,
int len) |
OutputStream |
write(String path) |
OutputStream |
write(String path,
Collection<SftpClient.OpenMode> mode) |
OutputStream |
write(String path,
int bufferSize) |
OutputStream |
write(String path,
int bufferSize,
Collection<SftpClient.OpenMode> mode) |
OutputStream |
write(String path,
int bufferSize,
SftpClient.OpenMode... mode) |
OutputStream |
write(String path,
SftpClient.OpenMode... mode) |
protected void |
writeAttributes(Buffer buffer,
SftpClient.Attributes attributes) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetServerExtensions, getVersion, isClosinggetClientSessionreceive, sendpublic String getName()
getName in interface NamedResourcepublic SftpClient.CloseableHandle open(String path) throws IOException
SftpClientopen in interface SftpClientpath - The remote pathSftpClient.CloseableHandleIOException - If failed to open the remote filepublic SftpClient.CloseableHandle open(String path, SftpClient.OpenMode... options) throws IOException
SftpClientopen in interface SftpClientpath - The remote pathoptions - The desired mode - if none specified
then SftpClient.OpenMode.Read is assumedSftpClient.CloseableHandleIOException - If failed to open the remote filepublic void rename(String oldPath, String newPath) throws IOException
rename in interface SftpClientIOExceptionpublic void rename(String oldPath, String newPath, SftpClient.CopyMode... options) throws IOException
rename in interface SftpClientIOExceptionpublic InputStream read(String path) throws IOException
read in interface SftpClientIOExceptionpublic InputStream read(String path, int bufferSize) throws IOException
read in interface SftpClientIOExceptionpublic InputStream read(String path, SftpClient.OpenMode... mode) throws IOException
read in interface SftpClientIOExceptionpublic InputStream read(String path, int bufferSize, SftpClient.OpenMode... mode) throws IOException
read in interface SftpClientIOExceptionpublic InputStream read(String path, Collection<SftpClient.OpenMode> mode) throws IOException
read in interface SftpClientIOExceptionpublic int read(SftpClient.Handle handle, long fileOffset, byte[] dst) throws IOException
read in interface SftpClientIOExceptionpublic OutputStream write(String path) throws IOException
write in interface SftpClientIOExceptionpublic OutputStream write(String path, int bufferSize) throws IOException
write in interface SftpClientIOExceptionpublic OutputStream write(String path, SftpClient.OpenMode... mode) throws IOException
write in interface SftpClientIOExceptionpublic OutputStream write(String path, Collection<SftpClient.OpenMode> mode) throws IOException
write in interface SftpClientIOExceptionpublic OutputStream write(String path, int bufferSize, SftpClient.OpenMode... mode) throws IOException
write in interface SftpClientIOExceptionpublic void write(SftpClient.Handle handle, long fileOffset, byte[] src) throws IOException
write in interface SftpClientIOExceptionpublic void symLink(String linkPath, String targetPath) throws IOException
symLink in interface SftpClientIOExceptionpublic <E extends SftpClientExtension> E getExtension(Class<? extends E> extensionType)
getExtension in interface SftpClientE - The generic extension typeextensionType - The extension typeOptionalFeature.isSupported() - null if
this extension type is not implemented by the clientSftpClient.getServerExtensions()public SftpClientExtension getExtension(String extensionName)
getExtension in interface SftpClientextensionName - The extension nameOptionalFeature.isSupported() - null if
this extension type is not implemented by the clientSftpClient.getServerExtensions()protected SftpClientExtension getExtension(SftpClientExtensionFactory factory)
protected Map<String,Object> getParsedServerExtensions(Map<String,byte[]> extensions)
protected void checkStatus(int cmd,
Buffer request)
throws IOException
checkStatus(Buffer)cmd - The command to sendrequest - The request BufferIOException - If failed to send, receive or check the returned statusRawSftpClient.send(int, Buffer),
RawSftpClient.receive(int),
checkStatus(Buffer)protected void checkStatus(Buffer buffer) throws IOException
SSH_FXP_STATUS one,
and if so whether the substatus is SSH_FX_OK.buffer - The received response BufferIOException - If response does not carry a status or carries
a bad status codecheckStatus(int, int, String, String)protected void checkStatus(int id,
int substatus,
String msg,
String lang)
throws IOException
id - The request idsubstatus - The sub-status valuemsg - The messagelang - The languageIOException - if the sub-status is not SSH_FX_OKthrowStatusException(int, int, String, String)protected void throwStatusException(int id,
int substatus,
String msg,
String lang)
throws IOException
IOExceptionprotected byte[] checkHandle(int cmd,
Buffer request)
throws IOException
cmd - Command to be sentrequest - The Buffer containing the requestIOException - If failed to send/receive or process the responseRawSftpClient.send(int, Buffer),
RawSftpClient.receive(int),
checkHandle(Buffer)protected byte[] checkHandle(Buffer buffer) throws IOException
IOExceptionprotected SftpClient.Attributes checkAttributes(int cmd, Buffer request) throws IOException
cmd - Command to be sentrequest - Request BufferAttributesIOException - If failed to send/receive or process the responseRawSftpClient.send(int, Buffer),
RawSftpClient.receive(int),
checkAttributes(Buffer)protected SftpClient.Attributes checkAttributes(Buffer buffer) throws IOException
IOExceptionprotected String checkOneName(int cmd, Buffer request) throws IOException
cmd - Command to be sentrequest - The request BufferIOException - If failed to send/receive or process the responseRawSftpClient.send(int, Buffer),
RawSftpClient.receive(int),
checkOneName(Buffer)protected String checkOneName(Buffer buffer) throws IOException
IOExceptionprotected SftpClient.Attributes readAttributes(Buffer buffer) throws IOException
IOExceptionprotected void writeAttributes(Buffer buffer, SftpClient.Attributes attributes) throws IOException
IOExceptionpublic SftpClient.CloseableHandle open(String path, Collection<SftpClient.OpenMode> options) throws IOException
SftpClientopen in interface SftpClientpath - The remote pathoptions - The desired mode - if none specified
then SftpClient.OpenMode.Read is assumedSftpClient.CloseableHandleIOException - If failed to open the remote filepublic void close(SftpClient.Handle handle) throws IOException
close in interface SftpClientIOExceptionpublic void remove(String path) throws IOException
remove in interface SftpClientIOExceptionpublic void rename(String oldPath, String newPath, Collection<SftpClient.CopyMode> options) throws IOException
rename in interface SftpClientIOExceptionpublic int read(SftpClient.Handle handle, long fileOffset, byte[] dst, int dstOffset, int len) throws IOException
read in interface SftpClientIOExceptionprotected int checkData(int cmd,
Buffer request,
int dstOffset,
byte[] dst)
throws IOException
IOExceptionprotected int checkData(Buffer buffer, int dstoff, byte[] dst) throws IOException
IOExceptionpublic void write(SftpClient.Handle handle, long fileOffset, byte[] src, int srcOffset, int len) throws IOException
write in interface SftpClientIOExceptionpublic void mkdir(String path) throws IOException
mkdir in interface SftpClientIOExceptionpublic void rmdir(String path) throws IOException
rmdir in interface SftpClientIOExceptionpublic SftpClient.CloseableHandle openDir(String path) throws IOException
openDir in interface SftpClientIOExceptionpublic List<SftpClient.DirEntry> readDir(SftpClient.Handle handle) throws IOException
readDir in interface SftpClienthandle - Directory SftpClient.Handle to read fromList of entries - null to indicate no more entries
Note: the list may be incomplete since the client and
server have some internal imposed limit on the number of entries they
can process. Therefore several calls to this method may be required
(until null). In order to iterate over all the entries use
SftpClient.readDir(String)IOException - If failed to access the remote siteprotected List<SftpClient.DirEntry> checkDir(Buffer buffer) throws IOException
IOExceptionpublic String canonicalPath(String path) throws IOException
canonicalPath in interface SftpClientIOExceptionpublic SftpClient.Attributes stat(String path) throws IOException
stat in interface SftpClientIOExceptionpublic SftpClient.Attributes lstat(String path) throws IOException
lstat in interface SftpClientIOExceptionpublic SftpClient.Attributes stat(SftpClient.Handle handle) throws IOException
stat in interface SftpClientIOExceptionpublic void setStat(String path, SftpClient.Attributes attributes) throws IOException
setStat in interface SftpClientIOExceptionpublic void setStat(SftpClient.Handle handle, SftpClient.Attributes attributes) throws IOException
setStat in interface SftpClientIOExceptionpublic String readLink(String path) throws IOException
readLink in interface SftpClientIOExceptionpublic void link(String linkPath, String targetPath, boolean symbolic) throws IOException
link in interface SftpClientIOExceptionpublic void lock(SftpClient.Handle handle, long offset, long length, int mask) throws IOException
lock in interface SftpClientIOExceptionpublic void unlock(SftpClient.Handle handle, long offset, long length) throws IOException
unlock in interface SftpClientIOExceptionpublic Iterable<SftpClient.DirEntry> readDir(String path) throws IOException
readDir in interface SftpClientpath - The remote directory pathIterable that can be used to iterate over all the
directory entries (unlike SftpClient.readDir(Handle))IOException - If failed to access the remote siteSftpClient.readDir(Handle)public InputStream read(String path, int bufferSize, Collection<SftpClient.OpenMode> mode) throws IOException
read in interface SftpClientIOExceptionpublic OutputStream write(String path, int bufferSize, Collection<SftpClient.OpenMode> mode) throws IOException
write in interface SftpClientIOExceptionCopyright © 2008–2015 The Apache Software Foundation. All rights reserved.