Class CACommandContext<E extends CAProtocolMessageType>
java.lang.Object
com.io7m.cardant.server.controller.command_exec.CACommandContext<E>
- Type Parameters:
E- The type of error messages
- Direct Known Subclasses:
CAICommandContext
The context for execution of a command (or set of commands in a
transaction).
-
Constructor Summary
ConstructorsConstructorDescriptionCACommandContext(com.io7m.repetoir.core.RPServiceDirectoryType inServices, UUID inRequestId, CADatabaseTransactionType inTransaction, CASession inSession, String inRemoteHost, String inRemoteUserAgent) The context for execution of a command (or set of commands in a transaction). -
Method Summary
Modifier and TypeMethodDescriptionfinal Map<CAStringConstantType, String> fail(int statusCode, CAErrorCode errorCode, String message, Map<CAStringConstantType, String> errorAttributes) Produce an exception indicating an error, with a string constant message.Produce an exception indicating a database error.failFormatted(int statusCode, CAErrorCode errorCode, Map<CAStringConstantType, String> errorAttributes, CAStringConstantType messageId, Object... args) Produce an exception indicating an error, with a formatted error message.failFormatted(Exception exception, int statusCode, CAErrorCode errorCode, Map<CAStringConstantType, String> errorAttributes, CAStringConstantType messageId, Object... args) Produce an exception indicating an error, with a formatted error message.Produce an exception indicating a protocol error.Produce an exception indicating a security policy error.Produce an exception indicating a validation error.failWithCause(Exception cause, int statusCode, CAErrorCode errorCode, String message, Map<String, String> errorAttributes) Produce an exception indicating an error, with a string constant message.final Stringlocal(CAStringConstantType constant, Object... objects) Localize the given string.final OffsetDateTimenow()final Stringfinal Stringfinal UUIDfinal com.io7m.repetoir.core.RPServiceDirectoryTypeservices()final CASessionsession()final voidsetAttribute(CAStringConstantType key, String value) Set an attribute for error reporting.final io.opentelemetry.api.trace.Tracertracer()
-
Constructor Details
-
CACommandContext
public CACommandContext(com.io7m.repetoir.core.RPServiceDirectoryType inServices, UUID inRequestId, CADatabaseTransactionType inTransaction, CASession inSession, String inRemoteHost, String inRemoteUserAgent) The context for execution of a command (or set of commands in a transaction).- Parameters:
inServices- The service directoryinRequestId- The request IDinTransaction- The transactioninSession- The user sessioninRemoteHost- The remote hostinRemoteUserAgent- The remote user agent
-
-
Method Details
-
attributes
- Returns:
- The attributes as an immutable map
-
setAttribute
Set an attribute for error reporting.- Parameters:
key- The key string constantvalue- The value
-
session
- Returns:
- The user session
-
remoteHost
- Returns:
- The remote host
-
remoteUserAgent
- Returns:
- The remote user agent
-
services
public final com.io7m.repetoir.core.RPServiceDirectoryType services()- Returns:
- The service directory used during execution
-
requestId
- Returns:
- The ID of the incoming request
-
transaction
- Returns:
- The database transaction
-
local
Localize the given string.- Parameters:
constant- The stringobjects- The object arguments- Returns:
- The localized string
-
tracer
public final io.opentelemetry.api.trace.Tracer tracer()- Returns:
- The OpenTelemetry tracer
-
now
- Returns:
- The current time
-
failFormatted
public final CACommandExecutionFailure failFormatted(int statusCode, CAErrorCode errorCode, Map<CAStringConstantType, String> errorAttributes, CAStringConstantType messageId, Object... args) Produce an exception indicating an error, with a formatted error message.- Parameters:
statusCode- The HTTP status kinderrorCode- The error kinderrorAttributes- The error attributesmessageId- The string resource message IDargs- The string resource format arguments- Returns:
- An execution failure
-
failFormatted
public final CACommandExecutionFailure failFormatted(Exception exception, int statusCode, CAErrorCode errorCode, Map<CAStringConstantType, String> errorAttributes, CAStringConstantType messageId, Object... args) Produce an exception indicating an error, with a formatted error message.- Parameters:
exception- The exceptionstatusCode- The HTTP status kinderrorCode- The error kinderrorAttributes- The error attributesmessageId- The string resource message IDargs- The string resource format arguments- Returns:
- An execution failure
-
fail
public final CACommandExecutionFailure fail(int statusCode, CAErrorCode errorCode, String message, Map<CAStringConstantType, String> errorAttributes) Produce an exception indicating an error, with a string constant message.- Parameters:
statusCode- The HTTP status kinderrorCode- The error kindmessage- The string messageerrorAttributes- The error attributes- Returns:
- An execution failure
-
failWithCause
public final CACommandExecutionFailure failWithCause(Exception cause, int statusCode, CAErrorCode errorCode, String message, Map<String, String> errorAttributes) Produce an exception indicating an error, with a string constant message.- Parameters:
cause- The causestatusCode- The HTTP status kinderrorCode- The error kindmessage- The string messageerrorAttributes- The error attributes- Returns:
- An execution failure
-
failDatabase
Produce an exception indicating a database error.- Parameters:
e- The database exception- Returns:
- An execution failure
-
failSecurity
Produce an exception indicating a security policy error.- Parameters:
e- The security exception- Returns:
- An execution failure
-
failProtocol
Produce an exception indicating a protocol error.- Parameters:
e- The exception- Returns:
- An execution failure
-
failValidity
Produce an exception indicating a validation error.- Parameters:
e- The exception- Returns:
- An execution failure
-