+ nodes = DataNormalizer.toLegacy(dataNode);
+ if (nodes != null) {
+ if (nodes instanceof CompositeNode) {
+ return (CompositeNode) nodes;
+ } else {
+ LOG.error("The node " + dataNode.getNodeType() + " couldn't be transformed to compositenode.");
+ }
+ } else {
+ LOG.error("Top level node isn't of type Container or List schema node but "
+ + schema.getClass().getSimpleName());
+ }
+
+ throw new RestconfDocumentedException(new RestconfError(ErrorType.APPLICATION, ErrorTag.INVALID_VALUE,
+ "It wasn't possible to correctly interpret data."));
+ }
+
+ private NormalizedNode<?, ?> compositeNodeToDatastoreNormalizedNode(final CompositeNode compNode,
+ final DataSchemaNode schema) {
+ List<Node<?>> lst = new ArrayList<Node<?>>();
+ lst.add(compNode);
+ if (schema instanceof ContainerSchemaNode) {
+ return CnSnToNormalizedNodeParserFactory.getInstance().getContainerNodeParser()
+ .parse(lst, (ContainerSchemaNode) schema);
+ } else if (schema instanceof ListSchemaNode) {
+ return CnSnToNormalizedNodeParserFactory.getInstance().getMapEntryNodeParser()
+ .parse(lst, (ListSchemaNode) schema);
+ }
+
+ LOG.error("Top level isn't of type container, list, leaf schema node but " + schema.getClass().getSimpleName());
+
+ throw new RestconfDocumentedException(new RestconfError(ErrorType.APPLICATION, ErrorTag.INVALID_VALUE,
+ "It wasn't possible to translate specified data to datastore readable form."));
+ }
+
+ private InstanceIdentifierContext normalizeInstanceIdentifierWithSchemaNode(
+ final InstanceIdentifierContext iiWithSchemaNode) {
+ return normalizeInstanceIdentifierWithSchemaNode(iiWithSchemaNode, false);
+ }
+
+ private InstanceIdentifierContext normalizeInstanceIdentifierWithSchemaNode(
+ final InstanceIdentifierContext iiWithSchemaNode, final boolean unwrapLastListNode) {
+ return new InstanceIdentifierContext(instanceIdentifierToReadableFormForNormalizeNode(
+ iiWithSchemaNode.getInstanceIdentifier(), unwrapLastListNode), iiWithSchemaNode.getSchemaNode(),
+ iiWithSchemaNode.getMountPoint(),iiWithSchemaNode.getSchemaContext());
+ }
+
+ private YangInstanceIdentifier instanceIdentifierToReadableFormForNormalizeNode(
+ final YangInstanceIdentifier instIdentifier, final boolean unwrapLastListNode) {
+ Preconditions.checkNotNull(instIdentifier, "Instance identifier can't be null");
+ final List<PathArgument> result = new ArrayList<PathArgument>();
+ final Iterator<PathArgument> iter = instIdentifier.getPathArguments().iterator();
+ while (iter.hasNext()) {
+ final PathArgument pathArgument = iter.next();
+ if (pathArgument instanceof NodeIdentifierWithPredicates && (iter.hasNext() || unwrapLastListNode)) {
+ result.add(new YangInstanceIdentifier.NodeIdentifier(pathArgument.getNodeType()));
+ }
+ result.add(pathArgument);