- makePost(path, data, schemaContext, transactionChain, newReadWriteTransaction);
- return newReadWriteTransaction.commit();
- } else {
- final DataSchemaNode schemaNode = PutDataTransactionUtil.checkListAndOrderedType(schemaContext, path);
- switch (insert) {
- case "first":
- if (schemaNode instanceof ListSchemaNode) {
- final NormalizedNode<?, ?> readData = PutDataTransactionUtil.readList(path.getParent(),
- schemaContext, transactionNode.getTransactionChainHandler(), schemaNode);
- final OrderedMapNode readList = (OrderedMapNode) readData;
- if (readList == null || readList.getValue().isEmpty()) {
- makePost(path, data, schemaContext, transactionChain,
- newReadWriteTransaction);
- return newReadWriteTransaction.commit();
- } else {
- newReadWriteTransaction.delete(LogicalDatastoreType.CONFIGURATION,
- path.getParent().getParent());
- simplePost(newReadWriteTransaction, LogicalDatastoreType.CONFIGURATION, path, data,
- schemaContext, transactionChain);
- makePost(path, readData, schemaContext, transactionChain,
- newReadWriteTransaction);
- return newReadWriteTransaction.commit();
- }
- } else {
- final NormalizedNode<?, ?> readData = PutDataTransactionUtil.readList(path.getParent(),
- schemaContext, transactionNode.getTransactionChainHandler(), schemaNode);
-
- final OrderedLeafSetNode<?> readLeafList = (OrderedLeafSetNode<?>) readData;
- if (readLeafList == null || readLeafList.getValue().isEmpty()) {
- makePost(path, data, schemaContext, transactionChain,
- newReadWriteTransaction);
- return newReadWriteTransaction.commit();
- } else {
- newReadWriteTransaction.delete(LogicalDatastoreType.CONFIGURATION,
- path.getParent().getParent());
- simplePost(newReadWriteTransaction, LogicalDatastoreType.CONFIGURATION, path, data,
- schemaContext, transactionChain);
- makePost(path, readData, schemaContext, transactionChain,
- newReadWriteTransaction);
- return newReadWriteTransaction.commit();
- }
- }
- case "last":
- makePost(path, data, schemaContext, transactionChain,
- newReadWriteTransaction);
- return newReadWriteTransaction.commit();
- case "before":
- if (schemaNode instanceof ListSchemaNode) {
- final NormalizedNode<?, ?> readData = PutDataTransactionUtil.readList(path.getParent(),
- schemaContext, transactionNode.getTransactionChainHandler(), schemaNode);
- final OrderedMapNode readList = (OrderedMapNode) readData;
- if (readList == null || readList.getValue().isEmpty()) {
- makePost(path, data, schemaContext, transactionChain,
- newReadWriteTransaction);
- return newReadWriteTransaction.commit();
- } else {
- insertWithPointListPost(newReadWriteTransaction, LogicalDatastoreType.CONFIGURATION, path,
- data, schemaContext, point, readList, true,
- transactionChain);
- return newReadWriteTransaction.commit();
- }
- } else {
- final NormalizedNode<?, ?> readData = PutDataTransactionUtil.readList(path.getParent(),
- schemaContext, transactionNode.getTransactionChainHandler(), schemaNode);
-
- final OrderedLeafSetNode<?> readLeafList = (OrderedLeafSetNode<?>) readData;
- if (readLeafList == null || readLeafList.getValue().isEmpty()) {
- makePost(path, data, schemaContext, transactionChain,
- newReadWriteTransaction);
- return newReadWriteTransaction.commit();
- } else {
- insertWithPointLeafListPost(newReadWriteTransaction, LogicalDatastoreType.CONFIGURATION,
- path, data, schemaContext, point, readLeafList, true,
- transactionChain);
- return newReadWriteTransaction.commit();
- }
- }
- case "after":
- if (schemaNode instanceof ListSchemaNode) {
- final NormalizedNode<?, ?> readData = PutDataTransactionUtil.readList(path.getParent(),
- schemaContext, transactionNode.getTransactionChainHandler(), schemaNode);
- final OrderedMapNode readList = (OrderedMapNode) readData;
- if (readList == null || readList.getValue().isEmpty()) {
- makePost(path, data, schemaContext, transactionChain,
- newReadWriteTransaction);
- return newReadWriteTransaction.commit();
- } else {
- insertWithPointListPost(newReadWriteTransaction, LogicalDatastoreType.CONFIGURATION, path,
- data, schemaContext, point, readList, false,
- transactionChain);
- return newReadWriteTransaction.commit();
- }
- } else {
- final NormalizedNode<?, ?> readData = PutDataTransactionUtil.readList(path.getParent(),
- schemaContext, transactionNode.getTransactionChainHandler(), schemaNode);
-
- final OrderedLeafSetNode<?> readLeafList = (OrderedLeafSetNode<?>) readData;
- if (readLeafList == null || readLeafList.getValue().isEmpty()) {
- makePost(path, data, schemaContext, transactionChain,
- newReadWriteTransaction);
- return newReadWriteTransaction.commit();
- } else {
- insertWithPointLeafListPost(newReadWriteTransaction, LogicalDatastoreType.CONFIGURATION,
- path, data, schemaContext, point, readLeafList, true,
- transactionChain);
- return newReadWriteTransaction.commit();
- }
- }
- default:
- throw new RestconfDocumentedException(
- "Used bad value of insert parameter. Possible values are first, last, before or after, "
- + "but was: " + insert, RestconfError.ErrorType.PROTOCOL,
- RestconfError.ErrorTag.BAD_ATTRIBUTE);
- }