Package com.io7m.idstore.server.controller.command_exec

# Class IdCommandContext<E extends IdProtocolMessageType,S extends IdSessionType>

java.lang.Object
com.io7m.idstore.server.controller.command_exec.IdCommandContext<E,S>

Type Parameters:
  `E` - The type of error messages
  `S` - The type of sessions

Direct Known Subclasses:
  `IdACommandContext`, `IdUCommandContext`

public abstract class IdCommandContext<E extends IdProtocolMessageType,S extends IdSessionType> extends Object
The context for execution of a command (or set of commands in a transaction).

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `IdCommandContext(com.io7m.repetoir.core.RPServiceDirectoryType inServices, UUID inRequestId, IdDatabaseTransactionType inTransaction, S inSession, String inRemoteHost, String inRemoteUserAgent)`
  The context for execution of a command (or set of commands in a transaction).

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final IdCommandExecutionFailure`
  `fail(int statusCode, IdErrorCode errorCode, String text)`
  Fail with a constant error message.
  `final IdCommandExecutionFailure`
  `failDatabase(IdDatabaseException e)`
  Produce an exception indicating a database error.
  `final IdCommandExecutionFailure`
  `failExceptional(Exception e, int statusCode, IdErrorCode errorCode, String text)`
  Fail with a constant error message.
  `final IdCommandExecutionFailure`
  `failFormatted(int statusCode, IdErrorCode errorCode, IdStringConstantType text, Object... args)`
  Fail with a constant error message.
  `final IdCommandExecutionFailure`
  `failMail(IdEmail email, Exception e)`
  Produce an exception indicating a mail system error.
  `final IdCommandExecutionFailure`
  `failPassword(IdPasswordException e)`
  Produce an exception indicating a password format error.
  `final IdCommandExecutionFailure`
  `failProtocol(IdProtocolException e)`
  Produce an exception indicating a protocol error.
  `final IdCommandExecutionFailure`
  `failSecurity(IdSecurityException e)`
  Produce an exception indicating a security policy error.
  `final IdCommandExecutionFailure`
  `failValidity(IdValidityException e)`
  Produce an exception indicating a validation error.
  `final OffsetDateTime`
  `now()`
  `final String`
  `remoteHost()`
  `final String`
  `remoteUserAgent()`
  `final UUID`
  `requestId()`
  `final void`
  `securityCheck(IdSecActionType action)`
  Check the given action against the security policy.
  `final com.io7m.repetoir.core.RPServiceDirectoryType`
  `services()`
  `final S`
  `session()`
  `final String`
  `toString()`
  `final io.opentelemetry.api.trace.Tracer`
  `tracer()`
  `final IdDatabaseTransactionType`
  `transaction()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### IdCommandContext

    protected IdCommandContext(com.io7m.repetoir.core.RPServiceDirectoryType inServices, UUID inRequestId, IdDatabaseTransactionType inTransaction, S inSession, String inRemoteHost, String inRemoteUserAgent)
    The context for execution of a command (or set of commands in a transaction).
    Parameters:
      `inServices` - The service directory
      `inRequestId` - The request ID
      `inTransaction` - The transaction
      `inSession` - The user session
      `inRemoteHost` - The remote remoteHost
      `inRemoteUserAgent` - The remote user agent

- ## Method Details

  - ### session

    public final S session()
    Returns:
      The user session

  - ### remoteHost

    public final String remoteHost()
    Returns:
      The remote remoteHost

  - ### remoteUserAgent

    public final String remoteUserAgent()
    Returns:
      The remote user agent

  - ### services

    public final com.io7m.repetoir.core.RPServiceDirectoryType services()
    Returns:
      The service directory used during execution

  - ### requestId

    public final UUID requestId()
    Returns:
      The ID of the incoming request

  - ### transaction

    public final IdDatabaseTransactionType transaction()
    Returns:
      The database transaction

  - ### tracer

    public final io.opentelemetry.api.trace.Tracer tracer()
    Returns:
      The OpenTelemetry tracer

  - ### now

    public final OffsetDateTime now()
    Returns:
      The current time

  - ### failDatabase

    public final IdCommandExecutionFailure failDatabase(IdDatabaseException e)
    Produce an exception indicating a database error.
    Parameters:
      `e` - The database exception
    Returns:
      An execution failure

  - ### failSecurity

    public final IdCommandExecutionFailure failSecurity(IdSecurityException e)
    Produce an exception indicating a security policy error.
    Parameters:
      `e` - The security exception
    Returns:
      An execution failure

  - ### failMail

    public final IdCommandExecutionFailure failMail(IdEmail email, Exception e)
    Produce an exception indicating a mail system error.
    Parameters:
      `email` - The email address
      `e` - The mail system exception
    Returns:
      An execution failure

  - ### failValidity

    public final IdCommandExecutionFailure failValidity(IdValidityException e)
    Produce an exception indicating a validation error.
    Parameters:
      `e` - The exception
    Returns:
      An execution failure

  - ### failPassword

    public final IdCommandExecutionFailure failPassword(IdPasswordException e)
    Produce an exception indicating a password format error.
    Parameters:
      `e` - The exception
    Returns:
      An execution failure

  - ### failProtocol

    public final IdCommandExecutionFailure failProtocol(IdProtocolException e)
    Produce an exception indicating a protocol error.
    Parameters:
      `e` - The exception
    Returns:
      An execution failure

  - ### securityCheck

    public final void securityCheck(IdSecActionType action) throws IdSecurityException
    Check the given action against the security policy.
    Parameters:
      `action` - The action
    Throws:
      `IdSecurityException` - On errors

  - ### fail

    public final IdCommandExecutionFailure fail(int statusCode, IdErrorCode errorCode, String text)
    Fail with a constant error message.
    Parameters:
      `statusCode` - The status code
      `errorCode` - The error code
      `text` - The message
    Returns:
      An exception

  - ### failExceptional

    public final IdCommandExecutionFailure failExceptional(Exception e, int statusCode, IdErrorCode errorCode, String text)
    Fail with a constant error message.
    Parameters:
      `e` - The exception
      `statusCode` - The status code
      `errorCode` - The error code
      `text` - The message
    Returns:
      An exception

  - ### failFormatted

    public final IdCommandExecutionFailure failFormatted(int statusCode, IdErrorCode errorCode, IdStringConstantType text, Object... args)
    Fail with a constant error message.
    Parameters:
      `statusCode` - The status code
      `errorCode` - The error code
      `text` - The message
      `args` - The format arguments
    Returns:
      An exception

  - ### toString

    public final String toString()
    Overrides:
      `toString` in class `Object`