Package org.apache.sshd.sftp.client.fs
Class SftpFileSystem.Wrapper
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.client.subsystem.AbstractSubsystemClient
org.apache.sshd.sftp.client.impl.AbstractSftpClient
org.apache.sshd.sftp.client.fs.SftpFileSystem.Wrapper
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,ClientChannelHolder,ClientSessionHolder,SubsystemClient,ChannelHolder,NamedResource,SessionContextHolder,SessionHolder<ClientSession>,FullAccessSftpClient,RawSftpClient,SftpClient,SftpErrorDataHandler
- Enclosing class:
SftpFileSystem
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.sshd.sftp.client.SftpClient
SftpClient.Attribute, SftpClient.Attributes, SftpClient.CloseableHandle, SftpClient.CopyMode, SftpClient.DirEntry, SftpClient.Handle, SftpClient.OpenMode -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SftpClientprivate final AtomicBooleanprivate final intprivate final intFields inherited from class org.apache.sshd.sftp.client.impl.AbstractSftpClient
errorDataHandler, INIT_COMMAND_SIZE, SFTP_CLIENT_CMD_TIMEOUTFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
logFields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTORFields inherited from interface org.apache.sshd.sftp.client.SftpClient
DEFAULT_CHANNEL_MODES, EMPTY_DIR_ENTRIES, IO_BUFFER_SIZE, MIN_BUFFER_SIZE, MIN_READ_BUFFER_SIZE, MIN_WRITE_BUFFER_SIZEFields inherited from interface org.apache.sshd.sftp.client.SftpErrorDataHandler
EMPTY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateWrapper(SftpClient delegate, SftpErrorDataHandler errorHandler, int readSize, int writeSize) -
Method Summary
Modifier and TypeMethodDescriptioncanonicalPath(String path) The effective "normalized" remote pathvoidclose()voidclose(SftpClient.Handle handle) Close the handle obtained from one of theopenmethodsNavigableMap<String, byte[]> intbooleanbooleanisOpen()voidCreate a linklistDir(SftpClient.Handle handle) voidlock(SftpClient.Handle handle, long offset, long length, int mask) Retrieve remote path meta-data - do not follow symbolic linksvoidCreate remote directoryopen(String path, Collection<SftpClient.OpenMode> options) Opens a remote file with the specified mode(s)Obtain a handle for a directoryread(String path, Collection<SftpClient.OpenMode> mode) read(String path, SftpClient.OpenMode... mode) intread(SftpClient.Handle handle, long fileOffset, byte[] dst, int dstOffset, int len) readDir(SftpClient.Handle handle) readDir(SftpClient.Handle handle, AtomicReference<Boolean> eolIndicator) Retrieve target of a linkreceive(int id) receive(int id, long timeout) voidvoidrename(String oldPath, String newPath, Collection<SftpClient.CopyMode> options) voidRemove remote directoryintvoidvoidsetStat(String path, SftpClient.Attributes attributes) Update remote node meta-datavoidsetStat(SftpClient.Handle handle, SftpClient.Attributes attributes) Update remote node meta-dataRetrieve remote path meta-data - follow symbolic links if encounteredstat(SftpClient.Handle handle) Retrieve file/directory handle meta-datavoidCreate symbolic linkvoidunlock(SftpClient.Handle handle, long offset, long length) write(String path, Collection<SftpClient.OpenMode> mode) write(String path, SftpClient.OpenMode... mode) voidwrite(SftpClient.Handle handle, long fileOffset, byte[] src, int srcOffset, int len) Write data to (open) file handleMethods inherited from class org.apache.sshd.sftp.client.impl.AbstractSftpClient
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, read, readAttributes, readDir, response, rpc, throwStatusException, write, writeAttributesMethods inherited from class org.apache.sshd.client.subsystem.AbstractSubsystemClient
toStringMethods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContextMethods inherited from interface org.apache.sshd.sftp.client.SftpClient
getExtension, getName, open, open, openRemoteFileChannel, openRemotePathChannel, openRemotePathChannel, read, read, read, read, readEntries, rename, rename, singleSessionInstance, write, write, writeMethods inherited from interface org.apache.sshd.client.subsystem.SubsystemClient
getSession
-
Field Details
-
delegate
-
readSize
private final int readSize -
writeSize
private final int writeSize -
open
-
-
Constructor Details
-
Wrapper
private Wrapper(SftpClient delegate, SftpErrorDataHandler errorHandler, int readSize, int writeSize)
-
-
Method Details
-
getVersion
public int getVersion()- Returns:
- The negotiated SFTP protocol version
-
getClientSession
- Returns:
- The underlying
ClientSessionused
-
getClientChannel
- Returns:
- The underlying
ClientChannelused
-
getServerExtensions
- Returns:
- An (unmodifiable)
NavigableMapof the reported server extensions. where key=extension name (case insensitive)
-
getNameDecodingCharset
- Returns:
- The (never
null)Charsetused to decode referenced files/folders names - See Also:
-
setNameDecodingCharset
-
isClosing
public boolean isClosing() -
isOpen
public boolean isOpen() -
close
- Throws:
IOException
-
open
public SftpClient.CloseableHandle open(String path, Collection<SftpClient.OpenMode> options) throws IOException Description copied from interface:SftpClientOpens a remote file with the specified mode(s)- Specified by:
openin interfaceSftpClient- Overrides:
openin classAbstractSftpClient- Parameters:
path- The remote pathoptions- The desired mode - if none specified thenSftpClient.OpenMode.Readis assumed- Returns:
- The file's
SftpClient.CloseableHandle - Throws:
IOException- If failed to open the remote file
-
close
Description copied from interface:SftpClientClose the handle obtained from one of theopenmethods- Specified by:
closein interfaceSftpClient- Overrides:
closein classAbstractSftpClient- Parameters:
handle- TheHandleto close- Throws:
IOException- If failed to execute
-
remove
- Specified by:
removein interfaceSftpClient- Overrides:
removein classAbstractSftpClient- Parameters:
path- The remote path to remove- Throws:
IOException- If failed to execute
-
rename
public void rename(String oldPath, String newPath, Collection<SftpClient.CopyMode> options) throws IOException - Specified by:
renamein interfaceSftpClient- Overrides:
renamein classAbstractSftpClient- Throws:
IOException
-
read
public int read(SftpClient.Handle handle, long fileOffset, byte[] dst, int dstOffset, int len) throws IOException - Throws:
IOException
-
write
public void write(SftpClient.Handle handle, long fileOffset, byte[] src, int srcOffset, int len) throws IOException Description copied from interface:SftpClientWrite data to (open) file handle- Specified by:
writein interfaceSftpClient- Overrides:
writein classAbstractSftpClient- Parameters:
handle- The fileSftpClient.HandlefileOffset- Zero-based offset to write in filesrc- Data buffersrcOffset- Offset of valid data in bufferlen- Number of bytes to write- Throws:
IOException- If failed to write the data
-
mkdir
Description copied from interface:SftpClientCreate remote directory- Specified by:
mkdirin interfaceSftpClient- Overrides:
mkdirin classAbstractSftpClient- Parameters:
path- Remote directory path- Throws:
IOException- If failed to execute
-
rmdir
Description copied from interface:SftpClientRemove remote directory- Specified by:
rmdirin interfaceSftpClient- Overrides:
rmdirin classAbstractSftpClient- Parameters:
path- Remote directory path- Throws:
IOException- If failed to execute
-
openDir
Description copied from interface:SftpClientObtain a handle for a directory- Specified by:
openDirin interfaceSftpClient- Overrides:
openDirin classAbstractSftpClient- Parameters:
path- Remote directory path- Returns:
- The associated directory
SftpClient.Handle - Throws:
IOException- If failed to execute
-
readDir
- Parameters:
handle- DirectorySftpClient.Handleto read from- Returns:
- A
Listof entries -nullto 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 (untilnull). In order to iterate over all the entries useSftpClient.readDir(String) - Throws:
IOException- If failed to access the remote site
-
listDir
- Specified by:
listDirin interfaceSftpClient- Overrides:
listDirin classAbstractSftpClient- Parameters:
handle- A directorySftpClient.Handle- Returns:
- An
Iterablethat can be used to iterate over all the directory entries (likeSftpClient.readDir(String)). Note: the iterable instance is not re-usable - i.e., files can be iterated only once - Throws:
IOException- If failed to access the directory
-
canonicalPath
Description copied from interface:SftpClientThe effective "normalized" remote path- Specified by:
canonicalPathin interfaceSftpClient- Overrides:
canonicalPathin classAbstractSftpClient- Parameters:
path- The requested path - may be relative, and/or contain dots - e.g., ".", "..", "./foo", "../bar"- Returns:
- The effective "normalized" remote path
- Throws:
IOException- If failed to execute
-
stat
Description copied from interface:SftpClientRetrieve remote path meta-data - follow symbolic links if encountered- Specified by:
statin interfaceSftpClient- Overrides:
statin classAbstractSftpClient- Parameters:
path- The remote path- Returns:
- The associated
SftpClient.Attributes - Throws:
IOException- If failed to execute
-
lstat
Description copied from interface:SftpClientRetrieve remote path meta-data - do not follow symbolic links- Specified by:
lstatin interfaceSftpClient- Overrides:
lstatin classAbstractSftpClient- Parameters:
path- The remote path- Returns:
- The associated
SftpClient.Attributes - Throws:
IOException- If failed to execute
-
stat
Description copied from interface:SftpClientRetrieve file/directory handle meta-data- Specified by:
statin interfaceSftpClient- Overrides:
statin classAbstractSftpClient- Parameters:
handle- TheSftpClient.Handleobtained via one of theopencalls- Returns:
- The associated
SftpClient.Attributes - Throws:
IOException- If failed to execute
-
setStat
Description copied from interface:SftpClientUpdate remote node meta-data- Specified by:
setStatin interfaceSftpClient- Overrides:
setStatin classAbstractSftpClient- Parameters:
path- The remote pathattributes- TheSftpClient.Attributesto update- Throws:
IOException- If failed to execute
-
setStat
Description copied from interface:SftpClientUpdate remote node meta-data- Specified by:
setStatin interfaceSftpClient- Overrides:
setStatin classAbstractSftpClient- Parameters:
handle- TheSftpClient.Handleobtained via one of theopencallsattributes- TheSftpClient.Attributesto update- Throws:
IOException- If failed to execute
-
readLink
Description copied from interface:SftpClientRetrieve target of a link- Specified by:
readLinkin interfaceSftpClient- Overrides:
readLinkin classAbstractSftpClient- Parameters:
path- Remote path that represents a link- Returns:
- The link target
- Throws:
IOException- If failed to execute
-
symLink
Description copied from interface:SftpClientCreate symbolic link- Parameters:
linkPath- The link locationtargetPath- The referenced target by the link- Throws:
IOException- If failed to execute- See Also:
-
readDir
public List<SftpClient.DirEntry> readDir(SftpClient.Handle handle, AtomicReference<Boolean> eolIndicator) throws IOException - Specified by:
readDirin interfaceSftpClient- Overrides:
readDirin classAbstractSftpClient- Parameters:
handle- DirectorySftpClient.Handleto read fromeolIndicator- An indicator that can be used to get information whether end of list has been reached - ignored ifnull. Upon return, set value indicates whether all entries have been exhausted - anullvalue means that this information cannot be provided and another call toreadDiris necessary in order to verify that no more entries are pending- Returns:
- A
Listof entries -nullto indicate no more entries - Throws:
IOException- If failed to access the remote site- See Also:
-
read
- Throws:
IOException
-
read
- Throws:
IOException
-
read
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
link
Description copied from interface:SftpClientCreate a link- Specified by:
linkin interfaceSftpClient- Overrides:
linkin classAbstractSftpClient- Parameters:
linkPath- The link locationtargetPath- The referenced target by the linksymbolic- Iftruethen make this a symbolic link, otherwise a hard one- Throws:
IOException- If failed to execute
-
lock
- Specified by:
lockin interfaceSftpClient- Overrides:
lockin classAbstractSftpClient- Throws:
IOException
-
unlock
- Specified by:
unlockin interfaceSftpClient- Overrides:
unlockin classAbstractSftpClient- Throws:
IOException
-
send
- Parameters:
cmd- Command to send - Note: only lower 8-bits are usedbuffer- TheBuffercontaining the command data- Returns:
- The assigned request id
- Throws:
IOException- if failed to send command
-
receive
- Parameters:
id- The expected request id- Returns:
- The received response
Buffercontaining the request id - Throws:
IOException- If connection closed or interrupted
-
receive
- Parameters:
id- The expected request idtimeout- The amount of time to wait for the response- Returns:
- The received response
Buffercontaining the request id - Throws:
IOException- If connection closed or interrupted
-
receive
- Parameters:
id- The expected request idtimeout- The amount of time to wait for the response- Returns:
- The received response
Buffercontaining the request id - Throws:
IOException- If connection closed or interrupted
-