Use ReadOperations.exists() to check existence 13/96113/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 11 May 2021 11:35:20 +0000 (13:35 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 11 May 2021 11:35:20 +0000 (13:35 +0200)
There is no point transferring all the data, just invoke the exists()
operation instead.

Change-Id: I54db6026ee641703196b6a8120245c4e60a60aa2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/EditConfig.java

index 4861c32001bc684f54b8acbddd64ba397b59aa8d..35e25bcdda9c3f51f06a202131296aa759ca21ce 100644 (file)
@@ -105,7 +105,7 @@ public final class EditConfig extends AbstractEdit {
                 break;
             case CREATE:
                 try {
-                    if (rwtx.read(LogicalDatastoreType.CONFIGURATION, path).get().isPresent()) {
+                    if (rwtx.exists(LogicalDatastoreType.CONFIGURATION, path).get()) {
                         throw new DocumentedException("Data already exists, cannot execute CREATE operation",
                             ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS, ErrorSeverity.ERROR);
                     }
@@ -121,7 +121,7 @@ public final class EditConfig extends AbstractEdit {
                 break;
             case DELETE:
                 try {
-                    if (!rwtx.read(LogicalDatastoreType.CONFIGURATION, path).get().isPresent()) {
+                    if (!rwtx.exists(LogicalDatastoreType.CONFIGURATION, path).get()) {
                         throw new DocumentedException("Data is missing, cannot execute DELETE operation",
                             ErrorType.PROTOCOL, ErrorTag.DATA_MISSING, ErrorSeverity.ERROR);
                     }