Class AbstractSftpClientExtension

    • Field Detail

      • name

        private final java.lang.String name
      • 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 interface NamedResource
        Returns:
        The resource name
      • 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 interface RawSftpClient
        Parameters:
        cmd - Command to send - Note: only lower 8-bits are used
        buffer - The Buffer containing the command data
        Returns:
        The assigned request id
        Throws:
        java.io.IOException - if failed to send command
      • receive

        public Buffer receive​(int id)
                       throws java.io.IOException
        Specified by:
        receive in interface RawSftpClient
        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 interface RawSftpClient
        Parameters:
        id - The expected request id
        timeout - 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 interface RawSftpClient
        Parameters:
        id - The expected request id
        timeout - 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
      • 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 - The Buffer
        target - A target path String or SftpClient.Handle or byte[] 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,
                                          int extraSize)
        Parameters:
        target - A target path String or SftpClient.Handle or byte[] to be encoded in the buffer
        extraSize - 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
      • validateIncomingResponse

        protected void validateIncomingResponse​(int cmd,
                                                int id,
                                                int type,
                                                int length,
                                                Buffer buffer)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • throwStatusException

        protected void throwStatusException​(int id,
                                            int substatus,
                                            java.lang.String msg,
                                            java.lang.String lang)
                                     throws java.io.IOException
        Throws:
        java.io.IOException