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;
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;
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);
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)) {
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();
}
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);
}
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;
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;
}
@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);
}
}
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;
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;
}
@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()));
}
}
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;
/**
* 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);
}
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;
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();
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);
}
/**
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);
}
/**
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);
}
/**
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);
}
/**
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);
}
}
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;
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);
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);
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);
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);
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;
}
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++;
}
}
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();
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);
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;
}
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++;
}
}
final SchemaContext schemaContext,
final RestconfTransaction transaction,
final NormalizedNode data) {
- transaction.replace(LogicalDatastoreType.CONFIGURATION, path, data, schemaContext);
+ transaction.replace(path, data, schemaContext);
return transaction.commit();
}
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;
final NormalizedNode parentStructure = ImmutableNodes.fromInstanceId(schemaContext,
YangInstanceIdentifier.create(normalizedPathWithoutChildArgs));
- transaction.merge(LogicalDatastoreType.CONFIGURATION, rootNormalizedPath, parentStructure);
+ transaction.merge(rootNormalizedPath, parentStructure);
}
}