-
- return ((CompositeNodeWrapper) node).unwrap();
- }
-
- return node;
- }
-
- private void normalizeNode(final NodeWrapper<? extends Object> nodeBuilder,
- final DataSchemaNode schema, final QName previousAugment,
- final MountInstance mountPoint) {
- if (schema == null) {
- throw new RestconfDocumentedException(
- "Data has bad format.\n\"" + nodeBuilder.getLocalName() +
- "\" does not exist in yang schema.",
- ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE );
- }
-
- QName currentAugment = null;
- if (nodeBuilder.getQname() != null) {
- currentAugment = previousAugment;
- }
- else {
- currentAugment = this.normalizeNodeName(nodeBuilder, schema, previousAugment, mountPoint);
- if (nodeBuilder.getQname() == null) {
- throw new RestconfDocumentedException(
- "Data has bad format.\nIf data is in XML format then namespace for \"" +
- nodeBuilder.getLocalName() +
- "\" should be \"" + schema.getQName().getNamespace() + "\".\n" +
- "If data is in JSON format then module name for \"" + nodeBuilder.getLocalName() +
- "\" should be corresponding to namespace \"" +
- schema.getQName().getNamespace() + "\".",
- ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE );
- }
- }
-
- if ( nodeBuilder instanceof CompositeNodeWrapper ) {
- if( schema instanceof DataNodeContainer ) {
- normalizeCompositeNode( (CompositeNodeWrapper)nodeBuilder, (DataNodeContainer)schema,
- mountPoint, currentAugment );
- }
- else if( schema instanceof AnyXmlSchemaNode ) {
- normalizeAnyXmlNode( (CompositeNodeWrapper)nodeBuilder, (AnyXmlSchemaNode)schema );
- }
- }
- else if ( nodeBuilder instanceof SimpleNodeWrapper ) {
- normalizeSimpleNode( (SimpleNodeWrapper) nodeBuilder, schema, mountPoint );
- }
- else if ((nodeBuilder instanceof EmptyNodeWrapper)) {
- normalizeEmptyNode( (EmptyNodeWrapper) nodeBuilder, schema );
- }
- }
-
- private void normalizeAnyXmlNode( final CompositeNodeWrapper compositeNode, final AnyXmlSchemaNode schema ) {
- List<NodeWrapper<?>> children = compositeNode.getValues();
- for( NodeWrapper<? extends Object> child : children ) {
- child.setNamespace( schema.getQName().getNamespace() );
- if( child instanceof CompositeNodeWrapper ) {
- normalizeAnyXmlNode( (CompositeNodeWrapper)child, schema );
- }