Interface TokenStorageAdapter


public interface TokenStorageAdapter
Adapts the token to some activity against the connection type.
  • Method Details

    • isAvailable

      boolean isAvailable()
      Checks whether this storage adapter is available and ready to process.
      Returns:
      true If this adapter is available and ready, false otherwise.
    • create

      Token create(Token token, Options options) throws DataLayerException
      Create the Token in the database.
      Parameters:
      token - Non null Token to create.
      options - Non null Options for the operations.
      Returns:
      The newly created Token.
      Throws:
      DataLayerException - If the operation failed, this exception will capture the reason.
      RuntimeException - If the thread is interrupted while retrieving the token from promise.
    • read

      Token read(String tokenId, Options options) throws DataLayerException
      Performs a read against the database and converts the result into a Token.
      Parameters:
      tokenId - The id of the Token to read.
      options - Non null Options for the operations.
      Returns:
      Token if found, otherwise null.
      Throws:
      DataLayerException - If the operation failed, this exception will capture the reason.
      RuntimeException - If the thread is interrupted while retrieving the token from promise.
    • update

      Token update(Token previous, Token updated, Options options) throws DataLayerException
      Update the Token based on whether there were any changes between the two.
      Parameters:
      previous - The non null previous Token to check against.
      updated - The non null Token to update with.
      options - Non null Options to pass through to the underlying implementation.
      Returns:
      A copy of the updated token. The token would contain the updated etag.
      Throws:
      DataLayerException - If the operation failed for a known reason.
    • delete

      default PartialToken delete(String tokenId, Options options) throws DataLayerException
      Performs a delete against the Token ID provided.
      Parameters:
      tokenId - The non null Token ID to delete.
      options - Non null Options to pass through to the underlying implementation.
      Returns:
      A PartialToken containing at least the CoreTokenField.TOKEN_ID.
      Throws:
      DataLayerException - If the operation failed, this exception will capture the reason.
    • deleteAsync

      Promise<PartialToken,DataLayerException> deleteAsync(String tokenId, Options options)
      Performs a delete against the Token ID provided.
      Parameters:
      tokenId - The non null Token ID to delete.
      options - Non null Options to pass through to the underlying implementation.
      Returns:
      A promise of PartialToken containing at least the CoreTokenField.TOKEN_ID.
      Throws:
      DataLayerException - If the operation failed, this exception will capture the reason.
    • patch

      PartialToken patch(String tokenId, TokenModifications modifications, Options options) throws DataLayerException
      Applies a patch to the database entry using the instructions contained within the TokenModification.
      Parameters:
      tokenId - The ID of the token against which to apply the modifications.
      modifications - The set of modifications to make to this token.
      options - The non null Options for the operation.
      Returns:
      A PartialToken containing at least the CoreTokenField.TOKEN_ID.
      Throws:
      DataLayerException - If the operation failed, this exception will capture the reason.
      RuntimeException - If the thread is interrupted while retrieving the token from promise.
    • query

      Collection<Token> query(TokenFilter query, Options options) throws DataLayerException
      Performs a full-token query using the provided filter.
      Parameters:
      query - The non null filter specification.
      options - Non null Options to pass through to the underlying implementation.
      Returns:
      A collection of Token.
      Throws:
      DataLayerException - If the operation failed, this exception will capture the reason.
      RuntimeException - If the thread is interrupted while retrieving the token from promise.
    • partialQuery

      Collection<PartialToken> partialQuery(TokenFilter query, Options options) throws DataLayerException
      Performs a partial query using the provided filter.
      Parameters:
      query - The non null filter specification.
      options - Non null Options to pass through to the underlying implementation.
      Returns:
      A collection of PartialToken.
      Throws:
      DataLayerException - If the operation failed, this exception will capture the reason.
      RuntimeException - If the thread is interrupted while retrieving the token from promise.
    • startContinuousQuery

      ContinuousQuery startContinuousQuery(TokenFilter filter, ContinuousQueryListener listener) throws DataLayerException
      Performs a continuous query using the provided filter.
      Parameters:
      filter - The non null filter specification.
      Returns:
      An instance of ContinuousQuery.
      Throws:
      DataLayerException - If the operation failed, this exception will capture the reason.