X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2FControllerContext.xtend;h=624178569d4e71551507f7733cec7c93bf4b032c;hb=7007ef0c2b418b9b49e56e6c3525e8906fefa522;hp=5057413a7a0710b8261e359340fca5b0820e4f2f;hpb=b5daa3678322a764f9b0e2483f82781f4d39d263;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend index 5057413a7a..624178569d 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend @@ -24,18 +24,23 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode import org.opendaylight.yangtools.yang.model.api.SchemaContext import static com.google.common.base.Preconditions.* +import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener +import org.opendaylight.yangtools.yang.model.api.RpcDefinition +import java.util.concurrent.ConcurrentHashMap + +class ControllerContext implements SchemaServiceListener { -class ControllerContext { - val static ControllerContext INSTANCE = new ControllerContext - + val static NULL_VALUE = "null" - + @Property SchemaContext schemas; private val BiMap uriToModuleName = HashBiMap.create(); private val Map moduleNameToUri = uriToModuleName.inverse(); + private val Map qnameToRpc = new ConcurrentHashMap(); + private new() { if (INSTANCE != null) { @@ -208,6 +213,7 @@ class ControllerContext { if (targetNode instanceof ListSchemaNode) { val listNode = targetNode as ListSchemaNode; val keysSize = listNode.keyDefinition.size + // every key has to be filled if ((strings.length - consumed) < keysSize) { return null; @@ -217,6 +223,7 @@ class ControllerContext { var i = 0; for (key : listNode.keyDefinition) { val uriKeyValue = uriKeyValues.get(i); + // key value cannot be NULL if (uriKeyValue.equals(NULL_VALUE)) { return null @@ -227,6 +234,7 @@ class ControllerContext { consumed = consumed + i; builder.nodeWithKey(targetNode.QName, keyValues); } else { + // Only one instance of node is allowed builder.node(targetNode.QName); } @@ -268,6 +276,27 @@ class ControllerContext { } } - public def QName toRpcQName(String name) { + public def QName toQName(String name) { + val module = name.toModuleName; + val node = name.toNodeName; + val namespace = moduleNameToUri.get(module); + return new QName(namespace,null,node); } + + override onGlobalContextUpdated(SchemaContext context) { + this.schemas = context; + for(operation : context.operations) { + val qname = new QName(operation.QName.namespace,null,operation.QName.localName); + qnameToRpc.put(qname,operation); + } + } + + def ContainerSchemaNode getRpcOutputSchema(QName name) { + qnameToRpc.get(name)?.output; + } + + def ContainerSchemaNode getRpcInputSchema(QName name) { + qnameToRpc.get(name)?.input; + } + }