- SchemaNode current = Preconditions.checkNotNull(context);
- for (final QName qname : path.getPathFromRoot()) {
- SchemaNode child;
- if(current instanceof DataNodeContainer) {
- child = ((DataNodeContainer) current).getDataChildByName(qname);
-
- if (child == null && current instanceof SchemaContext) {
- child = tryFindGroupings((SchemaContext) current, qname).orNull();
- }
-
- if(child == null && current instanceof SchemaContext) {
- child = tryFindNotification((SchemaContext) current, qname)
- .orNull();
- }
- } else if (current instanceof ChoiceNode) {
- child = ((ChoiceNode) current).getCaseNodeByName(qname);
- } else {
- throw new IllegalArgumentException(String.format("Schema node %s does not allow children.", current));
- }
- current = child;
- }
- Preconditions.checkArgument(current instanceof DataNodeContainer,"Schema path must point to container or list. Supplied path %s pointed to: %s",path,current);
+ SchemaNode current = SchemaUtils.findParentSchemaOnPath(context, path);
+ Preconditions.checkArgument(current instanceof DataNodeContainer,"Schema path must point to container or list or an rpc input/output. Supplied path %s pointed to: %s",path,current);