Bump upstreams
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / netconf / sal / NetconfDeviceRpc.java
index 6679f06020aa06ad66faa189a0801f45b633897d..48cbbb9dbc13d94bd12831dbc651478bcb94fe36 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
 import org.opendaylight.mdsal.dom.api.DefaultDOMRpcException;
-import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceCommunicator;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices.Rpcs;
@@ -29,20 +28,20 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.concepts.NoOpListenerRegistration;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 /**
  * Invokes RPC by sending netconf message via listener. Also transforms result from NetconfMessage to
- * {@link NormalizedNode}.
+ * {@link ContainerNode}.
  */
 public final class NetconfDeviceRpc implements Rpcs.Normalized {
     private final RemoteDeviceCommunicator communicator;
-    private final RpcTransformer transformer;
+    private final RpcTransformer<ContainerNode, DOMRpcResult> transformer;
     private final EffectiveModelContext modelContext;
 
     public NetconfDeviceRpc(final EffectiveModelContext modelContext, final RemoteDeviceCommunicator communicator,
-            final RpcTransformer transformer) {
+            final RpcTransformer<ContainerNode, DOMRpcResult> transformer) {
         this.modelContext = requireNonNull(modelContext);
         this.communicator = communicator;
         this.transformer = transformer;
@@ -50,7 +49,7 @@ public final class NetconfDeviceRpc implements Rpcs.Normalized {
 
     @Override
     @SuppressWarnings("checkstyle:IllegalCatch")
-    public ListenableFuture<DOMRpcResult> invokeRpc(final QName type, final NormalizedNode input) {
+    public ListenableFuture<DOMRpcResult> invokeRpc(final QName type, final ContainerNode input) {
         final ListenableFuture<RpcResult<NetconfMessage>> delegateFuture = communicator.sendRequest(
             transformer.toRpcRequest(type, input), type);
 
@@ -58,13 +57,16 @@ public final class NetconfDeviceRpc implements Rpcs.Normalized {
         Futures.addCallback(delegateFuture, new FutureCallback<RpcResult<NetconfMessage>>() {
             @Override
             public void onSuccess(final RpcResult<NetconfMessage> result) {
+                final DOMRpcResult rpcResult;
                 try {
-                    ret.set(result.isSuccessful() ? transformer.toRpcResult(result.getResult(), type)
-                            : new DefaultDOMRpcResult(result.getErrors()));
+                    rpcResult = transformer.toRpcResult(result, type);
                 } catch (Exception cause) {
                     ret.setException(new DefaultDOMRpcException(
-                            "Unable to parse rpc reply. type: " + type + " input: " + input, cause));
+                        "Unable to parse rpc reply. type: " + type + " input: " + input, cause));
+                    return;
                 }
+
+                ret.set(rpcResult);
             }
 
             @Override