@Override public void close() { ro.close(); }
@Override public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) { return delegateReadTx.read(store, path); }
@Override public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) { return delegateReadTx.exists(store, path); }
@Override public Object getIdentifier() { return delegate().getIdentifier(); }
@Override public Object getIdentifier() { return delegate().getIdentifier(); }
@Override public void close() { delegate().close(); } }
@Override public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) { return delegate().read(store, path); }
@Override public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) { return delegate().exists(store, path); }
@Override public Object getIdentifier() { if (AuthzServiceImpl.isAuthorized(ActionType.GetIdentifier)) { return ro.getIdentifier(); } return null; } }
@Override public void close() { delegate().close(); }
@Override public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) { return delegate().read(store, path); }
@Override public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) { return delegate().exists(store, path); }
@Override public Object getIdentifier() { return delegate().getIdentifier(); }
@Override public void close() { delegate().close(); } }
private <T extends DataObject> Optional<T> read(final InstanceIdentifier<T> currentId, final DOMDataReadOnlyTransaction tx) { final YangInstanceIdentifier path = serializer.toYangInstanceIdentifier(currentId); final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read = tx.read(LogicalDatastoreType.CONFIGURATION, path); try { // TODO HONEYCOMB-169 once the APIs are asynchronous use just Futures.transform final Optional<NormalizedNode<?, ?>> optional = read.checkedGet(); if (!optional.isPresent()) { return Optional.absent(); } final NormalizedNode<?, ?> data = optional.get(); final Map.Entry<InstanceIdentifier<?>, DataObject> entry = serializer.fromNormalizedNode(path, data); final Class<T> targetType = currentId.getTargetType(); checkState(targetType.isAssignableFrom(entry.getValue().getClass()), "Unexpected data object type, should be: %s, but was: %s", targetType, entry.getValue().getClass()); return Optional.of(targetType.cast(entry.getValue())); } catch (ReadFailedException e) { throw new IllegalStateException("Unable to perform read", e); } }
@Override public Future<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) { final CheckedFuture<Boolean, ReadFailedException> existsFuture = readTx.exists(store, path); final DefaultPromise<Boolean> promise = new DefaultPromise<>(); Futures.addCallback(existsFuture, new FutureCallback<Boolean>() { @Override public void onSuccess(Boolean result) { promise.success(result); } @Override public void onFailure(Throwable t) { promise.failure(t); } }); return promise.future(); }
@Override public Future<Optional<NormalizedNodeMessage>> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) { final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture = readTx.read(store, path); final DefaultPromise<Optional<NormalizedNodeMessage>> promise = new DefaultPromise<>(); Futures.addCallback(readFuture, new FutureCallback<Optional<NormalizedNode<?, ?>>>() { @Override public void onSuccess(Optional<NormalizedNode<?, ?>> result) { if (!result.isPresent()) { promise.success(Optional.<NormalizedNodeMessage>absent()); } else { promise.success(Optional.of(new NormalizedNodeMessage(path, result.get()))); } } @Override public void onFailure(Throwable t) { promise.failure(t); } }); return promise.future(); }
@Override public CheckedFuture<Boolean, ReadFailedException> exists( LogicalDatastoreType logicalDatastoreType, YangInstanceIdentifier yangInstanceIdentifier) { if (AuthzServiceImpl.isAuthorized(ActionType.Exists)) { return ro.exists(logicalDatastoreType, yangInstanceIdentifier); } ReadFailedException e = new ReadFailedException("Authorization Failed"); return Futures.immediateFailedCheckedFuture(e); }
@Override public boolean cancel() { delegateReadTx.close(); return delegateWriteTx.cancel(); }