- /**
- * Helper class for result of transaction commit callback.
- * @param <T> Type of result
- */
- private final class ReadDataResult<T> {
- T result = null;
-
- T getResult() {
- return this.result;
- }
-
- void setResult(final T result) {
- this.result = result;
- }
- }
-
- /**
- * Set result from transaction commit callback.
- * @param t Throwable if transaction commit failed
- * @param datastore Datastore from which data are read
- * @param path Path from which data are read
- * @param result Result of read from {@code datastore}
- * @param readData Result value which will be set
- * @param <X> Result type
- */
- protected final static <X> void handlingCallback(final Throwable t, final LogicalDatastoreType datastore,
- final YangInstanceIdentifier path, final Optional<X> result,
- final ReadDataResult<X> readData) {
- if (t != null) {
- LOG.warn("Exception by reading {} via Restconf: {}", datastore.name(), path, t);
- throw new RestconfDocumentedException("Problem to get data from transaction.", t);
- } else {
- LOG.debug("Reading result data from transaction.");
- if (result != null) {
- if (result.isPresent()) {
- readData.setResult(result.get());
- }
- }
- }
- }
-