@CompileStatic class MessageSourceResolvableSpecification extends Object
Data structure (a record) that defines the specification for creating message codes suitable for resolving messages against resource bundle.
At this moment, properties in this class, and corresponding implementations of message code resolvers fromorg.klokwrk.lib.hi.spring.context.MessageSourceResolvableHelper
, are highly
specialized to localize parts of JSON responses whose structure is defined by ResponseFormatting*
interceptors from org.klokwrk.cargotracking.lib.web.spring.mvc
package.
Be aware that actual implementations of message resolvers can choose to ignore any property from this specification.
Type | Name and description |
---|---|
String |
constraintViolationPropertyPath Specifies a property path whose value causes constraint violation in case of validation failures. |
String |
constraintViolationType Specifies a constraint violation type in case of validation failures. |
String |
controllerMethodName The method of the controller that is handling the current request. |
String |
controllerSimpleName The uncapitalized simple name of a controller that is handling the current request. |
String |
messageCategory High-level category of a message. |
String |
messageSubType The sub-type of a message that is used when further categorization of message types is needed. |
String |
messageSubTypeDetails Details of message sub-type used for further and deeper categorization of message sub-types in messageSubType .
|
String |
messageType Inside of a message category, this property determines a more specific type of outcome. |
String |
severity Specifies the severity of a message. |
Constructor and description |
---|
MessageSourceResolvableSpecification() |
Specifies a property path whose value causes constraint violation in case of validation failures.
Specifies a constraint violation type in case of validation failures.
The method of the controller that is handling the current request.
For example, if we haveorg.example.MyWebController.myMethod()
web controller method that is handling the current HTTP request, controllerMethodName
will be
myMethod
.
The controller does not have to be an HTTP/REST controller, but rather any type of controller accepting the client's requests. If used in messaging scenarios, controllerMethodName
might
be a simple class name of handled message or event.
The uncapitalized simple name of a controller that is handling the current request.
Typically, this is the uncapitalized name of the controller class name without the package. For example, if we haveorg.example.MyWebController
web controller class, controller's
uncapitalized simple name will be myWebController
.
The controller does not have to be an HTTP/REST controller, but rather any type of controller accepting the client's requests. For example, it can be a simple class name of the message handler
in messaging scenarios.
High-level category of a message.
Usually, it describes the type of outcome of current request handling. For our purposes, in case of errors, this property's value is specified asfailure
. If we need message
resolving for successful responses, this property's value should be success
.
The sub-type of a message that is used when further categorization of message types is needed.
For example, in HTTP/REST environment it might correspond to the string-message-encoded HTTP status. If we have status 500,messageType
will be unknown
(indicating
unexpected/unknown error), while messageSubType
might be internalServerError
. It is not recommended to use numerical values here (i.e. 500) since they are harder to
comprehend when reading keys in resource bundle files.
Let's look at another example. If we have some query controller trying to find and return entities based on some criteria. When the controller cannot find the result, the corresponding
messageType
will be domain
since we qualify that failure as a domain issue. But we still do not say anything more specific about the problem. This is where messageSubType
comes in, as it will contain notFound
value.
Details of message sub-type used for further and deeper categorization of message sub-types in messageSubType
.
messageSubType
, we might use messageSubTypeDetails
. For example, when localizing domain failure messages we might have notFound
messageSubType
and personSummary
messageSubTypeDetails
. In resource bundle this will end up with notFound.personSummary
sequence.
Inside of a message category, this property determines a more specific type of outcome.
For our purposes, in case of responses communicating some kind of error,messageType
will contain a string which categorizes the failure type. For this purpose we are using lowercase
values of org.klokwrk.cargotracking.lib.boundary.api.metadata.response.ViolationType
enum (domain
, validation
, etc.).
Specifies the severity of a message.
The value of this property corresponds to the lowercase values oforg.klokwrk.cargotracking.lib.boundary.api.severity.Severity
enum (error
, warning
, and info
).
Groovy Documentation