@Override public QName apply(final SchemaNode notification) { return QNAME_FUNCTION.apply(notification).withoutRevision(); } };
private void putNoRev(final QName qname, final StatementSupport<?, ?, ?> support) { final QName norev = qname.withoutRevision(); noRevQNameToSupport.put(norev != qname ? norev.intern() : qname, support); }
private static QName cachedQName(final String namespace, final String moduleName) { return QName.cachedReference(QName.create(URI.create(namespace), null, moduleName).withoutRevision()); }
/** * Parse response of get(netconf-state/schemas) to find all schemas under netconf-state/schemas */ @VisibleForTesting protected static NetconfStateSchemas create(final RemoteDeviceId id, final ContainerNode schemasNode) { final Set<RemoteYangSchema> availableYangSchemas = Sets.newHashSet(); final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> child = schemasNode.getChild(toId(Schema.QNAME)); Preconditions.checkState(child.isPresent(), "Unable to find list: %s in response: %s", Schema.QNAME.withoutRevision(), schemasNode); Preconditions.checkState(child.get() instanceof MapNode, "Unexpected structure for container: %s in response: %s. Expecting a list", Schema.QNAME.withoutRevision(), schemasNode); for (final MapEntryNode schemaNode : ((MapNode) child.get()).getValue()) { final Optional<RemoteYangSchema> fromCompositeNode = RemoteYangSchema.createFromNormalizedNode(id, schemaNode); if(fromCompositeNode.isPresent()) { availableYangSchemas.add(fromCompositeNode.get()); } } return new NetconfStateSchemas(availableYangSchemas); }
@Override public synchronized DOMNotification toNotification(final NetconfMessage message) { final Map.Entry<Date, XmlElement> stripped = stripNotification(message); final QName notificationNoRev; try { notificationNoRev = QName.create(stripped.getValue().getNamespace(), stripped.getValue().getName()).withoutRevision(); } catch (final MissingNameSpaceException e) { throw new IllegalArgumentException("Unable to parse notification " + message + ", cannot find namespace", e); } final Collection<NotificationDefinition> notificationDefinitions = mappedNotifications.get(notificationNoRev); Preconditions.checkArgument(notificationDefinitions.size() > 0, "Unable to parse notification %s, unknown notification. Available notifications: %s", notificationDefinitions, mappedNotifications.keySet()); // FIXME if multiple revisions for same notifications are present, we should pick the most recent. Or ? // We should probably just put the most recent notification versions into our map. We can expect that the device sends the data according to the latest available revision of a model. final NotificationDefinition next = notificationDefinitions.iterator().next(); // We wrap the notification as a container node in order to reuse the parsers and builders for container node final ContainerSchemaNode notificationAsContainerSchemaNode = NetconfMessageTransformUtil.createSchemaForNotification(next); final ContainerNode content = parserFactory.getContainerNodeParser().parse(Collections.singleton(stripped.getValue().getDomElement()), notificationAsContainerSchemaNode); return new NetconfDeviceNotification(content, stripped.getKey()); }
@Override public void onStatementDefinitionDeclared( final Mutable<QName, ExtensionStatement, EffectiveStatement<QName, ExtensionStatement>> stmt) { super.onStatementDefinitionDeclared(stmt); QName stmtName = stmt.coerceStatementArgument(); if (OpenConfigStatements.OPENCONFIG_VERSION.getStatementName().isEqualWithoutRevision(stmtName)) { stmtName = stmtName.withoutRevision(); } stmt.addContext(ExtensionNamespace.class, stmtName, stmt); final StmtContext<QName, ?, ?> argument = StmtContextUtils.findFirstDeclaredSubstatement(stmt, ArgumentStatement.class); final StmtContext<Boolean, ?, ?> yinElement = StmtContextUtils.findFirstDeclaredSubstatement(stmt, YinElementStatement.class); stmt.addToNs(StatementDefinitionNamespace.class, stmt.getStatementArgument(), new ModelDefinedStatementSupport(new ModelDefinedStatementDefinition(stmt.getStatementArgument(), argument != null ? argument.getStatementArgument() : null, yinElement != null ? yinElement.getStatementArgument() : false))); }