import java.io.InputStreamReader;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag;
import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorType;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
final JsonReader reader = new JsonReader(new InputStreamReader(entityStream));
jsonParser.parse(reader);
- NormalizedNode<?, ?> partialResult = resultHolder.getResult();
- final NormalizedNode<?, ?> result;
+ NormalizedNode<?, ?> result = resultHolder.getResult();
+ List<YangInstanceIdentifier.PathArgument> iiToDataList = new ArrayList<>();
+ InstanceIdentifierContext<SchemaNode> newIIContext;
- // FIXME: Also II should be updated unwrap result from augmentation and choice nodes on PUT
- if (!isPost()) {
- while (partialResult instanceof AugmentationNode || partialResult instanceof ChoiceNode) {
- final Object childNode = ((DataContainerNode) partialResult).getValue().iterator().next();
- partialResult = (NormalizedNode<?, ?>) childNode;
+ if (isPost()) {
+ while (result instanceof AugmentationNode || result instanceof ChoiceNode) {
+ final Object childNode = ((DataContainerNode) result).getValue().iterator().next();
+ iiToDataList.add(result.getIdentifier());
+ result = (NormalizedNode<?, ?>) childNode;
+ }
+ if (result instanceof MapEntryNode) {
+ iiToDataList.add(new YangInstanceIdentifier.NodeIdentifier(result.getNodeType()));
+ iiToDataList.add(result.getIdentifier());
+ } else {
+ iiToDataList.add(result.getIdentifier());
}
- }
-
- if (partialResult instanceof MapNode && !isPost()) {
- result = Iterables.getOnlyElement(((MapNode) partialResult).getValue());
} else {
- result = partialResult;
+ if (result instanceof MapNode) {
+ result = Iterables.getOnlyElement(((MapNode) result).getValue());
+ }
}
- return new NormalizedNodeContext(path,result);
+
+ YangInstanceIdentifier fullIIToData = YangInstanceIdentifier.create(Iterables.concat(
+ path.getInstanceIdentifier().getPathArguments(), iiToDataList));
+
+ newIIContext = new InstanceIdentifierContext<>(fullIIToData, path.getSchemaNode(), path.getMountPoint(),
+ path.getSchemaContext());
+
+ return new NormalizedNodeContext(newIIContext, result);
} catch (final RestconfDocumentedException e) {
throw e;
} catch (final ResultAlreadySetException e) {