RestconfTransaction always operates on a single datastore 59/96859/3
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 9 Jul 2021 15:53:48 +0000 (17:53 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 9 Jul 2021 16:18:48 +0000 (18:18 +0200)
Previous refactors in this area have suffered from lack of actual
clarity. All legitimate users of RestconfTransaction operate on
CONFIGURATION, hence use that without allowing a possiblity to
mix&match datastore access.

Change-Id: Ief9ff8d51e12c3cd3e04e55f9cd04b2b42f81068
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImpl.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/transactions/MdsalRestconfTransaction.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/transactions/NetconfRestconfTransaction.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/transactions/RestconfTransaction.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/DeleteDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PatchDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PlainPatchDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PostDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/TransactionUtil.java

index 3d71a525a0fb35c2f3117e9caf53a2c1eff43a1b..e4085e18c361acbf2650ee11bd99d8764e9dc9b2 100644 (file)
@@ -38,6 +38,8 @@ import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMActionResult;
 import org.opendaylight.mdsal.dom.api.DOMActionService;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteOperations;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
@@ -56,7 +58,6 @@ import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfDataServi
 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfStreamsSubscriptionService;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy;
-import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfTransaction;
 import org.opendaylight.restconf.nb.rfc8040.rests.utils.DeleteDataTransactionUtil;
 import org.opendaylight.restconf.nb.rfc8040.rests.utils.PatchDataTransactionUtil;
 import org.opendaylight.restconf.nb.rfc8040.rests.utils.PlainPatchDataTransactionUtil;
@@ -114,12 +115,14 @@ public class RestconfDataServiceImpl implements RestconfDataService {
     private final DOMMountPointService mountPointService;
     private final SubscribeToStreamUtil streamUtils;
     private final DOMActionService actionService;
+    private final DOMDataBroker dataBroker;
 
     public RestconfDataServiceImpl(final SchemaContextHandler schemaContextHandler,
             final DOMDataBroker dataBroker, final DOMMountPointService  mountPointService,
             final RestconfStreamsSubscriptionService delegRestconfSubscrService,
             final DOMActionService actionService, final Configuration configuration) {
         this.schemaContextHandler = requireNonNull(schemaContextHandler);
+        this.dataBroker = requireNonNull(dataBroker);
         this.restconfStrategy = new MdsalRestconfStrategy(dataBroker);
         this.mountPointService = requireNonNull(mountPointService);
         this.delegRestconfSubscrService = requireNonNull(delegRestconfSubscrService);
@@ -141,15 +144,23 @@ public class RestconfDataServiceImpl implements RestconfDataService {
         final WriterParameters parameters = ReadDataTransactionUtil.parseUriParameters(instanceIdentifier, uriInfo);
 
         final DOMMountPoint mountPoint = instanceIdentifier.getMountPoint();
+
+        // FIXME: this looks quite crazy, why do we even have it?
+        if (mountPoint == null && identifier != null && identifier.contains(STREAMS_PATH)
+            && !identifier.contains(STREAM_PATH_PART)) {
+            createAllYangNotificationStreams(schemaContextRef, uriInfo);
+        }
+
         final RestconfStrategy strategy = getRestconfStrategy(mountPoint);
         final NormalizedNode node;
         if (parameters.getFieldPaths() != null && !parameters.getFieldPaths().isEmpty()) {
             node = ReadDataTransactionUtil.readData(parameters.getContent(), instanceIdentifier.getInstanceIdentifier(),
                     strategy, parameters.getWithDefault(), schemaContextRef, parameters.getFieldPaths());
         } else {
-            node = readData(identifier, parameters.getContent(), instanceIdentifier.getInstanceIdentifier(), strategy,
-                    parameters.getWithDefault(), schemaContextRef, uriInfo);
+            node = ReadDataTransactionUtil.readData(parameters.getContent(), instanceIdentifier.getInstanceIdentifier(),
+                    strategy, parameters.getWithDefault(), schemaContextRef);
         }
+
         // FIXME: this is utter craziness, refactor it properly!
         if (identifier != null && identifier.contains(STREAM_PATH) && identifier.contains(STREAM_ACCESS_PATH_PART)
                 && identifier.contains(STREAM_LOCATION_PATH_PART)) {
@@ -178,40 +189,15 @@ public class RestconfDataServiceImpl implements RestconfDataService {
         return Response.status(200).entity(new NormalizedNodeContext(instanceIdentifier, node, parameters)).build();
     }
 
-    /**
-     * Read specific type of data from data store via transaction and if identifier read data from
-     * streams then put streams from actual schema context to datastore.
-     *
-     * @param identifier    identifier of data to read
-     * @param content       type of data to read (config, state, all)
-     * @param strategy      {@link RestconfStrategy} - object that perform the actual DS operations
-     * @param withDefa      value of with-defaults parameter
-     * @param schemaContext schema context
-     * @param uriInfo       uri info
-     * @return {@link NormalizedNode}
-     */
-    private NormalizedNode readData(final String identifier, final String content,
-            final YangInstanceIdentifier path, final RestconfStrategy strategy, final String withDefa,
-            final EffectiveModelContext schemaContext, final UriInfo uriInfo) {
-        if (identifier != null && identifier.contains(STREAMS_PATH) && !identifier.contains(STREAM_PATH_PART)) {
-            createAllYangNotificationStreams(strategy, schemaContext, uriInfo);
-        }
-        return ReadDataTransactionUtil.readData(content, path, strategy, withDefa, schemaContext);
-    }
-
-    private void createAllYangNotificationStreams(final RestconfStrategy strategy,
-            final EffectiveModelContext schemaContext, final UriInfo uriInfo) {
-        final RestconfTransaction transaction = strategy.prepareWriteExecution();
-
+    private void createAllYangNotificationStreams(final EffectiveModelContext schemaContext, final UriInfo uriInfo) {
+        final DOMDataTreeWriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         for (final NotificationDefinition notificationDefinition : schemaContext.getNotifications()) {
-            final NotificationListenerAdapter notifiStreamXML =
+            writeNotificationStreamToDatastore(schemaContext, uriInfo, transaction,
                 CreateStreamUtil.createYangNotifiStream(notificationDefinition, schemaContext,
-                    NotificationOutputType.XML);
-            final NotificationListenerAdapter notifiStreamJSON =
+                    NotificationOutputType.XML));
+            writeNotificationStreamToDatastore(schemaContext, uriInfo, transaction,
                 CreateStreamUtil.createYangNotifiStream(notificationDefinition, schemaContext,
-                    NotificationOutputType.JSON);
-            writeNotificationStreamToDatastore(schemaContext, uriInfo, transaction, notifiStreamXML);
-            writeNotificationStreamToDatastore(schemaContext, uriInfo, transaction, notifiStreamJSON);
+                    NotificationOutputType.JSON));
         }
         try {
             transaction.commit().get();
@@ -221,13 +207,13 @@ public class RestconfDataServiceImpl implements RestconfDataService {
     }
 
     private void writeNotificationStreamToDatastore(final EffectiveModelContext schemaContext,
-            final UriInfo uriInfo, final RestconfTransaction transaction, final NotificationListenerAdapter listener) {
+            final UriInfo uriInfo, final DOMDataTreeWriteOperations tx, final NotificationListenerAdapter listener) {
         final URI uri = streamUtils.prepareUriByStreamName(uriInfo, listener.getStreamName());
         final MapEntryNode mapToStreams = RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring(
                 listener.getSchemaPath().lastNodeIdentifier(), schemaContext.getNotifications(), null,
                 listener.getOutputType(), uri);
 
-        transaction.merge(LogicalDatastoreType.OPERATIONAL,
+        tx.merge(LogicalDatastoreType.OPERATIONAL,
             Rfc8040.restconfStateStreamPath(mapToStreams.getIdentifier()), mapToStreams);
     }
 
index e6b93d2bb5eb6f246c247e9d8de4dd28d466f3d0..0e7b2461f533fb698f00ff5c5ae11232de5a4e20 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.restconf.nb.rfc8040.rests.transactions;
 
 import static com.google.common.base.Verify.verifyNotNull;
+import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
 import static org.opendaylight.restconf.nb.rfc8040.rests.utils.DeleteDataTransactionUtil.DELETE_TX_TYPE;
 import static org.opendaylight.restconf.nb.rfc8040.rests.utils.PostDataTransactionUtil.checkItemDoesNotExists;
 
@@ -16,7 +17,6 @@ import java.util.Collection;
 import java.util.Map;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
@@ -48,65 +48,63 @@ final class MdsalRestconfTransaction extends RestconfTransaction {
     }
 
     @Override
-    public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
-        final FluentFuture<Boolean> isExists = verifyNotNull(rwTx).exists(store, path);
+    public void delete(final YangInstanceIdentifier path) {
+        final FluentFuture<Boolean> isExists = verifyNotNull(rwTx).exists(CONFIGURATION, path);
         DeleteDataTransactionUtil.checkItemExists(isExists, path, DELETE_TX_TYPE);
-        rwTx.delete(store, path);
+        rwTx.delete(CONFIGURATION, path);
     }
 
     @Override
-    public void remove(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
-        verifyNotNull(rwTx).delete(store, path);
+    public void remove(final YangInstanceIdentifier path) {
+        verifyNotNull(rwTx).delete(CONFIGURATION, path);
     }
 
     @Override
-    public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) {
-        verifyNotNull(rwTx).merge(store, path, data);
+    public void merge(final YangInstanceIdentifier path, final NormalizedNode data) {
+        verifyNotNull(rwTx).merge(CONFIGURATION, path, data);
     }
 
     @Override
-    public void create(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data,
+    public void create(final YangInstanceIdentifier path, final NormalizedNode data,
                        final SchemaContext schemaContext) {
         if (data instanceof MapNode || data instanceof LeafSetNode) {
             final NormalizedNode emptySubTree = ImmutableNodes.fromInstanceId(schemaContext, path);
-            merge(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.create(emptySubTree.getIdentifier()),
-                emptySubTree);
+            merge(YangInstanceIdentifier.create(emptySubTree.getIdentifier()), emptySubTree);
             TransactionUtil.ensureParentsByMerge(path, schemaContext, this);
 
             final Collection<? extends NormalizedNode> children = ((NormalizedNodeContainer<?>) data).body();
             final BatchedExistenceCheck check =
-                BatchedExistenceCheck.start(verifyNotNull(rwTx), LogicalDatastoreType.CONFIGURATION, path, children);
+                BatchedExistenceCheck.start(verifyNotNull(rwTx), CONFIGURATION, path, children);
 
             for (final NormalizedNode child : children) {
                 final YangInstanceIdentifier childPath = path.node(child.getIdentifier());
-                verifyNotNull(rwTx).put(store, childPath, child);
+                verifyNotNull(rwTx).put(CONFIGURATION, childPath, child);
             }
             // ... finally collect existence checks and abort the transaction if any of them failed.
             checkExistence(path, check);
         } else {
-            final FluentFuture<Boolean> isExists = verifyNotNull(rwTx).exists(store, path);
+            final FluentFuture<Boolean> isExists = verifyNotNull(rwTx).exists(CONFIGURATION, path);
             checkItemDoesNotExists(isExists, path);
             TransactionUtil.ensureParentsByMerge(path, schemaContext, this);
-            verifyNotNull(rwTx).put(store, path, data);
+            verifyNotNull(rwTx).put(CONFIGURATION, path, data);
         }
     }
 
     @Override
-    public void replace(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data,
+    public void replace(final YangInstanceIdentifier path, final NormalizedNode data,
                         final SchemaContext schemaContext) {
         if (data instanceof MapNode || data instanceof LeafSetNode) {
             final NormalizedNode emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path);
-            merge(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.create(emptySubtree.getIdentifier()),
-                emptySubtree);
+            merge(YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
             TransactionUtil.ensureParentsByMerge(path, schemaContext, this);
 
             for (final NormalizedNode child : ((NormalizedNodeContainer<?>) data).body()) {
                 final YangInstanceIdentifier childPath = path.node(child.getIdentifier());
-                verifyNotNull(rwTx).put(store, childPath, child);
+                verifyNotNull(rwTx).put(CONFIGURATION, childPath, child);
             }
         } else {
             TransactionUtil.ensureParentsByMerge(path, schemaContext, this);
-            verifyNotNull(rwTx).put(store, path, data);
+            verifyNotNull(rwTx).put(CONFIGURATION, path, data);
         }
     }
 
index f28f406199eec1a535fef04931270dfa48d89306..f5c48882d7072ce5856a4223491e09ca19f68d08 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.restconf.nb.rfc8040.rests.transactions;
 
 import static java.util.Objects.requireNonNull;
+import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.util.concurrent.FluentFuture;
@@ -27,7 +28,6 @@ import java.util.function.Supplier;
 import java.util.stream.Collectors;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
 import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
@@ -69,51 +69,49 @@ final class NetconfRestconfTransaction extends RestconfTransaction {
     }
 
     @Override
-    public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
-        enqueueOperation(() -> netconfService.delete(store, path));
+    public void delete(final YangInstanceIdentifier path) {
+        enqueueOperation(() -> netconfService.delete(CONFIGURATION, path));
     }
 
     @Override
-    public void remove(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
-        enqueueOperation(() -> netconfService.remove(store, path));
+    public void remove(final YangInstanceIdentifier path) {
+        enqueueOperation(() -> netconfService.remove(CONFIGURATION, path));
     }
 
     @Override
-    public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) {
-        enqueueOperation(() -> netconfService.merge(store, path, data, Optional.empty()));
+    public void merge(final YangInstanceIdentifier path, final NormalizedNode data) {
+        enqueueOperation(() -> netconfService.merge(CONFIGURATION, path, data, Optional.empty()));
     }
 
     @Override
-    public void create(final LogicalDatastoreType store, final YangInstanceIdentifier path,
-           final NormalizedNode data, final SchemaContext schemaContext) {
+    public void create(final YangInstanceIdentifier path, final NormalizedNode data,
+            final SchemaContext schemaContext) {
         if (data instanceof MapNode || data instanceof LeafSetNode) {
             final NormalizedNode emptySubTree = ImmutableNodes.fromInstanceId(schemaContext, path);
-            merge(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.create(emptySubTree.getIdentifier()),
-                emptySubTree);
+            merge(YangInstanceIdentifier.create(emptySubTree.getIdentifier()), emptySubTree);
 
             for (final NormalizedNode child : ((NormalizedNodeContainer<?>) data).body()) {
                 final YangInstanceIdentifier childPath = path.node(child.getIdentifier());
-                enqueueOperation(() -> netconfService.create(store, childPath, child, Optional.empty()));
+                enqueueOperation(() -> netconfService.create(CONFIGURATION, childPath, child, Optional.empty()));
             }
         } else {
-            enqueueOperation(() -> netconfService.create(store, path, data, Optional.empty()));
+            enqueueOperation(() -> netconfService.create(CONFIGURATION, path, data, Optional.empty()));
         }
     }
 
     @Override
-    public void replace(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data,
+    public void replace(final YangInstanceIdentifier path, final NormalizedNode data,
             final SchemaContext schemaContext) {
         if (data instanceof MapNode || data instanceof LeafSetNode) {
             final NormalizedNode emptySubTree = ImmutableNodes.fromInstanceId(schemaContext, path);
-            merge(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.create(emptySubTree.getIdentifier()),
-                emptySubTree);
+            merge(YangInstanceIdentifier.create(emptySubTree.getIdentifier()), emptySubTree);
 
             for (final NormalizedNode child : ((NormalizedNodeContainer<?>) data).body()) {
                 final YangInstanceIdentifier childPath = path.node(child.getIdentifier());
-                enqueueOperation(() -> netconfService.replace(store, childPath, child, Optional.empty()));
+                enqueueOperation(() -> netconfService.replace(CONFIGURATION, childPath, child, Optional.empty()));
             }
         } else {
-            enqueueOperation(() -> netconfService.replace(store, path, data, Optional.empty()));
+            enqueueOperation(() -> netconfService.replace(CONFIGURATION, path, data, Optional.empty()));
         }
     }
 
index 162e8be0467604ee6777625d44d6948a8ad3afc5..ef87b33e3cf597a120bbf0db1666ea068f2ee57d 100644 (file)
@@ -11,7 +11,6 @@ import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.FluentFuture;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -43,47 +42,40 @@ public abstract class RestconfTransaction {
     /**
      * Delete data from the datastore.
      *
-     * @param store the logical data store which should be modified
      * @param path the data object path
      */
-    public abstract void delete(LogicalDatastoreType store, YangInstanceIdentifier path);
+    public abstract void delete(YangInstanceIdentifier path);
 
     /**
      * Remove data from the datastore.
      *
-     * @param store the logical data store which should be modified
      * @param path  the data object path
      */
-    public abstract void remove(LogicalDatastoreType store, YangInstanceIdentifier path);
+    public abstract void remove(YangInstanceIdentifier path);
 
     /**
      * Merges a piece of data with the existing data at a specified path.
      *
-     * @param store the logical data store which should be modified
      * @param path the data object path
      * @param data the data object to be merged to the specified path
      */
-    public abstract void merge(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data);
+    public abstract void merge(YangInstanceIdentifier path, NormalizedNode data);
 
     /**
      * Stores a piece of data at the specified path.
      *
-     * @param store         the logical data store which should be modified
      * @param path          the data object path
      * @param data          the data object to be merged to the specified path
      * @param schemaContext static view of compiled yang files
      */
-    public abstract void create(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data,
-                                SchemaContext schemaContext);
+    public abstract void create(YangInstanceIdentifier path, NormalizedNode data, SchemaContext schemaContext);
 
     /**
      * Replace a piece of data at the specified path.
      *
-     * @param store         the logical data store which should be modified
      * @param path          the data object path
      * @param data          the data object to be merged to the specified path
      * @param schemaContext static view of compiled yang files
      */
-    public abstract void replace(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode data,
-                                 SchemaContext schemaContext);
+    public abstract void replace(YangInstanceIdentifier path, NormalizedNode data, SchemaContext schemaContext);
 }
index 955267935625cab3bf49c2b247fc5ed84a2bd66f..e26cba1f1107fdf59a6f686d2a4a96150780122d 100644 (file)
@@ -11,7 +11,6 @@ import com.google.common.util.concurrent.FluentFuture;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
@@ -41,7 +40,7 @@ public final class DeleteDataTransactionUtil {
     public static Response deleteData(final RestconfStrategy strategy, final YangInstanceIdentifier path) {
         final RestconfTransaction transaction = strategy.prepareWriteExecution();
         try {
-            transaction.delete(LogicalDatastoreType.CONFIGURATION, path);
+            transaction.delete(path);
         } catch (RestconfDocumentedException e) {
             // close transaction if any and pass exception further
             transaction.cancel();
index b9ca9798243a16a05ab2b7d3518b1a7423966cf7..620b1007782a48019ac30d9f9fc331062712bd07 100644 (file)
@@ -157,7 +157,7 @@ public final class PatchDataTransactionUtil {
                                                     final RestconfTransaction transaction) {
         LOG.trace("POST {} within Restconf Patch: {} with payload {}", LogicalDatastoreType.CONFIGURATION.name(),
             path, payload);
-        transaction.create(LogicalDatastoreType.CONFIGURATION, path, payload, schemaContext);
+        transaction.create(path, payload, schemaContext);
     }
 
     /**
@@ -169,7 +169,7 @@ public final class PatchDataTransactionUtil {
     private static void deleteDataWithinTransaction(final YangInstanceIdentifier path,
                                                     final RestconfTransaction transaction) {
         LOG.trace("Delete {} within Restconf Patch: {}", LogicalDatastoreType.CONFIGURATION.name(), path);
-        transaction.delete(LogicalDatastoreType.CONFIGURATION, path);
+        transaction.delete(path);
     }
 
     /**
@@ -185,7 +185,7 @@ public final class PatchDataTransactionUtil {
         LOG.trace("Merge {} within Restconf Patch: {} with payload {}", LogicalDatastoreType.CONFIGURATION.name(),
             path, payload);
         TransactionUtil.ensureParentsByMerge(path, schemaContext, transaction);
-        transaction.merge(LogicalDatastoreType.CONFIGURATION, path, payload);
+        transaction.merge(path, payload);
     }
 
     /**
@@ -197,7 +197,7 @@ public final class PatchDataTransactionUtil {
     private static void removeDataWithinTransaction(final YangInstanceIdentifier path,
                                                     final RestconfTransaction transaction) {
         LOG.trace("Remove {} within Restconf Patch: {}", LogicalDatastoreType.CONFIGURATION.name(), path);
-        transaction.remove(LogicalDatastoreType.CONFIGURATION, path);
+        transaction.remove(path);
     }
 
     /**
@@ -212,6 +212,6 @@ public final class PatchDataTransactionUtil {
                                                      final RestconfTransaction transaction) {
         LOG.trace("PUT {} within Restconf Patch: {} with payload {}",
             LogicalDatastoreType.CONFIGURATION.name(), path, payload);
-        transaction.replace(LogicalDatastoreType.CONFIGURATION, path, payload, schemaContext);
+        transaction.replace(path, payload, schemaContext);
     }
 }
index 5fcbe665b3af9ad42a4574e08e5fd33063f8a013..473ba0e3538567ddf2414552186796ad8ec87d00 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.util.concurrent.FluentFuture;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
@@ -54,7 +53,7 @@ public final class PlainPatchDataTransactionUtil {
         try {
             LOG.trace("Merge CONFIGURATION within Restconf Patch: {} with payload {}", path, data);
             TransactionUtil.ensureParentsByMerge(path, schemaContext, transaction);
-            transaction.merge(LogicalDatastoreType.CONFIGURATION, path, data);
+            transaction.merge(path, data);
         } catch (final RestconfDocumentedException e) {
             transaction.cancel();
             throw new IllegalArgumentException(e);
index 32edd65421595349b748d6f425989ed11c9b04ff..70008b7e135068613bc51d872383fc39c53a9437 100644 (file)
@@ -105,14 +105,13 @@ public final class PostDataTransactionUtil {
             case FIRST:
                 readData = PutDataTransactionUtil.readList(strategy, path.getParent().getParent());
                 if (readData == null || ((NormalizedNodeContainer<?>) readData).isEmpty()) {
-                    transaction.replace(LogicalDatastoreType.CONFIGURATION, path, data, schemaContext);
+                    transaction.replace(path, data, schemaContext);
                     return transaction.commit();
                 }
                 checkItemDoesNotExists(strategy.exists(LogicalDatastoreType.CONFIGURATION, path), path);
-                transaction.remove(LogicalDatastoreType.CONFIGURATION, path.getParent().getParent());
-                transaction.replace(LogicalDatastoreType.CONFIGURATION, path, data, schemaContext);
-                transaction.replace(LogicalDatastoreType.CONFIGURATION, path.getParent().getParent(), readData,
-                    schemaContext);
+                transaction.remove(path.getParent().getParent());
+                transaction.replace(path, data, schemaContext);
+                transaction.replace(path.getParent().getParent(), readData, schemaContext);
                 return transaction.commit();
             case LAST:
                 makePost(path, data, schemaContext, transaction);
@@ -120,7 +119,7 @@ public final class PostDataTransactionUtil {
             case BEFORE:
                 readData = PutDataTransactionUtil.readList(strategy, path.getParent().getParent());
                 if (readData == null || ((NormalizedNodeContainer<?>) readData).isEmpty()) {
-                    transaction.replace(LogicalDatastoreType.CONFIGURATION, path, data, schemaContext);
+                    transaction.replace(path, data, schemaContext);
                     return transaction.commit();
                 }
                 checkItemDoesNotExists(strategy.exists(LogicalDatastoreType.CONFIGURATION, path), path);
@@ -130,7 +129,7 @@ public final class PostDataTransactionUtil {
             case AFTER:
                 readData = PutDataTransactionUtil.readList(strategy, path.getParent().getParent());
                 if (readData == null || ((NormalizedNodeContainer<?>) readData).isEmpty()) {
-                    transaction.replace(LogicalDatastoreType.CONFIGURATION, path, data, schemaContext);
+                    transaction.replace(path, data, schemaContext);
                     return transaction.commit();
                 }
                 checkItemDoesNotExists(strategy.exists(LogicalDatastoreType.CONFIGURATION, path), path);
@@ -149,7 +148,7 @@ public final class PostDataTransactionUtil {
                                             final NormalizedNodeContainer<?> readList, final boolean before,
                                             final RestconfTransaction transaction) {
         final YangInstanceIdentifier parent = path.getParent().getParent();
-        transaction.remove(LogicalDatastoreType.CONFIGURATION, parent);
+        transaction.remove(parent);
         final InstanceIdentifierContext<?> instanceIdentifier =
             ParserIdentifier.toInstanceIdentifier(point, schemaContext, Optional.empty());
         int lastItemPosition = 0;
@@ -164,14 +163,13 @@ public final class PostDataTransactionUtil {
         }
         int lastInsertedPosition = 0;
         final NormalizedNode emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, parent);
-        transaction.merge(LogicalDatastoreType.CONFIGURATION,
-            YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
+        transaction.merge(YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
         for (final NormalizedNode nodeChild : readList.body()) {
             if (lastInsertedPosition == lastItemPosition) {
-                transaction.replace(LogicalDatastoreType.CONFIGURATION, path, data, schemaContext);
+                transaction.replace(path, data, schemaContext);
             }
             final YangInstanceIdentifier childPath = parent.node(nodeChild.getIdentifier());
-            transaction.replace(LogicalDatastoreType.CONFIGURATION, childPath, nodeChild, schemaContext);
+            transaction.replace(childPath, nodeChild, schemaContext);
             lastInsertedPosition++;
         }
     }
@@ -179,7 +177,7 @@ public final class PostDataTransactionUtil {
     private static void makePost(final YangInstanceIdentifier path, final NormalizedNode data,
                                  final SchemaContext schemaContext, final RestconfTransaction transaction) {
         try {
-            transaction.create(LogicalDatastoreType.CONFIGURATION, path, data, schemaContext);
+            transaction.create(path, data, schemaContext);
         } catch (RestconfDocumentedException e) {
             // close transaction if any and pass exception further
             transaction.cancel();
index 3c31d3e26acf6a7be1aec8a32bebfc900eeb8d1e..c9ca113e8c7ffc1838f09222ed51b4ce68dc9f18 100644 (file)
@@ -102,9 +102,9 @@ public final class PutDataTransactionUtil {
                 if (readData == null || ((NormalizedNodeContainer<?>) readData).isEmpty()) {
                     return makePut(path, schemaContext, transaction, data);
                 }
-                transaction.remove(LogicalDatastoreType.CONFIGURATION, path.getParent());
-                transaction.replace(LogicalDatastoreType.CONFIGURATION, path, data, schemaContext);
-                transaction.replace(LogicalDatastoreType.CONFIGURATION, path.getParent(), readData, schemaContext);
+                transaction.remove(path.getParent());
+                transaction.replace(path, data, schemaContext);
+                transaction.replace(path.getParent(), readData, schemaContext);
                 return transaction.commit();
             case LAST:
                 return makePut(path, schemaContext, transaction, data);
@@ -143,7 +143,7 @@ public final class PutDataTransactionUtil {
                                            final NormalizedNode data,
                                            final EffectiveModelContext schemaContext, final String point,
                                            final NormalizedNodeContainer<?> readList, final boolean before) {
-        transaction.remove(LogicalDatastoreType.CONFIGURATION, path.getParent());
+        transaction.remove(path.getParent());
         final InstanceIdentifierContext<?> instanceIdentifier =
             ParserIdentifier.toInstanceIdentifier(point, schemaContext, Optional.empty());
         int lastItemPosition = 0;
@@ -158,15 +158,13 @@ public final class PutDataTransactionUtil {
         }
         int lastInsertedPosition = 0;
         final NormalizedNode emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path.getParent());
-        transaction.merge(LogicalDatastoreType.CONFIGURATION,
-            YangInstanceIdentifier.create(emptySubtree.getIdentifier()),
-            emptySubtree);
+        transaction.merge(YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
         for (final NormalizedNode nodeChild : readList.body()) {
             if (lastInsertedPosition == lastItemPosition) {
-                transaction.replace(LogicalDatastoreType.CONFIGURATION, path, data, schemaContext);
+                transaction.replace(path, data, schemaContext);
             }
             final YangInstanceIdentifier childPath = path.getParent().node(nodeChild.getIdentifier());
-            transaction.replace(LogicalDatastoreType.CONFIGURATION, childPath, nodeChild, schemaContext);
+            transaction.replace(childPath, nodeChild, schemaContext);
             lastInsertedPosition++;
         }
     }
@@ -175,7 +173,7 @@ public final class PutDataTransactionUtil {
                                                               final SchemaContext schemaContext,
                                                               final RestconfTransaction transaction,
                                                               final NormalizedNode data) {
-        transaction.replace(LogicalDatastoreType.CONFIGURATION, path, data, schemaContext);
+        transaction.replace(path, data, schemaContext);
         return transaction.commit();
     }
 
index 93b3a941589f8402786b36bc52d512e591d8407d..490af7165bc7b58cf9d7058fab0daac960b2d6e0 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.restconf.nb.rfc8040.rests.utils;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -59,6 +58,6 @@ public final class TransactionUtil {
 
         final NormalizedNode parentStructure = ImmutableNodes.fromInstanceId(schemaContext,
                 YangInstanceIdentifier.create(normalizedPathWithoutChildArgs));
-        transaction.merge(LogicalDatastoreType.CONFIGURATION, rootNormalizedPath, parentStructure);
+        transaction.merge(rootNormalizedPath, parentStructure);
     }
 }