- 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 );
- }
+ private void normalizeEmptyNode(final EmptyNodeWrapper emptyNodeBuilder, final DataSchemaNode schema) {
+ if ((schema instanceof LeafSchemaNode)) {
+ emptyNodeBuilder.setComposite(false);
+ } else {
+ if ((schema instanceof ContainerSchemaNode)) {
+ // FIXME: Add presence check
+ emptyNodeBuilder.setComposite(true);
+ }
+ }
+ }
+
+ private void normalizeSimpleNode(final SimpleNodeWrapper simpleNode, final DataSchemaNode schema,
+ final DOMMountPoint mountPoint) {
+ final Object value = simpleNode.getValue();
+ Object inputValue = value;
+ final TypeDef typeDef = this.typeDefinition(schema);
+ TypeDefinition<? extends Object> typeDefinition = typeDef != null ? typeDef.typedef : null;
+
+ // For leafrefs, extract the type it is pointing to
+ if(typeDefinition instanceof LeafrefTypeDefinition) {
+ if (schema.getQName().equals(typeDef.qName)) {
+ typeDefinition = SchemaContextUtil.getBaseTypeForLeafRef(((LeafrefTypeDefinition) typeDefinition), mountPoint == null ? controllerContext.getGlobalSchema() : mountPoint.getSchemaContext(), schema);
+ } else {
+ typeDefinition = SchemaContextUtil.getBaseTypeForLeafRef(((LeafrefTypeDefinition) typeDefinition), mountPoint == null ? controllerContext.getGlobalSchema() : mountPoint.getSchemaContext(), typeDef.qName);
+ }
+ }
+
+ if (typeDefinition instanceof IdentityrefTypeDefinition) {
+ inputValue = parseToIdentityValuesDTO(simpleNode, value, inputValue);
+ }
+
+ Object outputValue = inputValue;
+
+ if (typeDefinition != null) {
+ final Codec<Object, Object> codec = RestCodec.from(typeDefinition, mountPoint);
+ outputValue = codec == null ? null : codec.deserialize(inputValue);
+ }
+
+ simpleNode.setValue(outputValue);
+ }
+
+ private Object parseToIdentityValuesDTO(final SimpleNodeWrapper simpleNode, final Object value, Object inputValue) {
+ if ((value instanceof String)) {
+ inputValue = new IdentityValuesDTO(simpleNode.getNamespace().toString(), (String) value, null,
+ (String) value);
+ } // else value is already instance of IdentityValuesDTO
+ return inputValue;
+ }