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
FieldsModifier and TypeFieldDescriptionprivate final SftpClient
private final String
private final RawSftpClient
private final boolean
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
ConstructorsModifierConstructorDescriptionprotected
AbstractSftpClientExtension
(String name, SftpClient client, RawSftpClient raw, boolean supported) protected
AbstractSftpClientExtension
(String name, SftpClient client, RawSftpClient raw, Collection<String> extras) protected
AbstractSftpClientExtension
(String name, SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) -
Method Summary
Modifier and TypeMethodDescriptionprotected Buffer
checkExtendedReplyBuffer
(Buffer buffer) protected void
checkStatus
(Buffer buffer) final SftpClient
protected Buffer
getCommandBuffer
(int extraSize) protected Buffer
getCommandBuffer
(Object target) protected Buffer
getCommandBuffer
(Object target, int extraSize) final String
getName()
final boolean
receive
(int id) receive
(int id, long timeout) int
protected void
protected int
sendExtendedCommand
(Buffer buffer) protected void
throwStatusException
(int id, SftpStatus status)
-
Field Details
-
name
-
client
-
raw
-
supported
private final boolean supported
-
-
Constructor Details
-
AbstractSftpClientExtension
protected AbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, Collection<String> extras) -
AbstractSftpClientExtension
protected AbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) -
AbstractSftpClientExtension
protected AbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, boolean supported)
-
-
Method Details
-
getName
- Specified by:
getName
in interfaceNamedResource
- Returns:
- The resource name
-
getClient
- Specified by:
getClient
in interfaceSftpClientHolder
-
sendAndCheckExtendedCommandStatus
- Throws:
IOException
-
sendExtendedCommand
- Throws:
IOException
-
send
- 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:
IOException
- if failed to send command
-
write
- Specified by:
write
in interfaceRawSftpClient
- Throws:
IOException
-
receive
- Specified by:
receive
in interfaceRawSftpClient
- Parameters:
id
- The expected request id- Returns:
- The received response
Buffer
containing the request id - Throws:
IOException
- If connection closed or interrupted
-
receive
- 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:
IOException
- If connection closed or interrupted
-
receive
- 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:
IOException
- If connection closed or interrupted
-
isSupported
public final boolean isSupported()- Specified by:
isSupported
in interfaceOptionalFeature
-
checkStatus
- Throws:
IOException
-
putTarget
- Parameters:
buffer
- TheBuffer
target
- A target pathString
orSftpClient.Handle
orbyte[]
to be encoded in the buffer- Returns:
- The updated buffer
- Throws:
UnsupportedOperationException
- If target is not one of the above supported types
-
getCommandBuffer
- 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
- 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
- Parameters:
extraSize
- Extra size - besides the extension name- Returns:
- A
Buffer
with the extension name set
-
checkExtendedReplyBuffer
- 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:
IOException
- If a non-SftpConstants.SSH_FX_OK
result or not aSftpConstants.SSH_FXP_EXTENDED_REPLY
buffer
-
throwStatusException
- Throws:
IOException
-