X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=restconf%2Frestconf-nb-rfc8040%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fnb%2Frfc8040%2Frests%2Fservices%2Fimpl%2FRestconfInvokeOperationsServiceImpl.java;h=55c6be3d8dc0c735e6529f35228a87193caf7d79;hb=93ac0881e434d13f002d6915790902ef9a55665a;hp=34c76dc3ae63d4d2737923b75e323bcd8c5a353d;hpb=6b8e4f7ee09ed344969ddad8017a7f41ad89f2d0;p=netconf.git diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImpl.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImpl.java index 34c76dc3ae..55c6be3d8d 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImpl.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImpl.java @@ -8,9 +8,12 @@ package org.opendaylight.restconf.nb.rfc8040.rests.services.impl; import java.net.URI; +import javax.ws.rs.Path; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; +import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; @@ -23,6 +26,7 @@ import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfInvokeOpe import org.opendaylight.restconf.nb.rfc8040.rests.utils.CreateStreamUtil; import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfInvokeOperationsUtil; import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaPath; @@ -31,10 +35,11 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; * Implementation of {@link RestconfInvokeOperationsService}. * */ +@Path("/") public class RestconfInvokeOperationsServiceImpl implements RestconfInvokeOperationsService { - private RpcServiceHandler rpcServiceHandler; - private SchemaContextHandler schemaContextHandler; + private volatile RpcServiceHandler rpcServiceHandler; + private volatile SchemaContextHandler schemaContextHandler; public RestconfInvokeOperationsServiceImpl(final RpcServiceHandler rpcServiceHandler, final SchemaContextHandler schemaContextHandler) { @@ -85,11 +90,17 @@ public class RestconfInvokeOperationsServiceImpl implements RestconfInvokeOperat final DOMRpcResult result = RestconfInvokeOperationsUtil.checkResponse(response); RpcDefinition resultNodeSchema = null; - final NormalizedNode resultData = result.getResult(); - if ((result != null) && (result.getResult() != null)) { + NormalizedNode resultData = null; + if (result != null && result.getResult() != null) { + resultData = result.getResult(); resultNodeSchema = (RpcDefinition) payload.getInstanceIdentifierContext().getSchemaNode(); } - return new NormalizedNodeContext(new InstanceIdentifierContext(null, resultNodeSchema, - mountPoint, schemaContextRef.get()), resultData); + + if (resultData != null && ((ContainerNode) resultData).getValue().isEmpty()) { + throw new WebApplicationException(Response.Status.NO_CONTENT); + } else { + return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, resultNodeSchema, + mountPoint, schemaContextRef.get()), resultData); + } } }