X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2FRestconfImpl.xtend;h=f1901d711259f1907aeb9f94817ffbf84694fffd;hb=31b7a44c89d1057489338492fcf62a64147bea24;hp=e09dc7ac017d143c65f45564beeb1783ed97a8be;hpb=4eb724db3877173d502ba38c6d83bec780b38bb2;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend index e09dc7ac01..f1901d7112 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend @@ -60,6 +60,8 @@ class RestconfImpl implements RestconfService { val static RESTCONF_MODULE_DRAFT02_RESTCONF_CONTAINER_SCHEMA_NODE = "restconf" val static RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE = "modules" val static RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE = "module" + val static RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE = "streams" + val static RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE = "stream" val static RESTCONF_MODULE_DRAFT02_OPERATIONS_CONTAINER_SCHEMA_NODE = "operations" val static SAL_REMOTE_NAMESPACE = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote" val static SAL_REMOTE_RPC_SUBSRCIBE = "create-data-change-event-subscription" @@ -92,6 +94,17 @@ class RestconfImpl implements RestconfService { return new StructuredData(modulesNode, modulesSchemaNode, null) } + override getAvailableStreams(){ + var Set availableStreams = Notificator.getStreamNames(); + val List> streamsAsData = new ArrayList + val streamSchemaNode = restconfModule.getSchemaNode(RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE) + for (String streamName:availableStreams){ + streamsAsData.add(streamName.toStreamCompositeNode(streamSchemaNode)) + } + val streamsSchemaNode = restconfModule.getSchemaNode(RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE) + val streamsNode = NodeFactory.createImmutableCompositeNode(streamsSchemaNode.QName, null, streamsAsData) + return new StructuredData(streamsNode, streamsSchemaNode, null) + } override getModules(String identifier) { var Set modules = null var MountInstance mountPoint = null @@ -196,6 +209,25 @@ class RestconfImpl implements RestconfService { } } + private def CompositeNode toStreamCompositeNode(String streamName, DataSchemaNode streamSchemaNode) { + val List> streamNodeValues = new ArrayList + val nameSchemaNode = (streamSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("name").head + streamNodeValues.add(NodeFactory.createImmutableSimpleNode(nameSchemaNode.QName, null, streamName)) + + val descriptionSchemaNode = (streamSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("description").head + streamNodeValues.add(NodeFactory.createImmutableSimpleNode(descriptionSchemaNode.QName, null, "DESCRIPTION_PLACEHOLDER")) + + val replaySupportSchemaNode = (streamSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("replay-support").head + streamNodeValues.add(NodeFactory.createImmutableSimpleNode(replaySupportSchemaNode.QName, null, true)) + + val replayLogCreationTimeSchemaNode = (streamSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("replay-log-creation-time").head + streamNodeValues.add(NodeFactory.createImmutableSimpleNode(replayLogCreationTimeSchemaNode.QName, null, "")) + + val eventsSchemaNode = (streamSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("events").head + streamNodeValues.add(NodeFactory.createImmutableSimpleNode(eventsSchemaNode.QName, null, "")) + + return NodeFactory.createImmutableCompositeNode(streamSchemaNode.QName, null, streamNodeValues) + } private def CompositeNode toModuleCompositeNode(Module module, DataSchemaNode moduleSchemaNode) { val List> moduleNodeValues = new ArrayList val nameSchemaNode = (moduleSchemaNode as DataNodeContainer).findInstanceDataChildrenByName("name").head @@ -216,7 +248,12 @@ class RestconfImpl implements RestconfService { val restconfContainer = restconfGrouping.findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_RESTCONF_CONTAINER_SCHEMA_NODE).head if (schemaNodeName == RESTCONF_MODULE_DRAFT02_OPERATIONS_CONTAINER_SCHEMA_NODE) { return (restconfContainer as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_OPERATIONS_CONTAINER_SCHEMA_NODE).head - } else if (schemaNodeName == RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE) { + } else if (schemaNodeName == RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE) { + return (restconfContainer as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE).head + } else if (schemaNodeName == RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE) { + val modules = (restconfContainer as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_STREAMS_CONTAINER_SCHEMA_NODE).head + return (modules as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_STREAM_LIST_SCHEMA_NODE).head + }else if (schemaNodeName == RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE) { return (restconfContainer as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE).head } else if (schemaNodeName == RESTCONF_MODULE_DRAFT02_MODULE_LIST_SCHEMA_NODE) { val modules = (restconfContainer as DataNodeContainer).findInstanceDataChildrenByName(RESTCONF_MODULE_DRAFT02_MODULES_CONTAINER_SCHEMA_NODE).head @@ -268,7 +305,7 @@ class RestconfImpl implements RestconfService { return callRpc(rpc, null) } - def resolveIdentifierInInvokeRpc(String identifier) { + private def resolveIdentifierInInvokeRpc(String identifier) { if (identifier.indexOf("/") === -1) { val identifierDecoded = identifier.urlPathArgDecode val rpc = identifierDecoded.rpcDefinition @@ -277,8 +314,8 @@ class RestconfImpl implements RestconfService { } throw new ResponseException(NOT_FOUND, "RPC does not exist."); } - val slashErrorMsg = String.format("Identifier %n%s%ncan't contain slash character (/). + - If slash is part of identifier name then use %2F placeholder.",identifier) + val slashErrorMsg = String.format( + "Identifier %n%s%ncan't contain slash character (/).%nIf slash is part of identifier name then use %%2F placeholder.", identifier) throw new ResponseException(NOT_FOUND, slashErrorMsg); } @@ -551,7 +588,11 @@ class RestconfImpl implements RestconfService { } if (node instanceof CompositeNodeWrapper) { if ((node as CompositeNodeWrapper).changeAllowed) { - normalizeNode(node as CompositeNodeWrapper, schema, null, mountPoint) + try { + normalizeNode(node as CompositeNodeWrapper, schema, null, mountPoint) + } catch (NumberFormatException e) { + throw new ResponseException(BAD_REQUEST,e.message) + } } return (node as CompositeNodeWrapper).unwrap() } @@ -632,7 +673,7 @@ class RestconfImpl implements RestconfService { if (schema.typeDefinition instanceof IdentityrefTypeDefinition) { if (value instanceof String) { - inputValue = new IdentityValuesDTO(nodeBuilder.namespace.toString, value as String, null) + inputValue = new IdentityValuesDTO(nodeBuilder.namespace.toString, value as String, null,value as String); } // else value is already instance of IdentityValuesDTO }