- BrokerFacade.LOG.trace( "Post Configuration via Restconf: {}", path );
- transaction.putConfigurationData( path, payload );
- return transaction.commit();
- }
-
- public Future<RpcResult<TransactionStatus>> commitConfigurationDataPostBehindMountPoint(
- final MountInstance mountPoint, final InstanceIdentifier path, final CompositeNode payload ) {
- this.checkPreconditions();
-
- final DataModificationTransaction transaction = mountPoint.beginTransaction();
- /* check for available Node in Configuration DataStore by path */
- CompositeNode availableNode = transaction.readConfigurationData( path );
- if (availableNode != null) {
- String errMsg = "Post Configuration via Restconf was not executed because data already exists";
- BrokerFacade.LOG.warn((new StringBuilder(errMsg)).append(" : ").append(path).toString());
- // FIXME: return correct ietf-restconf:errors -> follow specification
- // (http://tools.ietf.org/html/draft-bierman-netconf-restconf-03#page-48)
- throw new ResponseException(Status.CONFLICT, errMsg);
+
+ final ListenableFuture<Optional<NormalizedNode<?, ?>>> futureDatastoreData = rWTransaction.read(datastore, path);
+ try {
+ final Optional<NormalizedNode<?, ?>> optionalDatastoreData = futureDatastoreData.get();
+ if (optionalDatastoreData.isPresent() && payload.equals(optionalDatastoreData.get())) {
+ final String errMsg = "Post Configuration via Restconf was not executed because data already exists";
+ LOG.trace(errMsg + ":{}", path);
+ rWTransaction.cancel();
+ throw new RestconfDocumentedException("Data already exists for path: " + path, ErrorType.PROTOCOL,
+ ErrorTag.DATA_EXISTS);
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.trace("It wasn't possible to get data loaded from datastore at path " + path);