import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
try {
final Optional<InstanceIdentifierContext> path = getIdentifierWithSchema();
+ if (entityStream.available() < 1) {
+ // represent empty nopayload input
+ return new NormalizedNodeContext(path.get(), null);
+ }
+
final DocumentBuilder dBuilder;
try {
dBuilder = BUILDERFACTORY.newDocumentBuilder();
final NormalizedNode<?, ?> result = parse(path.get(),doc);
return new NormalizedNodeContext(path.get(),result);
} catch (final Exception e) {
- LOG.debug("Error parsing json input", e);
+ LOG.debug("Error parsing xml input", e);
throw new RestconfDocumentedException("Error parsing input: " + e.getMessage(), ErrorType.PROTOCOL,
ErrorTag.MALFORMED_MESSAGE);
}
}
- private static NormalizedNode<?,?> parse(final InstanceIdentifierContext pathContext,final Document doc) {
+ private static NormalizedNode<?,?> parse(final InstanceIdentifierContext<?> pathContext,final Document doc) {
final List<Element> elements = Collections.singletonList(doc.getDocumentElement());
- DataSchemaNode schemaNode = pathContext.getSchemaNode();
+ final SchemaNode schemaNodeContext = pathContext.getSchemaNode();
+ DataSchemaNode schemaNode = null;
+ if (schemaNodeContext instanceof RpcDefinition) {
+ schemaNode = ((RpcDefinition) schemaNodeContext).getInput();
+ } else if (schemaNodeContext instanceof DataSchemaNode) {
+ schemaNode = (DataSchemaNode) schemaNodeContext;
+ } else {
+ throw new IllegalStateException("Unknow SchemaNode");
+ }
final String docRootElm = doc.getDocumentElement().getLocalName();
final String schemaNodeName = pathContext.getSchemaNode().getQName().getLocalName();
- // TODO : do we want to really follow netconf-restconf specification ?
if (!schemaNodeName.equalsIgnoreCase(docRootElm)) {
final Collection<DataSchemaNode> children = ((DataNodeContainer) schemaNode).getChildNodes();
for (final DataSchemaNode child : children) {
} else if(schemaNode instanceof ListSchemaNode) {
final ListSchemaNode casted = (ListSchemaNode) schemaNode;
return parserFactory.getMapEntryNodeParser().parse(elements, casted);
- }
+ } // FIXME : add another DataSchemaNode extensions e.g. LeafSchemaNode
return null;
}
}