X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frest%2Fimpl%2FJsonNormalizedNodeBodyReader.java;h=5f7bd02ecf1bc46e4d0b84f8973d665139978dd0;hb=302ed51819ef1fd233a9b26073eae71e44a9338a;hp=9594c34b6ef49140fd03e473ac8efbab7efab676;hpb=4fc158fdb5e38ad492c1bccc6b1e70f0c0255560;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java index 9594c34b6e..5f7bd02ecf 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java @@ -35,6 +35,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeS import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; +import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,6 +60,9 @@ public class JsonNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPr WebApplicationException { try { final InstanceIdentifierContext path = getIdentifierWithSchema().get(); + if (entityStream.available() < 1) { + return new NormalizedNodeContext(path, null); + } final NormalizedNodeResult resultHolder = new NormalizedNodeResult(); final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder); @@ -66,10 +70,14 @@ public class JsonNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPr if(isPost()) { // FIXME: We need dispatch for RPC. parentSchema = path.getSchemaNode(); - } else if(path.getSchemaContext() instanceof SchemaContext) { + } else if(path.getSchemaNode() instanceof SchemaContext) { parentSchema = path.getSchemaContext(); } else { - parentSchema = SchemaContextUtil.findDataSchemaNode(path.getSchemaContext(), path.getSchemaNode().getPath().getParent()); + if (SchemaPath.ROOT.equals(path.getSchemaNode().getPath().getParent())) { + parentSchema = path.getSchemaContext(); + } else { + parentSchema = SchemaContextUtil.findDataSchemaNode(path.getSchemaContext(), path.getSchemaNode().getPath().getParent()); + } } final JsonParserStream jsonParser = JsonParserStream.create(writer, path.getSchemaContext(), parentSchema);