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,OpenSSHPosixRenameExtensionImpl,SpaceAvailableExtensionImpl
public abstract class AbstractSftpClientExtension extends AbstractLoggingBean implements SftpClientExtension, RawSftpClient
- Author:
- Apache MINA SSHD Project
-
-
Field Summary
-
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 protectedAbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, boolean supported)protectedAbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, Collection<String> extras)protectedAbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, Map<String,byte[]> extensions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected BuffercheckExtendedReplyBuffer(Buffer buffer)protected voidcheckStatus(Buffer buffer)SftpClientgetClient()protected BuffergetCommandBuffer(int extraSize)protected BuffergetCommandBuffer(Object target)protected BuffergetCommandBuffer(Object target, int extraSize)StringgetName()booleanisSupported()BufferputTarget(Buffer buffer, Object target)Bufferreceive(int id)Bufferreceive(int id, long timeout)Bufferreceive(int id, Duration timeout)intsend(int cmd, Buffer buffer)protected voidsendAndCheckExtendedCommandStatus(Buffer buffer)protected intsendExtendedCommand(Buffer buffer)protected voidthrowStatusException(int id, int substatus, String msg, String lang)protected voidvalidateIncomingResponse(int cmd, int id, int type, int length, Buffer buffer)
-
-
-
Constructor Detail
-
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 Detail
-
getName
public final String getName()
- Specified by:
getNamein interfaceNamedResource- Returns:
- The resource name
-
getClient
public final SftpClient getClient()
- Specified by:
getClientin interfaceSftpClientHolder
-
sendAndCheckExtendedCommandStatus
protected void sendAndCheckExtendedCommandStatus(Buffer buffer) throws IOException
- Throws:
IOException
-
sendExtendedCommand
protected int sendExtendedCommand(Buffer buffer) throws IOException
- Throws:
IOException
-
send
public int send(int cmd, Buffer buffer) throws IOException- Specified by:
sendin interfaceRawSftpClient- 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
public Buffer receive(int id) throws IOException
- Specified by:
receivein interfaceRawSftpClient- Parameters:
id- The expected request id- Returns:
- The received response
Buffercontaining the request id - Throws:
IOException- If connection closed or interrupted
-
receive
public Buffer receive(int id, long timeout) throws IOException
- Specified by:
receivein interfaceRawSftpClient- 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
public Buffer receive(int id, Duration timeout) throws IOException
- Specified by:
receivein interfaceRawSftpClient- 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
-
isSupported
public final boolean isSupported()
- Specified by:
isSupportedin interfaceOptionalFeature
-
checkStatus
protected void checkStatus(Buffer buffer) throws IOException
- Throws:
IOException
-
putTarget
public Buffer putTarget(Buffer buffer, Object target)
- Parameters:
buffer- TheBuffertarget- A target pathStringorSftpClient.Handleorbyte[]to be encoded in the buffer- Returns:
- The updated buffer
- Throws:
UnsupportedOperationException- If target is not one of the above supported types
-
getCommandBuffer
protected Buffer getCommandBuffer(Object target)
- Parameters:
target- A target pathStringorSftpClient.Handleorbyte[]to be encoded in the buffer- Returns:
- A
Bufferwith the extension name set - See Also:
getCommandBuffer(Object, int)
-
getCommandBuffer
protected Buffer getCommandBuffer(Object target, int extraSize)
- Parameters:
target- A target pathStringorSftpClient.Handleorbyte[]to be encoded in the bufferextraSize- Extra size - beyond the path/handle to be allocated- Returns:
- A
Bufferwith the extension name set - See Also:
getCommandBuffer(int)
-
getCommandBuffer
protected Buffer getCommandBuffer(int extraSize)
- Parameters:
extraSize- Extra size - besides the extension name- Returns:
- A
Bufferwith the extension name set
-
checkExtendedReplyBuffer
protected Buffer checkExtendedReplyBuffer(Buffer buffer) throws IOException
- Parameters:
buffer- TheBufferto check- Returns:
- The
Bufferif this is anSftpConstants.SSH_FXP_EXTENDED_REPLY, ornullif this is aSftpConstants.SSH_FXP_STATUScarrying anSftpConstants.SSH_FX_OKresult - Throws:
IOException- If a non-SftpConstants.SSH_FX_OKresult or not aSftpConstants.SSH_FXP_EXTENDED_REPLYbuffer
-
validateIncomingResponse
protected void validateIncomingResponse(int cmd, int id, int type, int length, Buffer buffer) throws IOException- Throws:
IOException
-
throwStatusException
protected void throwStatusException(int id, int substatus, String msg, String lang) throws IOException- Throws:
IOException
-
-