Add 'protocol-framework/' from commit '5d015c2c5f800d136406c15fcb64fd531d4ffc26'
[netconf.git] / restconf / sal-rest-connector / src / main / java / org / opendaylight / restconf / utils / schema / context / RestconfSchemaUtil.java
index 151811bb0b69789493b8e6d2bfe0cd52302b397c..e7d3d4190753a4862f369f00281bb8f40bc211d8 100644 (file)
@@ -7,17 +7,11 @@
  */
 package org.opendaylight.restconf.utils.schema.context;
 
-import com.google.common.base.Preconditions;
 import java.util.Collection;
-import java.util.Set;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
-import org.opendaylight.restconf.Draft15;
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 
 /**
@@ -30,83 +24,16 @@ public final class RestconfSchemaUtil {
         throw new UnsupportedOperationException("Util class");
     }
 
-    /**
-     * 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);
-        }
-    }
-
     /**
      * Find child of {@link SchemaNode} in {@link Collection} by {@link String}
      * schema node name.
      *
      * @param <T>
-     *            - child of SchemaNode
+     *             child of SchemaNode
      * @param collection
-     *            - child of node
+     *             child of node
      * @param schemaNodeName
-     *            - schema node name
+     *             schema node name
      * @return {@link SchemaNode}
      */
     public static <T extends SchemaNode> T findSchemaNodeInCollection(final Collection<T> collection,