*/
public final class PostDataTransactionUtil {
private static final Logger LOG = LoggerFactory.getLogger(PostDataTransactionUtil.class);
+ // FIXME: why is this being reused from other places?
+ static final String POST_TX_TYPE = "POST";
private PostDataTransactionUtil() {
// Hidden on purpose
final URI location = resolveLocation(uriInfo, path, schemaContext, payload.getData());
final ResponseFactory dataFactory = new ResponseFactory(Status.CREATED).location(location);
//This method will close transactionChain if any
- FutureCallbackTx.addCallback(future, RestconfDataServiceConstant.PostData.POST_TX_TYPE, dataFactory,
- strategy.getTransactionChain());
+ FutureCallbackTx.addCallback(future, POST_TX_TYPE, dataFactory, strategy.getTransactionChain());
return dataFactory.build();
}
strategy.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
for (final LeafSetEntryNode<?> nodeChild : readLeafList.getValue()) {
if (lastInsertedPosition == lastItemPosition) {
- checkItemDoesNotExists(strategy, datastore, path, RestconfDataServiceConstant.PostData.POST_TX_TYPE);
+ checkItemDoesNotExists(strategy, datastore, path);
strategy.create(datastore, path, payload);
}
final YangInstanceIdentifier childPath = path.getParent().getParent().node(nodeChild.getIdentifier());
- checkItemDoesNotExists(strategy, datastore, childPath, RestconfDataServiceConstant.PostData.POST_TX_TYPE);
+ checkItemDoesNotExists(strategy, datastore, childPath);
strategy.create(datastore, childPath, nodeChild);
lastInsertedPosition++;
}
strategy.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
for (final MapEntryNode mapEntryNode : readList.getValue()) {
if (lastInsertedPosition == lastItemPosition) {
- checkItemDoesNotExists(strategy, datastore, path, RestconfDataServiceConstant.PostData.POST_TX_TYPE);
+ checkItemDoesNotExists(strategy, datastore, path);
strategy.create(datastore, path, payload);
}
final YangInstanceIdentifier childPath = path.getParent().getParent().node(mapEntryNode.getIdentifier());
- checkItemDoesNotExists(strategy, datastore, childPath, RestconfDataServiceConstant.PostData.POST_TX_TYPE);
+ checkItemDoesNotExists(strategy, datastore, childPath);
strategy.create(datastore, childPath, mapEntryNode);
lastInsertedPosition++;
}
boolean merge = false;
for (final MapEntryNode child : ((MapNode) data).getValue()) {
final YangInstanceIdentifier childPath = path.node(child.getIdentifier());
- checkItemDoesNotExists(strategy, LogicalDatastoreType.CONFIGURATION, childPath,
- RestconfDataServiceConstant.PostData.POST_TX_TYPE);
+ checkItemDoesNotExists(strategy, LogicalDatastoreType.CONFIGURATION, childPath);
if (!merge) {
merge = true;
TransactionUtil.ensureParentsByMerge(path, schemaContext, strategy);
strategy.create(LogicalDatastoreType.CONFIGURATION, childPath, child);
}
} else {
- checkItemDoesNotExists(strategy, LogicalDatastoreType.CONFIGURATION, path,
- RestconfDataServiceConstant.PostData.POST_TX_TYPE);
+ checkItemDoesNotExists(strategy, LogicalDatastoreType.CONFIGURATION, path);
TransactionUtil.ensureParentsByMerge(path, schemaContext, strategy);
strategy.create(LogicalDatastoreType.CONFIGURATION, path, data);
private static void simplePost(final LogicalDatastoreType datastore, final YangInstanceIdentifier path,
final NormalizedNode<?, ?> payload,
final SchemaContext schemaContext, final RestconfStrategy strategy) {
- checkItemDoesNotExists(strategy, datastore, path, RestconfDataServiceConstant.PostData.POST_TX_TYPE);
+ checkItemDoesNotExists(strategy, datastore, path);
TransactionUtil.ensureParentsByMerge(path, schemaContext, strategy);
strategy.create(datastore, path, payload);
}
* @param operationType Type of operation (READ, POST, PUT, DELETE...)
*/
private static void checkItemDoesNotExists(final RestconfStrategy strategy,
- final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final String operationType) {
+ final LogicalDatastoreType store, final YangInstanceIdentifier path) {
final FluentFuture<Boolean> future = strategy.exists(store, path);
final FutureDataFactory<Boolean> response = new FutureDataFactory<>();
- FutureCallbackTx.addCallback(future, operationType, response);
+ FutureCallbackTx.addCallback(future, POST_TX_TYPE, response);
if (response.result) {
// close transaction