X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2FBrokerFacade.java;h=7cd20ee733dac07483bb378429ff6a6a6f64cc75;hb=0766a1f4d4c78ef0a6e9f8e3cd4cd9131cfa02f4;hp=e8701f37e5846e72e9c177ca2188969c7fb9a9da;hpb=c422305ed3346b6eb50af5fa1bf5377ad3572750;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java index e8701f37e5..7cd20ee733 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.java @@ -21,6 +21,7 @@ import java.util.concurrent.Future; import javax.ws.rs.core.Response.Status; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation; @@ -204,6 +205,7 @@ public class BrokerFacade { if (optionalDatastoreData.isPresent() && payload.equals(optionalDatastoreData.get())) { 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); } @@ -229,7 +231,7 @@ public class BrokerFacade { private CheckedFuture deleteDataViaTransaction( final DOMDataWriteTransaction writeTransaction, final LogicalDatastoreType datastore, YangInstanceIdentifier path) { - LOG.info("Delete " + datastore.name() + " via Restconf: {}", path); + LOG.trace("Delete " + datastore.name() + " via Restconf: {}", path); writeTransaction.delete(datastore, path); return writeTransaction.submit(); } @@ -249,21 +251,26 @@ public class BrokerFacade { try { currentOp = currentOp.getChild(currentArg); } catch (DataNormalizationException e) { + rwTx.cancel(); throw new IllegalArgumentException( String.format("Invalid child encountered in path %s", normalizedPath), e); } currentArguments.add(currentArg); YangInstanceIdentifier currentPath = YangInstanceIdentifier.create(currentArguments); - final Optional> datastoreData; + final Boolean exists; + try { - datastoreData = rwTx.read(store, currentPath).get(); - } catch (InterruptedException | ExecutionException e) { + + CheckedFuture future = rwTx.exists(store, currentPath); + exists = future.checkedGet(); + } catch (ReadFailedException e) { LOG.error("Failed to read pre-existing data from store {} path {}", store, currentPath, e); + rwTx.cancel(); throw new IllegalStateException("Failed to read pre-existing data", e); } - if (!datastoreData.isPresent() && iterator.hasNext()) { + if (!exists && iterator.hasNext()) { rwTx.merge(store, currentPath, currentOp.createDefault(currentArg)); } }