use of org.opendaylight.netconf.sal.rest.impl.JsonToPatchBodyReader in project netconf by opendaylight.
the class JSONRestconfServiceImpl method patch.
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public Optional<String> patch(final String uriPath, final String payload) throws OperationFailedException {
String output = null;
requireNonNull(payload, "payload can't be null");
LOG.debug("patch: uriPath: {}, payload: {}", uriPath, payload);
final InputStream entityStream = new ByteArrayInputStream(payload.getBytes(StandardCharsets.UTF_8));
JsonToPatchBodyReader jsonToPatchBodyReader = new JsonToPatchBodyReader(controllerContext);
final PatchContext context = jsonToPatchBodyReader.readFrom(uriPath, entityStream);
LOG.debug("Parsed YangInstanceIdentifier: {}", context.getInstanceIdentifierContext().getInstanceIdentifier());
LOG.debug("Parsed NormalizedNode: {}", context.getData());
try {
PatchStatusContext patchStatusContext = restconfService.patchConfigurationData(context, new SimpleUriInfo(uriPath));
output = toJson(patchStatusContext);
} catch (final Exception e) {
propagateExceptionAs(uriPath, e, "PATCH");
}
return Optional.ofNullable(output);
}
Aggregations