use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class TestJsonBodyReaderMountPoint method moduleSubContainerDataPutTest.
@Test
public void moduleSubContainerDataPutTest() throws Exception {
final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1";
mockBodyReader(uri, this.jsonBodyReader, false);
final InputStream inputStream = TestJsonBodyReaderMountPoint.class.getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
checkMountPointNormalizedNodeContext(returnValue);
checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, QName.create(dataSchemaNode.getQName(), "cont1"));
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class JSONRestconfServiceImpl method post.
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void post(final String uriPath, final String payload) throws OperationFailedException {
requireNonNull(payload, "payload can't be null");
LOG.debug("post: uriPath: {}, payload: {}", uriPath, payload);
final InputStream entityStream = new ByteArrayInputStream(payload.getBytes(StandardCharsets.UTF_8));
final NormalizedNodeContext context = JsonNormalizedNodeBodyReader.readFrom(uriPath, entityStream, true, controllerContext);
LOG.debug("Parsed YangInstanceIdentifier: {}", context.getInstanceIdentifierContext().getInstanceIdentifier());
LOG.debug("Parsed NormalizedNode: {}", context.getData());
try {
restconfService.createConfigurationData(uriPath, context, new SimpleUriInfo(uriPath));
} catch (final Exception e) {
propagateExceptionAs(uriPath, e, "POST");
}
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class JSONRestconfServiceImpl method subscribeToStream.
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public Optional<String> subscribeToStream(final String identifier, final MultivaluedMap<String, String> params) throws OperationFailedException {
// Note: We use http://127.0.0.1 because the Uri parser requires something there though it does nothing
String uri = new StringBuilder("http://127.0.0.1:8081/restconf/streams/stream/").append(identifier).toString();
MultivaluedMap queryParams = params != null ? params : new MultivaluedHashMap<String, String>();
UriInfo uriInfo = new SimpleUriInfo(uri, queryParams);
String jsonRes = null;
try {
NormalizedNodeContext res = restconfService.subscribeToStream(identifier, uriInfo);
jsonRes = toJson(res);
} catch (final Exception e) {
propagateExceptionAs(identifier, e, "RPC");
}
return Optional.ofNullable(jsonRes);
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class JsonToNnTest method simpleTest.
private void simpleTest(final String jsonPath, final String topLevelElementName, final String moduleName) throws Exception {
final String uri = moduleName + ":" + topLevelElementName;
final NormalizedNodeContext normalizedNodeContext = prepareNNC(jsonPath, uri);
assertNotNull(normalizedNodeContext);
verifyNormaluizedNodeContext(normalizedNodeContext, topLevelElementName);
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class JsonToNnTest method testJsonBlankInput.
@Test
public void testJsonBlankInput() throws Exception {
final NormalizedNodeContext normalizedNodeContext = prepareNNC("", "array-with-null-yang:cont");
assertNull(normalizedNodeContext);
}
Aggregations