Bug fixes

- Netconf get family should return from <data
- adapt ODTN driver to that behavior

Change-Id: I25508518354914fdd239beab3a9951eff3586e41
diff --git a/drivers/odtn-driver/src/main/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscovery.java b/drivers/odtn-driver/src/main/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscovery.java
index 5bd7345..b2e76a2 100644
--- a/drivers/odtn-driver/src/main/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscovery.java
+++ b/drivers/odtn-driver/src/main/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscovery.java
@@ -42,8 +42,6 @@
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
 import org.onosproject.netconf.NetconfController;
 import org.onosproject.netconf.NetconfDevice;
-import org.onosproject.netconf.NetconfRpcParserUtil;
-import org.onosproject.netconf.NetconfRpcReply;
 import org.onosproject.netconf.NetconfSession;
 import org.onosproject.odtn.behaviour.OdtnDeviceDescriptionDiscovery;
 import org.slf4j.Logger;
@@ -87,20 +85,15 @@
 
         // TODO convert this method into non-blocking form?
 
-        NetconfRpcReply reply = ns.asyncGet()
-            .thenApply(NetconfRpcParserUtil::parseRpcReply)
-            .join();
+        String reply = ns.asyncGet()
+            .join().toString();
 
-        if (reply.hasError()) {
-            log.error("Netconf error replies from {}:\n{}", did, reply.errors());
-            return ImmutableList.of();
+        // workaround until asyncGet().join() start failing exceptionally
+        String data = null;
+        if (reply.startsWith("<data")) {
+            data = reply;
         }
 
-        String data = reply.responses().stream()
-                .filter(s -> s.startsWith("<data"))
-                .findFirst()
-                .orElse(null);
-
         if (data == null) {
             log.error("No valid response found from {}:\n{}", did, reply);
             return ImmutableList.of();
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
index 0a478fe..0711137 100644
--- a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
+++ b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
@@ -87,7 +87,7 @@
                     int begin = msg.indexOf("<data>");
                     int end = msg.lastIndexOf("</data>");
                     if (begin != -1 && end != -1) {
-                        return msg.subSequence(begin + "<data>".length(), end);
+                        return msg.subSequence(begin, end + "</data>".length());
                     } else {
                         // FIXME probably should exceptionally fail here.
                         return msg;
@@ -116,7 +116,7 @@
                     int begin = msg.indexOf("<data>");
                     int end = msg.lastIndexOf("</data>");
                     if (begin != -1 && end != -1) {
-                        return msg.subSequence(begin + "<data>".length(), end);
+                        return msg.subSequence(begin, end + "</data>".length());
                     } else {
                         // FIXME probably should exceptionally fail here.
                         return msg;