Class CloudEventUtils

java.lang.Object
com.sap.cds.services.messaging.utils.CloudEventUtils

public class CloudEventUtils extends Object
Utilities for CloudEvents according to SAP standards
  • Field Details

  • Constructor Details

    • CloudEventUtils

      public CloudEventUtils()
  • Method Details

    • toCloudEvent

      public static String toCloudEvent(String message, String defaultType, String namespace)
      Enriches the given message with cloudevents headers if not yet present
      Parameters:
      message - the message to enrich
      defaultType - the default type
      namespace - 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 enrich
      defaultType - the default type
      namespace - 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 context
      eventName - CDS event name
      Returns:
      the CloudEventMessageEventContext
    • toJson

      public static String toJson(Map<String,Object> map)
      Serializes the specified map to a JSON string.
      Parameters:
      map - map to be serialized in a JSON string
      Returns:
      the JSON string
    • toMap

      public static Map<String,Object> toMap(String jsonString)
      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