# Interface CAHandlerType

All Superinterfaces:
  `AutoCloseable`, `com.io7m.hibiscus.api.HBClientCloseableType<CAClientException>`, `com.io7m.hibiscus.api.HBClientHandlerType<CAIMessageType,CAClientConnectionParameters,CAClientException>`, `com.io7m.hibiscus.api.HBIOOperationsType<CAIMessageType,CAClientException>`

public interface CAHandlerType extends com.io7m.hibiscus.api.HBClientHandlerType<CAIMessageType,CAClientConnectionParameters,CAClientException>
A versioned protocol handler.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Path`
  `onExecuteFileDownload(CAFileID fileID, Path file, Path fileTmp, long size, String hashAlgorithm, String hashValue, Consumer<CAClientTransferStatistics> statistics)`
  Download the data associated with the given file.
  `void`
  `onExecuteFileUpload(CAFileID fileID, Path file, String contentType, String description, Consumer<CAClientTransferStatistics> statistics)`
  Upload the data associated with the given file.
  `List<CAIResponseType>`
  `transaction(List<CAICommandType<?>> commands)`
  Execute all the given commands in order, in a single transaction.
  `Optional<CAUserID>`
  `userId()`

  ### Methods inherited from interface com.io7m.hibiscus.api.HBClientCloseableType

  `close, isClosed`

  ### Methods inherited from interface com.io7m.hibiscus.api.HBClientHandlerType

  `doConnect, exceptionTransformer, receive, send, sendAndForget, sendAndWait, transport`

- ## Method Details

  - ### userId

    Optional<CAUserID> userId()
    Returns:
      The authenticated user ID

  - ### onExecuteFileDownload

    Path onExecuteFileDownload(CAFileID fileID, Path file, Path fileTmp, long size, String hashAlgorithm, String hashValue, Consumer<CAClientTransferStatistics> statistics) throws InterruptedException, CAClientException
    Download the data associated with the given file. The file will be downloaded to a temporary file and then, if everything succeeds and the hash value matches, the temporary file will atomically replace the output file.
    Parameters:
      `fileID` - The file ID
      `file` - The output file
      `fileTmp` - The temporary output file
      `size` - The expected size
      `hashAlgorithm` - The hash algorithm
      `hashValue` - The expected hash value
      `statistics` - A receiver of transfer statistics
    Returns:
      The result
    Throws:
      `InterruptedException` - On interruption
      `CAClientException` - On errors

  - ### onExecuteFileUpload

    void onExecuteFileUpload(CAFileID fileID, Path file, String contentType, String description, Consumer<CAClientTransferStatistics> statistics) throws InterruptedException, CAClientException
    Upload the data associated with the given file.
    Parameters:
      `fileID` - The file ID
      `file` - The input file
      `contentType` - The content type
      `description` - The file description
      `statistics` - A receiver of transfer statistics
    Throws:
      `InterruptedException` - On interruption
      `CAClientException` - On errors

  - ### transaction

    List<CAIResponseType> transaction(List<CAICommandType<?>> commands) throws InterruptedException, CAClientException
    Execute all the given commands in order, in a single transaction.
    Parameters:
      `commands` - The commands
    Returns:
      The responses
    Throws:
      `InterruptedException` - On interruption
      `CAClientException` - On errors