From b28444e372162528d42d86363918bfcf49d00058 Mon Sep 17 00:00:00 2001 From: "miroslav.kovac" Date: Fri, 2 Sep 2016 09:58:27 +0200 Subject: [PATCH] Bug 6429 - Fix notification xml output according to RFC Change-Id: If0802ee4a3bb3a2d0938977a3420298156833286 Signed-off-by: miroslav.kovac --- .../listeners/NotificationListenerAdapter.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java index 42f0996052..db8b27821b 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java @@ -200,16 +200,16 @@ public class NotificationListenerAdapter implements DOMNotificationListener { private String prepareXmlFrom(final DOMNotification notification) { final SchemaContext schemaContext = ControllerContext.getInstance().getGlobalSchema(); final Document doc = ListenerAdapter.createDocument(); - final Element notificationElement = doc.createElementNS("urn:ietf:params:xml:ns:netconf:notification:1.0", + final Element notificationElement = doc.createElementNS("urn:ietf:params:xml:ns:yang:ietf-restconf", "notification"); doc.appendChild(notificationElement); final Element eventTimeElement = doc.createElement("eventTime"); eventTimeElement.setTextContent(ListenerAdapter.toRFC3339(new Date())); notificationElement.appendChild(eventTimeElement); - + final String notificationNamespace = notification.getType().getLastComponent().getNamespace().toString(); final Element notificationEventElement = doc.createElementNS( - "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "create-notification-stream"); + notificationNamespace, "event"); addValuesToNotificationEventElement(doc, notificationEventElement, notification, schemaContext); notificationElement.appendChild(notificationEventElement); @@ -243,9 +243,7 @@ public class NotificationListenerAdapter implements DOMNotificationListener { final DOMResult domResult = writeNormalizedNode(body, YangInstanceIdentifier.create(body.getIdentifier()), schemaContext); final Node result = doc.importNode(domResult.getNode().getFirstChild(), true); - final Element dataElement = doc.createElement("notification"); - dataElement.appendChild(result); - element.appendChild(dataElement); + element.appendChild(result); } catch (final IOException e) { LOG.error("Error in writer ", e); } catch (final XMLStreamException e) { @@ -385,6 +383,6 @@ public class NotificationListenerAdapter implements DOMNotificationListener { * Type of the event. */ private enum EventType { - REGISTER, DEREGISTER, NOTIFY; + REGISTER, DEREGISTER, NOTIFY } } -- 2.36.6