Package com.sap.cds.services.messages
Interface Message
public interface Message
Messages 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
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionAdds the passedcodeto the current message.static Messagecreate(Message.Severity severity, String text) This method creates a standalone instance ofMessagethat is not added to theMessagesof the activeRequestContext.static Messagecreate(Message.Severity severity, String text, Message message) This method creates a standalone instance ofMessagethat is not added to theMessagesof the activeRequestContext.static Messagecreate(String text, ServiceException exception) This method creates a standalone instance ofMessagethat is not added to theMessagesof the activeRequestContext.getCode()The optional code of the messageThe optional long text urlThe localized messageThe severity of the message.The optionalMessageTargetlongTextUrl(String longTextUrl) Adds the passedlongTextUrlto 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 ofMessagethat is not added to theMessagesof the activeRequestContext.- Parameters:
severity- theMessage.Severityof theMessagetext- the final text of the message. For localization useCdsRuntime.getLocalizedMessage(String, Object[], Locale)explicitly.- Returns:
- Created
Messageinstance.
-
create
This method creates a standalone instance ofMessagethat is not added to theMessagesof the activeRequestContext.- Parameters:
severity- theMessage.Severityof theMessagetext- the final text of the message. For localization useCdsRuntime.getLocalizedMessage(String, Object[], Locale)explicitly.message- theMessageto copy optional arguments from- Returns:
- the
Messageinstance
-
create
This method creates a standalone instance ofMessagethat is not added to theMessagesof the activeRequestContext.- Parameters:
text- the final text of the message. For localization useCdsRuntime.getLocalizedMessage(String, Object[], Locale)explicitly.exception- theServiceExceptionto copy optional arguments from- Returns:
- the
Messageinstance
-
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 passedlongTextUrlto the current message.- Parameters:
longTextUrl- The long text url to be set- Returns:
- The current message
-
code
Adds the passedcodeto 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_CQNindicates 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_CQNindicates 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 theCdsDataProcessorand its functional interfaces.- Parameters:
path- the pathelement- the target element or association- Returns:
- the current message
-