Class CloudEventUtils
java.lang.Object
com.sap.cds.services.messaging.utils.CloudEventUtils
Utilities for CloudEvents according to SAP standards
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringtoCloudEvent(String message, String defaultType, String namespace) Enriches the given message with cloudevents headers if not yet presentEnriches the given headers map with cloudevents headers if not yet presenttoCloudEventMessageContext(TopicMessageEventContext context, String eventName) Creates the cloud event message event context from the messaging context.static StringSerializes the specified map to a JSON string.Deserializes the specified JSON string to a map.
-
Field Details
-
KEY_ID
- See Also:
-
KEY_SPECVERSION
- See Also:
-
KEY_DATACONTENTTYPE
- See Also:
-
KEY_TIME
- See Also:
-
KEY_TYPE
- See Also:
-
KEY_SOURCE
- See Also:
-
KEY_DATA
- See Also:
-
-
Constructor Details
-
CloudEventUtils
public CloudEventUtils()
-
-
Method Details
-
toCloudEvent
Enriches the given message with cloudevents headers if not yet present- Parameters:
message- the message to enrichdefaultType- the default typenamespace- the namespace to try to be interpreted as source- Returns:
- enriched cloudevents message string
-
toCloudEvent
public static Map<String,Object> toCloudEvent(Map<String, Object> headers, String defaultType, String namespace) Enriches the given headers map with cloudevents headers if not yet present- Parameters:
headers- the headers to enrichdefaultType- the default typenamespace- the namespace to try to be interpreted as source- Returns:
- enriched cloudevents headers
-
toCloudEventMessageContext
public static CloudEventMessageEventContext toCloudEventMessageContext(TopicMessageEventContext context, String eventName) Creates the cloud event message event context from the messaging context.- Parameters:
context- messaging contexteventName- CDS event name- Returns:
- the
CloudEventMessageEventContext
-
toJson
Serializes the specified map to a JSON string.- Parameters:
map- map to be serialized in a JSON string- Returns:
- the JSON string
-
toMap
Deserializes the specified JSON string to a map.- Parameters:
jsonString- JSON string to be deserialized to a map- Returns:
- the map or null, if the JSON string is invalid
-