- if ((nodeBuilder instanceof CompositeNodeWrapper)) {
- final List<NodeWrapper<?>> children = ((CompositeNodeWrapper) nodeBuilder).getValues();
- for (final NodeWrapper<? extends Object> child : children) {
- final List<DataSchemaNode> potentialSchemaNodes =
- this.controllerContext.findInstanceDataChildrenByName(
- ((DataNodeContainer) schema), child.getLocalName());
+ 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( CompositeNodeWrapper compositeNode, 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 );
+ }
+ }
+ }
+
+ private void normalizeEmptyNode( EmptyNodeWrapper emptyNodeBuilder, DataSchemaNode schema ) {
+ if ((schema instanceof LeafSchemaNode)) {
+ emptyNodeBuilder.setComposite(false);
+ }
+ else {
+ if ((schema instanceof ContainerSchemaNode)) {
+ // FIXME: Add presence check
+ emptyNodeBuilder.setComposite(true);
+ }
+ }
+ }
+
+ private void normalizeSimpleNode( SimpleNodeWrapper simpleNode, DataSchemaNode schema,
+ MountInstance mountPoint ) {
+ final Object value = simpleNode.getValue();
+ Object inputValue = value;
+ TypeDefinition<? extends Object> typeDefinition = this.typeDefinition(schema);
+ if ((typeDefinition instanceof IdentityrefTypeDefinition)) {
+ if ((value instanceof String)) {
+ inputValue = new IdentityValuesDTO( simpleNode.getNamespace().toString(),
+ (String) value, null, (String) value );
+ } // else value is already instance of IdentityValuesDTO
+ }