- private void normalizeCompositeNode(final CompositeNodeWrapper compositeNodeBuilder,
- final DataNodeContainer schema, final DOMMountPoint mountPoint, final QName currentAugment) {
- final List<NodeWrapper<?>> children = compositeNodeBuilder.getValues();
- checkNodeMultiplicityAccordingToSchema(schema, children);
- for (final NodeWrapper<? extends Object> child : children) {
- final List<DataSchemaNode> potentialSchemaNodes = ControllerContext.findInstanceDataChildrenByName(
- schema, child.getLocalName());
-
- if (potentialSchemaNodes.size() > 1 && child.getNamespace() == null) {
- StringBuilder builder = new StringBuilder();
- for (final DataSchemaNode potentialSchemaNode : potentialSchemaNodes) {
- builder.append(" ").append(potentialSchemaNode.getQName().getNamespace().toString()).append("\n");
- }
-
- throw new RestconfDocumentedException("Node \"" + child.getLocalName()
- + "\" is added as augment from more than one module. "
- + "Therefore node must have namespace (XML format) or module name (JSON format)."
- + "\nThe node is added as augment from modules with namespaces:\n" + builder,
- ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
- }
-
- boolean rightNodeSchemaFound = false;
- for (final DataSchemaNode potentialSchemaNode : potentialSchemaNodes) {
- if (!rightNodeSchemaFound) {
- final QName potentialCurrentAugment = this.normalizeNodeName(child, potentialSchemaNode,
- currentAugment, mountPoint);
- if (child.getQname() != null) {
- this.normalizeNode(child, potentialSchemaNode, potentialCurrentAugment, mountPoint);
- rightNodeSchemaFound = true;
- }
- }
- }
-
- if (!rightNodeSchemaFound) {
- throw new RestconfDocumentedException("Schema node \"" + child.getLocalName()
- + "\" was not found in module.", ErrorType.APPLICATION, ErrorTag.UNKNOWN_ELEMENT);
- }
- }
-
- if ((schema instanceof ListSchemaNode)) {
- ListSchemaNode listSchemaNode = (ListSchemaNode) schema;
- final List<QName> listKeys = listSchemaNode.getKeyDefinition();
- for (final QName listKey : listKeys) {
- boolean foundKey = false;
- for (final NodeWrapper<? extends Object> child : children) {
- if (Objects.equal(child.unwrap().getNodeType().getLocalName(), listKey.getLocalName())) {
- foundKey = true;
- }
- }
-
- if (!foundKey) {
- throw new RestconfDocumentedException("Missing key in URI \"" + listKey.getLocalName()
- + "\" of list \"" + listSchemaNode.getQName().getLocalName() + "\"", ErrorType.PROTOCOL,
- ErrorTag.DATA_MISSING);
- }
+ 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()));