Search in sources :

Example 1 with CloudEventDeserializationException

use of com.redhat.service.smartevents.infra.exceptions.definitions.user.CloudEventDeserializationException in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ExecutorService method toSourceCloudEvent.

private CloudEvent toSourceCloudEvent(String event, Headers headers) {
    try {
        // JsonCloudEventData.wrap requires an empty JSON
        JsonNode payload = event == null ? mapper.createObjectNode() : mapper.readTree(event);
        CloudEventData data = JsonCloudEventData.wrap(payload);
        return wrapToCloudEvent(String.format("%s", executor.getProcessor().getDefinition().getRequestedSource().getType()), data, toExtensionsMap(headers));
    } catch (JsonProcessingException e2) {
        LOG.error("JsonProcessingException when generating CloudEvent for '{}'", event, e2);
        throw new CloudEventDeserializationException("Failed to generate event map");
    }
}
Also used : CloudEventDeserializationException(com.redhat.service.smartevents.infra.exceptions.definitions.user.CloudEventDeserializationException) BytesCloudEventData(io.cloudevents.core.data.BytesCloudEventData) CloudEventData(io.cloudevents.CloudEventData) JsonCloudEventData(io.cloudevents.jackson.JsonCloudEventData) JsonNode(com.fasterxml.jackson.databind.JsonNode) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 CloudEventDeserializationException (com.redhat.service.smartevents.infra.exceptions.definitions.user.CloudEventDeserializationException)1 CloudEventData (io.cloudevents.CloudEventData)1 BytesCloudEventData (io.cloudevents.core.data.BytesCloudEventData)1 JsonCloudEventData (io.cloudevents.jackson.JsonCloudEventData)1