Class AbstractSftpClientExtension
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.sftp.client.extensions.helpers.AbstractSftpClientExtension
-
- All Implemented Interfaces:
NamedResource
,OptionalFeature
,SftpClientExtension
,RawSftpClient
,SftpClientHolder
- Direct Known Subclasses:
AbstractCheckFileExtension
,AbstractMD5HashExtension
,AbstractOpenSSHStatCommandExtension
,CopyDataExtensionImpl
,CopyFileExtensionImpl
,FilenameTranslationControlExtensionImpl
,OpenSSHFsyncExtensionImpl
,OpenSSHLimitsExtensionImpl
,OpenSSHPosixRenameExtensionImpl
,SpaceAvailableExtensionImpl
public abstract class AbstractSftpClientExtension extends AbstractLoggingBean implements SftpClientExtension, RawSftpClient
-
-
Field Summary
Fields Modifier and Type Field Description private SftpClient
client
private java.lang.String
name
private RawSftpClient
raw
private boolean
supported
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR
-
Fields inherited from interface org.apache.sshd.common.OptionalFeature
FALSE, TRUE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSftpClientExtension(java.lang.String name, SftpClient client, RawSftpClient raw, boolean supported)
protected
AbstractSftpClientExtension(java.lang.String name, SftpClient client, RawSftpClient raw, java.util.Collection<java.lang.String> extras)
protected
AbstractSftpClientExtension(java.lang.String name, SftpClient client, RawSftpClient raw, java.util.Map<java.lang.String,byte[]> extensions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Buffer
checkExtendedReplyBuffer(Buffer buffer)
protected void
checkStatus(Buffer buffer)
SftpClient
getClient()
protected Buffer
getCommandBuffer(int extraSize)
protected Buffer
getCommandBuffer(java.lang.Object target)
protected Buffer
getCommandBuffer(java.lang.Object target, int extraSize)
java.lang.String
getName()
boolean
isSupported()
Buffer
putTarget(Buffer buffer, java.lang.Object target)
Buffer
receive(int id)
Buffer
receive(int id, long timeout)
Buffer
receive(int id, java.time.Duration timeout)
int
send(int cmd, Buffer buffer)
protected void
sendAndCheckExtendedCommandStatus(Buffer buffer)
protected int
sendExtendedCommand(Buffer buffer)
protected void
throwStatusException(int id, SftpStatus status)
SftpMessage
write(int cmd, Buffer buffer)
-
-
-
Field Detail
-
name
private final java.lang.String name
-
client
private final SftpClient client
-
raw
private final RawSftpClient raw
-
supported
private final boolean supported
-
-
Constructor Detail
-
AbstractSftpClientExtension
protected AbstractSftpClientExtension(java.lang.String name, SftpClient client, RawSftpClient raw, java.util.Collection<java.lang.String> extras)
-
AbstractSftpClientExtension
protected AbstractSftpClientExtension(java.lang.String name, SftpClient client, RawSftpClient raw, java.util.Map<java.lang.String,byte[]> extensions)
-
AbstractSftpClientExtension
protected AbstractSftpClientExtension(java.lang.String name, SftpClient client, RawSftpClient raw, boolean supported)
-
-
Method Detail
-
getName
public final java.lang.String getName()
- Specified by:
getName
in interfaceNamedResource
- Returns:
- The resource name
-
getClient
public final SftpClient getClient()
- Specified by:
getClient
in interfaceSftpClientHolder
-
sendAndCheckExtendedCommandStatus
protected void sendAndCheckExtendedCommandStatus(Buffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
sendExtendedCommand
protected int sendExtendedCommand(Buffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
send
public int send(int cmd, Buffer buffer) throws java.io.IOException
- Specified by:
send
in interfaceRawSftpClient
- Parameters:
cmd
- Command to send - Note: only lower 8-bits are usedbuffer
- TheBuffer
containing the command data- Returns:
- The assigned request id
- Throws:
java.io.IOException
- if failed to send command
-
write
public SftpMessage write(int cmd, Buffer buffer) throws java.io.IOException
- Specified by:
write
in interfaceRawSftpClient
- Throws:
java.io.IOException
-
receive
public Buffer receive(int id) throws java.io.IOException
- Specified by:
receive
in interfaceRawSftpClient
- Parameters:
id
- The expected request id- Returns:
- The received response
Buffer
containing the request id - Throws:
java.io.IOException
- If connection closed or interrupted
-
receive
public Buffer receive(int id, long timeout) throws java.io.IOException
- Specified by:
receive
in interfaceRawSftpClient
- Parameters:
id
- The expected request idtimeout
- The amount of time to wait for the response- Returns:
- The received response
Buffer
containing the request id - Throws:
java.io.IOException
- If connection closed or interrupted
-
receive
public Buffer receive(int id, java.time.Duration timeout) throws java.io.IOException
- Specified by:
receive
in interfaceRawSftpClient
- Parameters:
id
- The expected request idtimeout
- The amount of time to wait for the response- Returns:
- The received response
Buffer
containing the request id - Throws:
java.io.IOException
- If connection closed or interrupted
-
isSupported
public final boolean isSupported()
- Specified by:
isSupported
in interfaceOptionalFeature
-
checkStatus
protected void checkStatus(Buffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
putTarget
public Buffer putTarget(Buffer buffer, java.lang.Object target)
- Parameters:
buffer
- TheBuffer
target
- A target pathString
orSftpClient.Handle
orbyte[]
to be encoded in the buffer- Returns:
- The updated buffer
- Throws:
java.lang.UnsupportedOperationException
- If target is not one of the above supported types
-
getCommandBuffer
protected Buffer getCommandBuffer(java.lang.Object target)
- Parameters:
target
- A target pathString
orSftpClient.Handle
orbyte[]
to be encoded in the buffer- Returns:
- A
Buffer
with the extension name set - See Also:
getCommandBuffer(Object, int)
-
getCommandBuffer
protected Buffer getCommandBuffer(java.lang.Object target, int extraSize)
- Parameters:
target
- A target pathString
orSftpClient.Handle
orbyte[]
to be encoded in the bufferextraSize
- Extra size - beyond the path/handle to be allocated- Returns:
- A
Buffer
with the extension name set - See Also:
getCommandBuffer(int)
-
getCommandBuffer
protected Buffer getCommandBuffer(int extraSize)
- Parameters:
extraSize
- Extra size - besides the extension name- Returns:
- A
Buffer
with the extension name set
-
checkExtendedReplyBuffer
protected Buffer checkExtendedReplyBuffer(Buffer buffer) throws java.io.IOException
- Parameters:
buffer
- TheBuffer
to check- Returns:
- The
Buffer
if this is anSftpConstants.SSH_FXP_EXTENDED_REPLY
, ornull
if this is aSftpConstants.SSH_FXP_STATUS
carrying anSftpConstants.SSH_FX_OK
result - Throws:
java.io.IOException
- If a non-SftpConstants.SSH_FX_OK
result or not aSftpConstants.SSH_FXP_EXTENDED_REPLY
buffer
-
throwStatusException
protected void throwStatusException(int id, SftpStatus status) throws java.io.IOException
- Throws:
java.io.IOException
-
-