chenqinyuan opened a new issue, #1905: URL: https://github.com/apache/incubator-eventmesh/issues/1905
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/eventmesh/issues?q=is%3Aissue) and found no similar issues. ### Enhancement Request ` @Override public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException { final HttpEventWrapper httpEventWrapper = new HttpEventWrapper(); Map<String, Object> sysHeaderMap = new HashMap<>(); // ce attributes Set<String> attributeNames = cloudEvent.getAttributeNames(); // ce extensions Set<String> extensionNames = cloudEvent.getExtensionNames(); for (String attributeName : attributeNames) { sysHeaderMap.put(attributeName, cloudEvent.getAttribute(attributeName)); } for (String extensionName : extensionNames) { sysHeaderMap.put(extensionName, cloudEvent.getExtension(extensionName)); } sysHeaderMap.put("cloudEventId", cloudEvent.getId()); sysHeaderMap.put("cloudEventName", cloudEvent.getSubject()); sysHeaderMap.put("cloudEventSource", cloudEvent.getSource().toString()); sysHeaderMap.put("type", cloudEvent.getType()); httpEventWrapper.setSysHeaderMap(sysHeaderMap); httpEventWrapper.setBody(cloudEvent.getData().toBytes()); return httpEventWrapper; } ` located at: org/apache/eventmesh/protocol/webhook/WebHookProtocolAdaptor.java line78 Add NPE to check for exceptions. ### Describe the solution you'd like ` @Override public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException { final HttpEventWrapper httpEventWrapper = new HttpEventWrapper(); Map<String, Object> sysHeaderMap = new HashMap<>(); // ce attributes Set<String> attributeNames = cloudEvent.getAttributeNames(); // ce extensions Set<String> extensionNames = cloudEvent.getExtensionNames(); for (String attributeName : attributeNames) { sysHeaderMap.put(attributeName, cloudEvent.getAttribute(attributeName)); } for (String extensionName : extensionNames) { sysHeaderMap.put(extensionName, cloudEvent.getExtension(extensionName)); } sysHeaderMap.put("cloudEventId", cloudEvent.getId()); sysHeaderMap.put("cloudEventName", cloudEvent.getSubject()); sysHeaderMap.put("cloudEventSource", cloudEvent.getSource().toString()); sysHeaderMap.put("type", cloudEvent.getType()); httpEventWrapper.setSysHeaderMap(sysHeaderMap); if(cloudEvent.getData() != null){ httpEventWrapper.setBody(cloudEvent.getData().toBytes()); } return httpEventWrapper; } ` ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
