import java.net.URISyntaxException;
import java.util.ArrayDeque;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Deque;
import java.util.List;
import java.util.Optional;
import javax.xml.transform.dom.DOMSource;
import org.opendaylight.netconf.sal.rest.api.Draft02;
import org.opendaylight.netconf.sal.rest.api.RestconfService;
+import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
-import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
private static final Logger LOG = LoggerFactory.getLogger(XmlNormalizedNodeBodyReader.class);
+ public XmlNormalizedNodeBodyReader(final ControllerContext controllerContext) {
+ super(controllerContext);
+ }
+
@Override
public boolean isReadable(final Class<?> type, final Type genericType, final Annotation[] annotations,
final MediaType mediaType) {
@Override
public NormalizedNodeContext readFrom(final Class<NormalizedNodeContext> type, final Type genericType,
final Annotation[] annotations, final MediaType mediaType,
- final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws IOException,
- WebApplicationException {
+ final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws
+ WebApplicationException {
try {
return readFrom(entityStream);
} catch (final RestconfDocumentedException e) {
}
while (!foundSchemaNodes.isEmpty()) {
final Object child = foundSchemaNodes.pop();
- if (child instanceof AugmentationSchema) {
- final AugmentationSchema augmentSchemaNode = (AugmentationSchema) child;
- iiToDataList.add(SchemaUtils.getNodeIdentifierForAugmentation(augmentSchemaNode));
+ if (child instanceof AugmentationSchemaNode) {
+ final AugmentationSchemaNode augmentSchemaNode = (AugmentationSchemaNode) child;
+ iiToDataList.add(DataSchemaContextNode.augmentationIdentifierFrom(augmentSchemaNode));
} else if (child instanceof DataSchemaNode) {
schemaNode = (DataSchemaNode) child;
iiToDataList.add(new YangInstanceIdentifier.NodeIdentifier(schemaNode.getQName()));
final String namespace) {
final Deque<Object> result = new ArrayDeque<>();
final ArrayList<ChoiceSchemaNode> choiceSchemaNodes = new ArrayList<>();
- final Collection<DataSchemaNode> children = ((DataNodeContainer) schemaNode).getChildNodes();
- for (final DataSchemaNode child : children) {
+ for (final DataSchemaNode child : ((DataNodeContainer) schemaNode).getChildNodes()) {
if (child instanceof ChoiceSchemaNode) {
choiceSchemaNodes.add((ChoiceSchemaNode) child);
} else if (child.getQName().getLocalName().equalsIgnoreCase(elementName)
// find augmentation
if (child.isAugmenting()) {
- final AugmentationSchema augment = findCorrespondingAugment(schemaNode, child);
+ final AugmentationSchemaNode augment = findCorrespondingAugment(schemaNode, child);
if (augment != null) {
result.push(augment);
}
}
for (final ChoiceSchemaNode choiceNode : choiceSchemaNodes) {
- for (final ChoiceCaseNode caseNode : choiceNode.getCases()) {
+ for (final CaseSchemaNode caseNode : choiceNode.getCases()) {
final Deque<Object> resultFromRecursion = findPathToSchemaNodeByName(caseNode, elementName, namespace);
if (!resultFromRecursion.isEmpty()) {
resultFromRecursion.push(choiceNode);
if (choiceNode.isAugmenting()) {
- final AugmentationSchema augment = findCorrespondingAugment(schemaNode, choiceNode);
+ final AugmentationSchemaNode augment = findCorrespondingAugment(schemaNode, choiceNode);
if (augment != null) {
resultFromRecursion.push(augment);
}
return result;
}
- private static AugmentationSchema findCorrespondingAugment(final DataSchemaNode parent,
+ private static AugmentationSchemaNode findCorrespondingAugment(final DataSchemaNode parent,
final DataSchemaNode child) {
- if ((parent instanceof AugmentationTarget) && !(parent instanceof ChoiceSchemaNode)) {
- for (final AugmentationSchema augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) {
+ if (parent instanceof AugmentationTarget && !(parent instanceof ChoiceSchemaNode)) {
+ for (final AugmentationSchemaNode augmentation :
+ ((AugmentationTarget) parent).getAvailableAugmentations()) {
final DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName());
if (childInAugmentation != null) {
return augmentation;