- /**
- * Get {@link DataSchemaNode} from {@link Module} Restconf module by
- * {@link String} schema node name.
- *
- * @param restconfModule
- * - restconf module
- * @param schemaNodeName
- * - schema node name
- * @return {@link DataSchemaNode}
- */
- public static DataSchemaNode getRestconfSchemaNode(final Module restconfModule, final String schemaNodeName) {
-
- final Set<GroupingDefinition> groupings = restconfModule.getGroupings();
- final GroupingDefinition restGroup = findSchemaNodeInCollection(groupings,
- Draft15.RestconfModule.RESTCONF_GROUPING_SCHEMA_NODE);
- final Collection<DataSchemaNode> childNodes = restGroup.getChildNodes();
- final DataSchemaNode restCont = childNodes.iterator().next();
-
- return findSchemaNode(restCont, schemaNodeName);
- }
-
- /**
- * Find specific {@link DataSchemaNode} child in {@link DataNodeContainer}
- * by {@link String} schema node name.
- *
- * @param restCont
- * - restconf container
- * @param schemaNodeName
- * - schema node name
- * @return {@link DataSchemaNode}
- */
- private static DataSchemaNode findSchemaNode(final DataSchemaNode restCont, final String schemaNodeName) {
- switch (schemaNodeName) {
- //MODULES
- case Draft15.RestconfModule.MODULE_LIST_SCHEMA_NODE:
- final DataSchemaNode moduleListSchNode = findSchemaNodeInCollection(
- ((DataNodeContainer) findSchemaNode(restCont,
- Draft15.RestconfModule.MODULES_CONTAINER_SCHEMA_NODE)).getChildNodes(),
- Draft15.RestconfModule.MODULE_LIST_SCHEMA_NODE);
- Preconditions.checkNotNull(moduleListSchNode);
- return moduleListSchNode;
- case Draft15.RestconfModule.MODULES_CONTAINER_SCHEMA_NODE:
- final DataSchemaNode modulesContSchNode = findSchemaNodeInCollection(((DataNodeContainer) restCont).getChildNodes(),
- Draft15.RestconfModule.MODULES_CONTAINER_SCHEMA_NODE);
- Preconditions.checkNotNull(modulesContSchNode);
- return modulesContSchNode;
-
- //STREAMS
- case Draft15.MonitoringModule.STREAM_LIST_SCHEMA_NODE:
- final DataSchemaNode streamListSchNode = findSchemaNodeInCollection(
- ((DataNodeContainer) findSchemaNode(restCont,
- Draft15.MonitoringModule.STREAMS_CONTAINER_SCHEMA_NODE)).getChildNodes(),
- Draft15.MonitoringModule.STREAM_LIST_SCHEMA_NODE);
- Preconditions.checkNotNull(streamListSchNode);
- return streamListSchNode;
- case Draft15.MonitoringModule.STREAMS_CONTAINER_SCHEMA_NODE:
- final DataSchemaNode streamsContSchNode = findSchemaNodeInCollection(
- ((DataNodeContainer) restCont).getChildNodes(),
- Draft15.MonitoringModule.STREAMS_CONTAINER_SCHEMA_NODE);
- Preconditions.checkNotNull(streamsContSchNode);
- return streamsContSchNode;
- default:
- throw new RestconfDocumentedException("Schema node " + schemaNodeName + " does not exist in module.",
- ErrorType.PROTOCOL, ErrorTag.DATA_MISSING);
- }
- }
-