- final CompositeNode schemasNode =
- (CompositeNode) NetconfMessageTransformUtil.findNode(schemasNodeResult.getResult(), DATA_STATE_SCHEMAS_IDENTIFIER);
- return create(id, schemasNode);
+ final Optional<? extends NormalizedNode<?, ?>> schemasNode = findSchemasNode(schemasNodeResult.getResult());
+
+ if(schemasNode.isPresent()) {
+ Preconditions.checkState(schemasNode.get() instanceof ContainerNode,
+ "Expecting container containing schemas, but was %s", schemasNode.get());
+ return create(id, ((ContainerNode) schemasNode.get()));
+ } else {
+ LOG.warn("{}: Unable to detect available schemas, get to {} was empty", id, STATE_SCHEMAS_IDENTIFIER);
+ return EMPTY;
+ }
+ }
+
+ private static Optional<? extends NormalizedNode<?, ?>> findSchemasNode(final NormalizedNode<?, ?> result) {
+ if(result == null) {
+ return Optional.absent();
+ }
+ final Optional<DataContainerChild<?, ?>> dataNode = ((DataContainerNode<?>) result).getChild(toId(NETCONF_DATA_QNAME));
+ if(dataNode.isPresent() == false) {
+ return Optional.absent();
+ }
+
+ final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> nStateNode =
+ ((DataContainerNode<?>) dataNode.get()).getChild(toId(NetconfState.QNAME));
+ if(nStateNode.isPresent() == false) {
+ return Optional.absent();
+ }
+
+ return ((DataContainerNode<?>) nStateNode.get()).getChild(toId(Schemas.QNAME));