Package com.sap.cds.services.messages
Interface Message
public interface Message
Message
s can be used to pass additional information along with the response.
Some clients such as Fiori UIs provide controls to show these messages in a user friendly way.-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds the passedcode
to the current message.static Message
create
(Message.Severity severity, String text) This method creates a standalone instance ofMessage
that is not added to theMessages
of the activeRequestContext
.static Message
create
(Message.Severity severity, String text, Message message) This method creates a standalone instance ofMessage
that is not added to theMessages
of the activeRequestContext
.static Message
create
(String text, ServiceException exception) This method creates a standalone instance ofMessage
that is not added to theMessages
of the activeRequestContext
.getCode()
The optional code of the messageThe optional long text urlThe localized messageThe severity of the message.The optionalMessageTarget
longTextUrl
(String longTextUrl) Adds the passedlongTextUrl
to the current message.target
(com.sap.cds.ql.cqn.Path path, com.sap.cds.reflect.CdsElement element) Adds the passed path and element as target to the currentMessage
.<E extends com.sap.cds.ql.StructuredType<E>>
MessageAdds the passed path as target to the currentMessage
.Sets the provided string-based target.<E extends com.sap.cds.ql.StructuredType<E>>
MessageAdds the passed target parameter and path as target to the currentMessage
.Adds the passed target parameter and path as target to the currentMessage
.Adds the passed path as target to the currentMessage
.
-
Method Details
-
create
This method creates a standalone instance ofMessage
that is not added to theMessages
of the activeRequestContext
.- Parameters:
severity
- theMessage.Severity
of theMessage
text
- the final text of the message. For localization useCdsRuntime.getLocalizedMessage(String, Object[], Locale)
explicitly.- Returns:
- Created
Message
instance.
-
create
This method creates a standalone instance ofMessage
that is not added to theMessages
of the activeRequestContext
.- Parameters:
severity
- theMessage.Severity
of theMessage
text
- the final text of the message. For localization useCdsRuntime.getLocalizedMessage(String, Object[], Locale)
explicitly.message
- theMessage
to copy optional arguments from- Returns:
- the
Message
instance
-
create
This method creates a standalone instance ofMessage
that is not added to theMessages
of the activeRequestContext
.- Parameters:
text
- the final text of the message. For localization useCdsRuntime.getLocalizedMessage(String, Object[], Locale)
explicitly.exception
- theServiceException
to copy optional arguments from- Returns:
- the
Message
instance
-
getCode
String getCode()The optional code of the message- Returns:
- The code
-
getMessage
String getMessage()The localized message- Returns:
- The localized message
-
getTarget
MessageTarget getTarget()The optionalMessageTarget
- Returns:
- The
MessageTarget
-
getLongTextUrl
String getLongTextUrl()The optional long text url- Returns:
- The long text url
-
getSeverity
Message.Severity getSeverity()The severity of the message.- Returns:
- The severity
-
longTextUrl
Adds the passedlongTextUrl
to the current message.- Parameters:
longTextUrl
- The long text url to be set- Returns:
- The current message
-
code
Adds the passedcode
to the current message.- Parameters:
code
- The code to be set- Returns:
- The current message
-
target
Sets the provided string-based target. No further processing of the string is performed.- Parameters:
target
- the string-based target- Returns:
- The current message
-
target
Adds the passed path as target to the currentMessage
. The path is interpreted relative to the CQN statement, which was determined from the request. For CRUD events this CQN statement points to the targeted entity. For bound actions or functions this CQN statement points to the bound entity. Is equivalent to callingtarget(MessageTarget.PARAMETER_CQN, path)
- Parameters:
path
- the path to the target element or association- Returns:
- The current message
-
target
Adds the passed target parameter and path as target to the currentMessage
.- Parameters:
parameter
- target parameter serving as the entry point for the path resolution. PassingMessageTarget.PARAMETER_CQN
indicates that the path should be interpreted relatively to the target entity of the request. Alternatively you can pass names of action or function parameters.path
- the path to the target element or association- Returns:
- The current message
-
target
Adds the passed path as target to the currentMessage
. This method allows to build the path in a type-safe way, by passing the corresponding entity or structured type interface. The path is interpreted relative to the CQN statement, which was determined from the request. For CRUD events this CQN statement points to the targeted entity. For bound actions or functions this CQN statement points to the bound entity. Is equivalent to callingtarget(MessageTarget.PARAMETER_CQN, type, path)
- Type Parameters:
E
- the type of the root- Parameters:
type
- the root type of the path. Either an entity or a structured type.path
- the path to the target element or association- Returns:
- The current message
-
target
<E extends com.sap.cds.ql.StructuredType<E>> Message target(String parameter, Class<E> type, Function<E, Object> path) Adds the passed target parameter and path as target to the currentMessage
. This method allows to build the path in a type-safe way, by passing the corresponding entity or structured type interface.- Type Parameters:
E
- the type of the root- Parameters:
parameter
- target parameter serving as the entry point for the path resolution. PassingMessageTarget.PARAMETER_CQN
indicates that the path should be interpreted relatively to the target entity of the request. Alternatively you can pass names of action or function parameters.type
- the root type of the path. Either an entity or a structured type.path
- the path to the target element or association- Returns:
- The current message
-
target
Adds the passed path and element as target to the currentMessage
. The path is interpreted relative to the CQN statement, which was determined from the request. For CRUD events this CQN statement points to the targeted entity. For bound actions or functions this CQN statement points to the bound entity. This method can be used with theCdsDataProcessor
and its functional interfaces.- Parameters:
path
- the pathelement
- the target element or association- Returns:
- the current message
-