[ONOS-7297] DC App to adapt changes wherein RpcInput contains ResourceId.

Change-Id: I066643af52037733789e9af0c9d87ed0f2f41206
diff --git a/apps/config/src/main/java/org/onosproject/config/DynamicConfigService.java b/apps/config/src/main/java/org/onosproject/config/DynamicConfigService.java
index bb562e8..25bceb8 100644
--- a/apps/config/src/main/java/org/onosproject/config/DynamicConfigService.java
+++ b/apps/config/src/main/java/org/onosproject/config/DynamicConfigService.java
@@ -120,5 +120,15 @@
      * @return future that will be completed with RpcOutput
      * @throws FailedException if the RPC could not be invoked
      */
+    @Deprecated
     CompletableFuture<RpcOutput> invokeRpc(ResourceId id, RpcInput input);
+
+    /**
+     * Invokes an RPC.
+     *
+     * @param input RPC input with ResourceId and DataNode
+     * @return future that will be completed with RpcOutput
+     * @throws FailedException if the RPC could not be invoked
+     */
+    CompletableFuture<RpcOutput> invokeRpc(RpcInput input);
 }
\ No newline at end of file
diff --git a/apps/config/src/main/java/org/onosproject/config/DynamicConfigServiceAdapter.java b/apps/config/src/main/java/org/onosproject/config/DynamicConfigServiceAdapter.java
index 4dcd671..a74aaae 100644
--- a/apps/config/src/main/java/org/onosproject/config/DynamicConfigServiceAdapter.java
+++ b/apps/config/src/main/java/org/onosproject/config/DynamicConfigServiceAdapter.java
@@ -69,6 +69,12 @@
     }
 
     @Override
+    public CompletableFuture<RpcOutput> invokeRpc(RpcInput input) {
+        //TODO: implement me, not sure about purpose of this adapter.
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
     public void addListener(DynamicConfigListener listener) {
         listenerRegistry.addListener(listener);
     }
diff --git a/apps/config/src/main/java/org/onosproject/config/ForwardingDynamicConfigService.java b/apps/config/src/main/java/org/onosproject/config/ForwardingDynamicConfigService.java
index b8e9167..5fcdc04 100644
--- a/apps/config/src/main/java/org/onosproject/config/ForwardingDynamicConfigService.java
+++ b/apps/config/src/main/java/org/onosproject/config/ForwardingDynamicConfigService.java
@@ -85,4 +85,9 @@
                                                   RpcInput input) {
         return delegate.invokeRpc(id, input);
     }
+
+    @Override
+    public CompletableFuture<RpcOutput> invokeRpc(RpcInput input) {
+        return delegate.invokeRpc(input);
+    }
 }
diff --git a/apps/config/src/main/java/org/onosproject/config/impl/DynamicConfigManager.java b/apps/config/src/main/java/org/onosproject/config/impl/DynamicConfigManager.java
index d976a40..cdec56a 100644
--- a/apps/config/src/main/java/org/onosproject/config/impl/DynamicConfigManager.java
+++ b/apps/config/src/main/java/org/onosproject/config/impl/DynamicConfigManager.java
@@ -51,6 +51,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 import org.slf4j.Logger;
 
+import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onosproject.d.config.DeviceResourceIds.DCS_NAMESPACE;
 import static org.slf4j.LoggerFactory.getLogger;
 
@@ -206,6 +207,21 @@
                                 context.rpcName(), RpcMessageId.generate(), input));
     }
 
+    @Override
+    public CompletableFuture<RpcOutput> invokeRpc(RpcInput input) {
+        checkNotNull(input);
+        checkNotNull(input.id());
+        RpcContext context = contextProvider.getRpcContext(input.id());
+        String srvcIntf = context.serviceIntf().getName();
+        RpcService handler = handlerRegistry.get(srvcIntf);
+        if (handler == null) {
+            throw new FailedException("No registered handler found, cannot invoke");
+        }
+        return CompletableFuture.supplyAsync(
+            new RpcExecutor(handler, getSvcId(handler, srvcIntf),
+                context.rpcName(), RpcMessageId.generate(), input));
+    }
+
     /**
      * Auxiliary store delegate to receive notification about changes in the store.
      */
diff --git a/apps/config/src/main/java/org/onosproject/d/config/DynamicDeviceConfigServiceView.java b/apps/config/src/main/java/org/onosproject/d/config/DynamicDeviceConfigServiceView.java
index c3f3e7b..2d25fcb 100644
--- a/apps/config/src/main/java/org/onosproject/d/config/DynamicDeviceConfigServiceView.java
+++ b/apps/config/src/main/java/org/onosproject/d/config/DynamicDeviceConfigServiceView.java
@@ -117,6 +117,11 @@
     }
 
     @Override
+    public CompletableFuture<RpcOutput> invokeRpc(RpcInput input) {
+        return super.invokeRpc(new RpcInput(toAbsoluteId(input.id()), input.data()));
+    }
+
+    @Override
     public void addListener(DynamicConfigListener listener) {
         super.addListener(wrapped.computeIfAbsent(listener,
                                                   DynamicDeviceConfigListener::new));
diff --git a/apps/restconf/restconfmgr/src/main/java/org/onosproject/restconf/restconfmanager/RestconfManager.java b/apps/restconf/restconfmgr/src/main/java/org/onosproject/restconf/restconfmanager/RestconfManager.java
index 0ad6b25..3ef0aca 100644
--- a/apps/restconf/restconfmgr/src/main/java/org/onosproject/restconf/restconfmanager/RestconfManager.java
+++ b/apps/restconf/restconfmgr/src/main/java/org/onosproject/restconf/restconfmanager/RestconfManager.java
@@ -276,12 +276,12 @@
         ResourceId resourceId = rpcInputNode.resourceId();
         List<DataNode> inputDataNodeList = rpcInputNode.dataNodes();
         DataNode inputDataNode = inputDataNodeList.get(0);
-        RpcInput rpcInput = new RpcInput(inputDataNode);
+        RpcInput rpcInput = new RpcInput(resourceId, inputDataNode);
 
         RestconfRpcOutput restconfOutput = null;
         try {
             CompletableFuture<RpcOutput> rpcFuture =
-                    dynamicConfigService.invokeRpc(resourceId, rpcInput);
+                    dynamicConfigService.invokeRpc(rpcInput);
             RpcOutput rpcOutput = rpcFuture.get();
             restconfOutput = RestconfUtils.convertRpcOutput(resourceId, rpcOutput);
         } catch (InterruptedException e) {