Code Review
/
netconf.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Adjust to yangtools-2.0.0/odlparent-3.0.0 changes
[netconf.git]
/
restconf
/
restconf-nb-bierman02
/
src
/
main
/
java
/
org
/
opendaylight
/
netconf
/
sal
/
streams
/
listeners
/
NotificationListenerAdapter.java
diff --git
a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java
b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java
index a5999ddfacc1aefef9b1e9f955988a40d4c80924..9775e344f6018361eb4b7d07bbafe5117136edeb 100644
(file)
--- a/
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java
+++ b/
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java
@@
-21,7
+21,7
@@
import javax.xml.transform.dom.DOMResult;
import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
-import org.opendaylight.
netconf.sal.restconf.impl
.RestconfDocumentedException;
+import org.opendaylight.
restconf.common.errors
.RestconfDocumentedException;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
@@
-66,10
+66,7
@@
public class NotificationListenerAdapter extends AbstractCommonSubscriber implem
* type of output on notification (JSON, XML)
*/
NotificationListenerAdapter(final SchemaPath path, final String streamName, final String outputType) {
* type of output on notification (JSON, XML)
*/
NotificationListenerAdapter(final SchemaPath path, final String streamName, final String outputType) {
- super();
register(this);
register(this);
- setLocalNameOfPath(path.getLastComponent().getLocalName());
-
this.outputType = Preconditions.checkNotNull(outputType);
this.path = Preconditions.checkNotNull(path);
Preconditions.checkArgument(streamName != null && !streamName.isEmpty());
this.outputType = Preconditions.checkNotNull(outputType);
this.path = Preconditions.checkNotNull(path);
Preconditions.checkArgument(streamName != null && !streamName.isEmpty());
@@
-87,6
+84,7
@@
public class NotificationListenerAdapter extends AbstractCommonSubscriber implem
}
@Override
}
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
public void onNotification(final DOMNotification notification) {
this.schemaContext = ControllerContext.getInstance().getGlobalSchema();
this.notification = notification;
public void onNotification(final DOMNotification notification) {
this.schemaContext = ControllerContext.getInstance().getGlobalSchema();
this.notification = notification;
@@
-138,8
+136,8
@@
public class NotificationListenerAdapter extends AbstractCommonSubscriber implem
*/
@VisibleForTesting
String prepareJson() {
*/
@VisibleForTesting
String prepareJson() {
- JsonParser jsonParser = new JsonParser();
- JsonObject json = new JsonObject();
+
final
JsonParser jsonParser = new JsonParser();
+
final
JsonObject json = new JsonObject();
json.add("ietf-restconf:notification", jsonParser.parse(writeBodyToString()));
json.addProperty("event-time", ListenerAdapter.toRFC3339(Instant.now()));
return json.toString();
json.add("ietf-restconf:notification", jsonParser.parse(writeBodyToString()));
json.addProperty("event-time", ListenerAdapter.toRFC3339(Instant.now()));
return json.toString();
@@
-176,18
+174,13
@@
public class NotificationListenerAdapter extends AbstractCommonSubscriber implem
final Element notificationEventElement = doc.createElementNS(
"urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "create-notification-stream");
final Element notificationEventElement = doc.createElementNS(
"urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "create-notification-stream");
- addValuesToNotificationEventElement(doc, notificationEventElement
, this.notification, this.schemaContext
);
+ addValuesToNotificationEventElement(doc, notificationEventElement);
notificationElement.appendChild(notificationEventElement);
return transformDoc(doc);
}
notificationElement.appendChild(notificationEventElement);
return transformDoc(doc);
}
- private void addValuesToNotificationEventElement(final Document doc, final Element element,
- final DOMNotification notification, final SchemaContext schemaContext) {
- if (notification == null) {
- return;
- }
-
+ private void addValuesToNotificationEventElement(final Document doc, final Element element) {
final NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> body =
notification.getBody();
try {
final NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> body =
notification.getBody();
try {