private final class SftpFileSystem.Wrapper extends AbstractSftpClient
SftpClient.Attribute, SftpClient.Attributes, SftpClient.CloseableHandle, SftpClient.CopyMode, SftpClient.DirEntry, SftpClient.Handle, SftpClient.OpenMode
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicInteger |
count |
private SftpClient |
delegate |
private int |
readSize |
private int |
writeSize |
errorDataHandler, INIT_COMMAND_SIZE
log
DEFAULT_CHANNEL_MODES, EMPTY_DIR_ENTRIES, IO_BUFFER_SIZE, MIN_BUFFER_SIZE, MIN_READ_BUFFER_SIZE, MIN_WRITE_BUFFER_SIZE
BY_NAME_COMPARATOR, NAME_EXTRACTOR
EMPTY
Modifier | Constructor and Description |
---|---|
private |
Wrapper(SftpClient delegate,
SftpErrorDataHandler errorHandler,
int readSize,
int writeSize) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
canonicalPath(java.lang.String path)
The effective "normalized" remote path
|
void |
close() |
void |
close(SftpClient.Handle handle)
Close the handle obtained from one of the
open methods |
ClientChannel |
getClientChannel() |
ClientSession |
getClientSession() |
java.nio.charset.Charset |
getNameDecodingCharset() |
java.util.NavigableMap<java.lang.String,byte[]> |
getServerExtensions() |
int |
getVersion() |
void |
increment() |
boolean |
isClosing() |
boolean |
isOpen() |
void |
link(java.lang.String linkPath,
java.lang.String targetPath,
boolean symbolic)
Create a link
|
java.lang.Iterable<SftpClient.DirEntry> |
listDir(SftpClient.Handle handle) |
void |
lock(SftpClient.Handle handle,
long offset,
long length,
int mask) |
SftpClient.Attributes |
lstat(java.lang.String path)
Retrieve remote path meta-data - do not follow symbolic links
|
void |
mkdir(java.lang.String path)
Create remote directory
|
SftpClient.CloseableHandle |
open(java.lang.String path,
java.util.Collection<SftpClient.OpenMode> options)
Opens a remote file with the specified mode(s)
|
SftpClient.CloseableHandle |
openDir(java.lang.String path)
Obtain a handle for a directory
|
int |
read(SftpClient.Handle handle,
long fileOffset,
byte[] dst,
int dstOffset,
int len) |
java.io.InputStream |
read(java.lang.String path) |
java.io.InputStream |
read(java.lang.String path,
java.util.Collection<SftpClient.OpenMode> mode) |
java.io.InputStream |
read(java.lang.String path,
int bufferSize,
java.util.Collection<SftpClient.OpenMode> mode)
Read a remote file's data via an input stream
|
java.io.InputStream |
read(java.lang.String path,
SftpClient.OpenMode... mode) |
java.util.List<SftpClient.DirEntry> |
readDir(SftpClient.Handle handle) |
java.lang.Iterable<SftpClient.DirEntry> |
readDir(java.lang.String path) |
java.lang.String |
readLink(java.lang.String path)
Retrieve target of a link
|
Buffer |
receive(int id) |
Buffer |
receive(int id,
java.time.Duration timeout) |
Buffer |
receive(int id,
long timeout) |
void |
remove(java.lang.String path) |
void |
rename(java.lang.String oldPath,
java.lang.String newPath,
java.util.Collection<SftpClient.CopyMode> options) |
void |
rmdir(java.lang.String path)
Remove remote directory
|
int |
send(int cmd,
Buffer buffer) |
void |
setNameDecodingCharset(java.nio.charset.Charset cs) |
void |
setStat(SftpClient.Handle handle,
SftpClient.Attributes attributes)
Update remote node meta-data
|
void |
setStat(java.lang.String path,
SftpClient.Attributes attributes)
Update remote node meta-data
|
SftpClient.Attributes |
stat(SftpClient.Handle handle)
Retrieve file/directory handle meta-data
|
SftpClient.Attributes |
stat(java.lang.String path)
Retrieve remote path meta-data - follow symbolic links if encountered
|
void |
symLink(java.lang.String linkPath,
java.lang.String targetPath)
Create symbolic link
|
void |
unlock(SftpClient.Handle handle,
long offset,
long length) |
void |
write(SftpClient.Handle handle,
long fileOffset,
byte[] src,
int srcOffset,
int len)
Write data to (open) file handle
|
java.io.OutputStream |
write(java.lang.String path) |
java.io.OutputStream |
write(java.lang.String path,
java.util.Collection<SftpClient.OpenMode> mode) |
java.io.OutputStream |
write(java.lang.String path,
int bufferSize,
java.util.Collection<SftpClient.OpenMode> mode)
Write to a remote file via an output stream
|
java.io.OutputStream |
write(java.lang.String path,
SftpClient.OpenMode... mode) |
checkAttributes, checkAttributesResponse, checkCommandStatus, checkData, checkDataResponse, checkDirResponse, checkHandle, checkHandleResponse, checkOneName, checkOneNameResponse, checkResponseStatus, checkResponseStatus, errorData, getChannel, getExtension, getExtension, getParsedServerExtensions, getParsedServerExtensions, getReadBufferSize, getReferencedName, getWriteBufferSize, handleUnexpectedAttributesPacket, handleUnexpectedHandlePacket, handleUnexpectedPacket, handleUnknownDataPacket, handleUnknownDirListingPacket, handleUnknownOneNamePacket, openRemoteFileChannel, putReferencedName, read, readAttributes, readDir, throwStatusException, validateIncomingResponse, writeAttributes
toString
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
singleSessionInstance
getExtension, getName, open, open, openRemoteFileChannel, openRemotePathChannel, openRemotePathChannel, read, read, read, read, readEntries, rename, rename, singleSessionInstance, write, write, write
getSession
getSessionContext
findByName, findFirstMatchByName, getNameList, getNames, ofName, removeByName, safeCompareByName
private final SftpClient delegate
private final java.util.concurrent.atomic.AtomicInteger count
private final int readSize
private final int writeSize
private Wrapper(SftpClient delegate, SftpErrorDataHandler errorHandler, int readSize, int writeSize)
public int getVersion()
public ClientSession getClientSession()
ClientSession
usedpublic ClientChannel getClientChannel()
ClientChannel
usedpublic java.util.NavigableMap<java.lang.String,byte[]> getServerExtensions()
NavigableMap
of the reported server extensions. where key=extension name (case
insensitive)public java.nio.charset.Charset getNameDecodingCharset()
null
) Charset
used to decode referenced files/folders namesSftpModuleProperties.NAME_DECODING_CHARSET
public void setNameDecodingCharset(java.nio.charset.Charset cs)
public boolean isClosing()
public boolean isOpen()
public void close() throws java.io.IOException
java.io.IOException
public void increment()
public SftpClient.CloseableHandle open(java.lang.String path, java.util.Collection<SftpClient.OpenMode> options) throws java.io.IOException
SftpClient
open
in interface SftpClient
open
in class AbstractSftpClient
path
- The remote pathoptions
- The desired mode - if none specified then SftpClient.OpenMode.Read
is assumedSftpClient.CloseableHandle
java.io.IOException
- If failed to open the remote filepublic void close(SftpClient.Handle handle) throws java.io.IOException
SftpClient
open
methodsclose
in interface SftpClient
close
in class AbstractSftpClient
handle
- The Handle
to closejava.io.IOException
- If failed to executepublic void remove(java.lang.String path) throws java.io.IOException
remove
in interface SftpClient
remove
in class AbstractSftpClient
path
- The remote path to removejava.io.IOException
- If failed to executepublic void rename(java.lang.String oldPath, java.lang.String newPath, java.util.Collection<SftpClient.CopyMode> options) throws java.io.IOException
rename
in interface SftpClient
rename
in class AbstractSftpClient
java.io.IOException
public int read(SftpClient.Handle handle, long fileOffset, byte[] dst, int dstOffset, int len) throws java.io.IOException
java.io.IOException
public void write(SftpClient.Handle handle, long fileOffset, byte[] src, int srcOffset, int len) throws java.io.IOException
SftpClient
write
in interface SftpClient
write
in class AbstractSftpClient
handle
- The file SftpClient.Handle
fileOffset
- Zero-based offset to write in filesrc
- Data buffersrcOffset
- Offset of valid data in bufferlen
- Number of bytes to writejava.io.IOException
- If failed to write the datapublic void mkdir(java.lang.String path) throws java.io.IOException
SftpClient
mkdir
in interface SftpClient
mkdir
in class AbstractSftpClient
path
- Remote directory pathjava.io.IOException
- If failed to executepublic void rmdir(java.lang.String path) throws java.io.IOException
SftpClient
rmdir
in interface SftpClient
rmdir
in class AbstractSftpClient
path
- Remote directory pathjava.io.IOException
- If failed to executepublic SftpClient.CloseableHandle openDir(java.lang.String path) throws java.io.IOException
SftpClient
openDir
in interface SftpClient
openDir
in class AbstractSftpClient
path
- Remote directory pathSftpClient.Handle
java.io.IOException
- If failed to executepublic java.util.List<SftpClient.DirEntry> readDir(SftpClient.Handle handle) throws java.io.IOException
handle
- 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)
java.io.IOException
- If failed to access the remote sitepublic java.lang.Iterable<SftpClient.DirEntry> listDir(SftpClient.Handle handle) throws java.io.IOException
listDir
in interface SftpClient
listDir
in class AbstractSftpClient
handle
- A directory SftpClient.Handle
Iterable
that can be used to iterate over all the directory entries (like
SftpClient.readDir(String)
). Note: the iterable instance is not re-usable - i.e., files
can be iterated only oncejava.io.IOException
- If failed to access the directorypublic java.lang.String canonicalPath(java.lang.String path) throws java.io.IOException
SftpClient
canonicalPath
in interface SftpClient
canonicalPath
in class AbstractSftpClient
path
- The requested path - may be relative, and/or contain dots - e.g., ".",
"..", "./foo", "../bar"java.io.IOException
- If failed to executepublic SftpClient.Attributes stat(java.lang.String path) throws java.io.IOException
SftpClient
stat
in interface SftpClient
stat
in class AbstractSftpClient
path
- The remote pathSftpClient.Attributes
java.io.IOException
- If failed to executepublic SftpClient.Attributes lstat(java.lang.String path) throws java.io.IOException
SftpClient
lstat
in interface SftpClient
lstat
in class AbstractSftpClient
path
- The remote pathSftpClient.Attributes
java.io.IOException
- If failed to executepublic SftpClient.Attributes stat(SftpClient.Handle handle) throws java.io.IOException
SftpClient
stat
in interface SftpClient
stat
in class AbstractSftpClient
handle
- The SftpClient.Handle
obtained via one of the open
callsSftpClient.Attributes
java.io.IOException
- If failed to executepublic void setStat(java.lang.String path, SftpClient.Attributes attributes) throws java.io.IOException
SftpClient
setStat
in interface SftpClient
setStat
in class AbstractSftpClient
path
- The remote pathattributes
- The SftpClient.Attributes
to updatejava.io.IOException
- If failed to executepublic void setStat(SftpClient.Handle handle, SftpClient.Attributes attributes) throws java.io.IOException
SftpClient
setStat
in interface SftpClient
setStat
in class AbstractSftpClient
handle
- The SftpClient.Handle
obtained via one of the open
callsattributes
- The SftpClient.Attributes
to updatejava.io.IOException
- If failed to executepublic java.lang.String readLink(java.lang.String path) throws java.io.IOException
SftpClient
readLink
in interface SftpClient
readLink
in class AbstractSftpClient
path
- Remote path that represents a linkjava.io.IOException
- If failed to executepublic void symLink(java.lang.String linkPath, java.lang.String targetPath) throws java.io.IOException
SftpClient
linkPath
- The link locationtargetPath
- The referenced target by the linkjava.io.IOException
- If failed to executeSftpClient.link(String, String, boolean)
public java.lang.Iterable<SftpClient.DirEntry> readDir(java.lang.String path) throws java.io.IOException
readDir
in interface SftpClient
readDir
in class AbstractSftpClient
path
- The remote directory pathIterable
that can be used to iterate over all the directory entries (unlike
SftpClient.readDir(Handle)
)java.io.IOException
- If failed to access the remote siteSftpClient.readDir(Handle)
public java.io.InputStream read(java.lang.String path) throws java.io.IOException
java.io.IOException
public java.io.InputStream read(java.lang.String path, SftpClient.OpenMode... mode) throws java.io.IOException
java.io.IOException
public java.io.InputStream read(java.lang.String path, java.util.Collection<SftpClient.OpenMode> mode) throws java.io.IOException
java.io.IOException
public java.io.InputStream read(java.lang.String path, int bufferSize, java.util.Collection<SftpClient.OpenMode> mode) throws java.io.IOException
SftpClient
read
in interface SftpClient
read
in class AbstractSftpClient
path
- The remote file pathbufferSize
- The internal read buffer sizemode
- The remote file SftpClient.OpenMode
sInputStream
for reading the remote file datajava.io.IOException
- If failed to executepublic java.io.OutputStream write(java.lang.String path) throws java.io.IOException
java.io.IOException
public java.io.OutputStream write(java.lang.String path, SftpClient.OpenMode... mode) throws java.io.IOException
java.io.IOException
public java.io.OutputStream write(java.lang.String path, java.util.Collection<SftpClient.OpenMode> mode) throws java.io.IOException
java.io.IOException
public java.io.OutputStream write(java.lang.String path, int bufferSize, java.util.Collection<SftpClient.OpenMode> mode) throws java.io.IOException
SftpClient
write
in interface SftpClient
write
in class AbstractSftpClient
path
- The remote file pathbufferSize
- The internal write buffer sizemode
- The remote file SftpClient.OpenMode
sOutputStream
for writing the datajava.io.IOException
- If failed to executepublic void link(java.lang.String linkPath, java.lang.String targetPath, boolean symbolic) throws java.io.IOException
SftpClient
link
in interface SftpClient
link
in class AbstractSftpClient
linkPath
- The link locationtargetPath
- The referenced target by the linksymbolic
- If true
then make this a symbolic link, otherwise a hard onejava.io.IOException
- If failed to executepublic void lock(SftpClient.Handle handle, long offset, long length, int mask) throws java.io.IOException
lock
in interface SftpClient
lock
in class AbstractSftpClient
java.io.IOException
public void unlock(SftpClient.Handle handle, long offset, long length) throws java.io.IOException
unlock
in interface SftpClient
unlock
in class AbstractSftpClient
java.io.IOException
public int send(int cmd, Buffer buffer) throws java.io.IOException
cmd
- Command to send - Note: only lower 8-bits are usedbuffer
- The Buffer
containing the command datajava.io.IOException
- if failed to send commandpublic Buffer receive(int id) throws java.io.IOException
id
- The expected request idBuffer
containing the request idjava.io.IOException
- If connection closed or interruptedpublic Buffer receive(int id, long timeout) throws java.io.IOException
id
- The expected request idtimeout
- The amount of time to wait for the responseBuffer
containing the request idjava.io.IOException
- If connection closed or interruptedpublic Buffer receive(int id, java.time.Duration timeout) throws java.io.IOException
id
- The expected request idtimeout
- The amount of time to wait for the responseBuffer
containing the request idjava.io.IOException
- If connection closed or interrupted