- protected void checkTouchApplicable(final ModificationPath path, final NodeModification modification,
- final Optional<TreeNode> current, final Version version) throws DataValidationFailedException {
- if (!modification.getOriginal().isPresent() && !current.isPresent()) {
- final YangInstanceIdentifier id = path.toInstanceIdentifier();
- throw new ModifiedNodeDoesNotExistException(id,
- String.format("Node %s does not exist. Cannot apply modification to its children.", id));
+ protected final void checkTouchApplicable(final ModificationPath path, final NodeModification modification,
+ final Optional<? extends TreeNode> current, final Version version) throws DataValidationFailedException {
+ final TreeNode currentNode;
+ if (!current.isPresent()) {
+ currentNode = defaultTreeNode();
+ if (currentNode == null) {
+ if (!modification.getOriginal().isPresent()) {
+ final YangInstanceIdentifier id = path.toInstanceIdentifier();
+ throw new ModifiedNodeDoesNotExistException(id,
+ String.format("Node %s does not exist. Cannot apply modification to its children.", id));
+ }
+
+ throw new ConflictingModificationAppliedException(path.toInstanceIdentifier(),
+ "Node was deleted by other transaction.");
+ }
+ } else {
+ currentNode = current.get();