From a4cf7d7b063ab2e0c6ce356170b8924f73768b30 Mon Sep 17 00:00:00 2001 From: liujun <273793041@qq.com> Date: Fri, 28 Oct 2022 14:51:22 +0800 Subject: [PATCH] fix #1077 --- .../webhook/receive/WebHookController.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/eventmesh-webhook/eventmesh-webhook-receive/src/main/java/org/apache/eventmesh/webhook/receive/WebHookController.java b/eventmesh-webhook/eventmesh-webhook-receive/src/main/java/org/apache/eventmesh/webhook/receive/WebHookController.java index 52df13c248..cdba71a1c6 100644 --- a/eventmesh-webhook/eventmesh-webhook-receive/src/main/java/org/apache/eventmesh/webhook/receive/WebHookController.java +++ b/eventmesh-webhook/eventmesh-webhook-receive/src/main/java/org/apache/eventmesh/webhook/receive/WebHookController.java @@ -47,6 +47,14 @@ public class WebHookController { private static final String CONTENT_TYPE = "content-type"; + private static final String UUID_GENERATE_MODE = "uuid"; + + private static final String WEBSITE_PREFIX = "www."; + + private static final String WEBSITE_SUFFIX = ".com"; + + private static final String DOT = "."; + /** * protocol pool */ @@ -106,13 +114,13 @@ public void execute(String path, Map header, byte[] body) throws } // 3. convert to cloudEvent obj - String cloudEventId = "uuid".equals(webHookConfig.getCloudEventIdGenerateMode()) ? UUID.randomUUID().toString() + String cloudEventId = UUID_GENERATE_MODE.equals(webHookConfig.getCloudEventIdGenerateMode()) ? UUID.randomUUID().toString() : webHookRequest.getManufacturerEventId(); - String eventType = manufacturerName + "." + webHookConfig.getManufacturerEventName(); + String eventType = manufacturerName + DOT + webHookConfig.getManufacturerEventName(); WebhookProtocolTransportObject webhookProtocolTransportObject = WebhookProtocolTransportObject.builder() .cloudEventId(cloudEventId).eventType(eventType).cloudEventName(webHookConfig.getCloudEventName()) - .cloudEventSource("www." + webHookConfig.getManufacturerName() + ".com") + .cloudEventSource(WEBSITE_PREFIX + webHookConfig.getManufacturerName() + WEBSITE_SUFFIX) .dataContentType(webHookConfig.getDataContentType()).body(body).build(); // 4. send cloudEvent