- String value = (String) node.getValue();
- // TODO check Leafref, InstanceIdentifierTypeDefinition,
- // IdentityrefTypeDefinition, UnionTypeDefinition
- TypeDefinition<?> baseType = resolveBaseTypeFrom(type);
- if (baseType instanceof InstanceIdentifierTypeDefinition) {
- writer.value(((InstanceIdentifierTypeDefinition) baseType).getPathStatement().toString());
- } else if (baseType instanceof UnionTypeDefinition) {
- processTypeIsUnionType(writer, (UnionTypeDefinition) baseType, value);
+ // TODO check InstanceIdentifierTypeDefinition
+ if (baseType instanceof IdentityrefTypeDefinition) {
+ if (node.getValue() instanceof QName) {
+ IdentityValuesDTO valueDTO = (IdentityValuesDTO) RestCodec.from(baseType, mountPoint).serialize(
+ node.getValue());
+ IdentityValue valueFromDTO = valueDTO.getValuesWithNamespaces().get(0);
+ String moduleName;
+ if (mountPoint != null) {
+ moduleName = ControllerContext.getInstance().findModuleNameByNamespace(mountPoint,
+ URI.create(valueFromDTO.getNamespace()));
+ } else {
+ moduleName = ControllerContext.getInstance().findModuleNameByNamespace(
+ URI.create(valueFromDTO.getNamespace()));
+ }
+ writer.value(moduleName + ":" + valueFromDTO.getValue());
+ } else {
+ writeStringRepresentation(writer, node, baseType, QName.class);
+ }
+ } else if (baseType instanceof InstanceIdentifierTypeDefinition) {
+ if (node.getValue() instanceof InstanceIdentifier) {
+ IdentityValuesDTO valueDTO = (IdentityValuesDTO) RestCodec.from(baseType, mountPoint).serialize(
+ node.getValue());
+ writeIdentityValuesDTOToJson(writer, valueDTO);
+ } else {
+ writeStringRepresentation(writer, node, baseType, InstanceIdentifier.class);
+ }