Bug 6856: Rpc definition should implicitly define input/output 36/52936/1
authorIgor Foltin <ifoltin@cisco.com>
Mon, 6 Mar 2017 13:41:23 +0000 (14:41 +0100)
committerIgor Foltin <ifoltin@cisco.com>
Tue, 7 Mar 2017 10:53:11 +0000 (10:53 +0000)
Corresponding patch for netconf.

Change-Id: I041a90e222578f43144d42cd72dd2f9457362a4a
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
(cherry picked from commit 23f46e2b1c14be9ee7be61d3285d52cc27cfaefc)

netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpc.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/BaseRpcSchemalessTransformer.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGenerator.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ModelGenerator.java

index 94dfa5e38a5d94f109a7597dbbb61a8a3806eb32..5d5966e4f36baafedd8aab58c0d94fd3fd359d9d 100644 (file)
@@ -251,7 +251,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
      */
     @Nullable
     private NormalizedNode<?, ?> rpcToNNode(final XmlElement oElement, @Nullable final ContainerSchemaNode input) {
-        return input == null ? null : DomToNormalizedNodeParserFactory
+        return input.getChildNodes().isEmpty() ? null : DomToNormalizedNodeParserFactory
                 .getInstance(DomUtils.defaultValueCodecProvider(), schemaContext.getCurrentContext())
                 .getContainerNodeParser()
                 .parse(Collections.singletonList(oElement.getDomElement()), input);
index 0448c709a95cfffe985016aa66ebdb0cb9438cf3..9c97d7ab4d65a27c00a865784b46737972c73488 100644 (file)
@@ -60,7 +60,7 @@ public class BaseRpcSchemalessTransformer implements MessageTransformer<NetconfM
 
         Preconditions.checkNotNull(mappedRpcs.get(rpcQName), "Unknown rpc %s, available rpcs: %s", rpcQName, mappedRpcs.keySet());
         final DOMResult domResult = NetconfMessageTransformUtil.prepareDomResultForRpcRequest(rpcQName, counter);
-        if(mappedRpcs.get(rpcQName).getInput() == null) {
+        if (mappedRpcs.get(rpcQName).getInput().getChildNodes().isEmpty()) {
             return new NetconfMessage(domResult.getNode().getOwnerDocument());
         }
 
index 0abd74409709240a7b9ab13620e9b484b096b1b2..ada96c4577a94b391b128be68d153cd5ff1ac628 100644 (file)
@@ -140,7 +140,7 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
         }
 
         Preconditions.checkNotNull(currentMappedRpcs.get(rpcQName), "Unknown rpc %s, available rpcs: %s", rpcQName, currentMappedRpcs.keySet());
-        if(currentMappedRpcs.get(rpcQName).getInput() == null) {
+        if(currentMappedRpcs.get(rpcQName).getInput().getChildNodes().isEmpty()) {
             return new NetconfMessage(NetconfMessageTransformUtil.prepareDomResultForRpcRequest(rpcQName, counter).getNode().getOwnerDocument());
         }
 
@@ -205,7 +205,7 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
             Preconditions.checkArgument(rpcDefinition != null, "Unable to parse response of %s, the rpc is unknown", rpcQName);
 
             // In case no input for rpc is defined, we can simply construct the payload here
-            if (rpcDefinition.getOutput() == null) {
+            if (rpcDefinition.getOutput().getChildNodes().isEmpty()) {
                 Preconditions.checkArgument(XmlElement.fromDomDocument(
                     message.getDocument()).getOnlyChildElementWithSameNamespaceOptionally("ok").isPresent(),
                     "Unexpected content in response of rpc: %s, %s", rpcDefinition.getQName(), message);
index a09dbcc4a4378b3d7cca0545a877d305d9ad3215..ea24dbf062984911cfbd7b045ff16a5038f1b973 100644 (file)
@@ -634,7 +634,7 @@ public class RestconfImpl implements RestconfService {
             throw new RestconfDocumentedException("RPC does not exist.", ErrorType.RPC, ErrorTag.UNKNOWN_ELEMENT);
         }
 
-        if (rpc.getInput() != null) {
+        if (!rpc.getInput().getChildNodes().isEmpty()) {
             LOG.debug("RPC " + rpc + " does not need input value.");
             // FIXME : find a correct Error from specification
             throw new IllegalStateException("RPC " + rpc + " does'n need input value!");
index 55c62b24a1b38fa22b1a806b61f325340f91d94b..1d0b1fb575480b54a59e3e5b80e7363cb361f0e1 100644 (file)
@@ -421,10 +421,10 @@ public class BaseYangSwaggerGenerator {
         operationSpec.setMethod("POST");
         operationSpec.setNotes(rpcDefn.getDescription());
         operationSpec.setNickname(rpcDefn.getQName().getLocalName());
-        if (rpcDefn.getOutput() != null) {
+        if (!rpcDefn.getOutput().getChildNodes().isEmpty()) {
             operationSpec.setType("(" + rpcDefn.getQName().getLocalName() + ")output" + OperationBuilder.TOP);
         }
-        if (rpcDefn.getInput() != null) {
+        if (!rpcDefn.getInput().getChildNodes().isEmpty()) {
             final Parameter payload = new Parameter();
             payload.setParamType("body");
             payload.setType("(" + rpcDefn.getQName().getLocalName() + ")input" + OperationBuilder.TOP);
index b7fcdd0d8b721d8c150067830fef2f934275bf00..a0e07adaf03726ad447965007d0a53ae39a39e16 100644 (file)
@@ -151,7 +151,7 @@ public class ModelGenerator {
         final String moduleName = module.getName();
         for (final RpcDefinition rpc : rpcs) {
             final ContainerSchemaNode input = rpc.getInput();
-            if (input != null) {
+            if (!input.getChildNodes().isEmpty()) {
                 final JSONObject properties = processChildren(input.getChildNodes(), moduleName, models, true, schemaContext);
 
                 final String filename = "(" + rpc.getQName().getLocalName() + ")input";
@@ -165,7 +165,7 @@ public class ModelGenerator {
             }
 
             final ContainerSchemaNode output = rpc.getOutput();
-            if (output != null) {
+            if (!output.getChildNodes().isEmpty()) {
                 final JSONObject properties = processChildren(output.getChildNodes(), moduleName, models, true, schemaContext);
                 final String filename = "(" + rpc.getQName().getLocalName() + ")output";
                 final JSONObject childSchema = getSchemaTemplate();