if(schemasNode.isPresent()) {
Preconditions.checkState(schemasNode.get() instanceof ContainerNode,
"Expecting container containing schemas, but was %s", schemasNode.get());
- return create(id, ((ContainerNode) 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;
}
childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_NAMESPACE;
- final String namespaceAsString = getSingleChildNodeValue(schemaNode, childNode).get();
+ final Optional<String> namespaceValue = getSingleChildNodeValue(schemaNode, childNode);
+ if (!namespaceValue.isPresent()) {
+ LOG.warn("{}: Ignoring schema due to missing namespace", id);
+ return Optional.absent();
+ }
+ final String namespaceAsString = namespaceValue.get();
childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_VERSION;
// Revision does not have to be filled
private static Optional<String> getSingleChildNodeValue(final DataContainerNode<?> schemaNode, final QName childNode) {
final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> node = schemaNode.getChild(toId(childNode));
- Preconditions.checkArgument(node.isPresent(), "Child node %s not present", childNode);
- return getValueOfSimpleNode(node.get());
+ if (node.isPresent()) {
+ return getValueOfSimpleNode(node.get());
+ } else {
+ LOG.debug("Child node {} not present", childNode);
+ return Optional.absent();
+ }
}
private static Optional<String> getValueOfSimpleNode(final NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> node) {