- /**
- * Creates artificial schema node for get rpc. This artificial schema looks like:
- * <pre>
- * {@code
- * rpc
- * get-config
- * filter
- * // All schema nodes from remote schema
- * filter
- * get-config
- * rpc
- * }
- * </pre>
- *
- * This makes the translation of rpc get-config request(especially the config node)
- * to xml use schema which is crucial for some types of nodes e.g. identity-ref.
- */
- public static DataNodeContainer createSchemaForGetConfig(final SchemaContext schemaContext) {
- final QName filter = QName.create(NETCONF_GET_CONFIG_QNAME, "filter");
- final QName getConfig = QName.create(NETCONF_GET_CONFIG_QNAME, "get-config");
- final NodeContainerProxy configProxy = new NodeContainerProxy(filter, schemaContext.getChildNodes());
- final NodeContainerProxy editConfigProxy = new NodeContainerProxy(getConfig, Sets.<DataSchemaNode>newHashSet(configProxy));
- return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(editConfigProxy));
- }
-
- /**
- * Creates artificial schema node for schema defined rpc. This artificial schema looks like:
- * <pre>
- * {@code
- * rpc
- * rpc-name
- * // All schema nodes from remote schema
- * rpc-name
- * rpc
- * }
- * </pre>
- *
- * This makes the translation of schema defined rpc request
- * to xml use schema which is crucial for some types of nodes e.g. identity-ref.
- */
- public static DataNodeContainer createSchemaForRpc(final QName rpcName, final SchemaContext schemaContext) {
- Preconditions.checkNotNull(rpcName);
- Preconditions.checkNotNull(schemaContext);
-
- final NodeContainerProxy rpcBodyProxy = new NodeContainerProxy(rpcName, schemaContext.getChildNodes());
- return new NodeContainerProxy(NETCONF_RPC_QNAME, Sets.<DataSchemaNode>newHashSet(rpcBodyProxy));
-
- }
-
- public static CompositeNodeTOImpl wrap(final QName name, final Node<?> node) {
- if (node != null) {
- return new CompositeNodeTOImpl(name, null, Collections.<Node<?>> singletonList(node));
+ if (dataPath.isEmpty()) {
+ Preconditions.checkArgument(lastChildOverride.isPresent(), "Data has to be present when creating structure for top level element");
+ Preconditions.checkArgument(lastChildOverride.get() instanceof DataContainerChild<?, ?>,
+ "Data has to be either container or a list node when creating structure for top level element, but was: %s", lastChildOverride.get());
+ configContent = lastChildOverride.get();