Author: bcarothers
Date: 2009-06-11 17:23:33 -0400 (Thu, 11 Jun 2009)
New Revision: 1046
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
Log:
DNA-459 Mandatory Child Nodes Can Be Removed
Applied patch that conservatively inspects every changed node (and its parent) to
determine if node type definitions are violated.
As an aside, by spec, DNA has to let mandatory child nodes be removed, it just cannot
allow their parents to be saved if no replacement child node was re-added.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-06-11 15:52:24
UTC (rev 1045)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-06-11 21:23:33
UTC (rev 1046)
@@ -386,6 +386,12 @@
boolean checkSns )
throws ConstraintViolationException, ItemExistsException, RepositoryException {
+ assert nodeUuid != null;
+
+ if (this.deletedNodes.containsKey(nodeUuid)) {
+ nodeUuid = this.deletedNodes.get(nodeUuid).getParent();
+ }
+
NodeInfo nodeInfo = findNodeInfo(nodeUuid);
AbstractJcrNode node = findJcrNode(nodeUuid);
@@ -631,9 +637,9 @@
*/
public void save() throws RepositoryException {
if (operations.isExecuteRequired()) {
- for (UUID changedUuid : changedNodes.keySet()) {
- checkAgainstTypeDefinitions(changedUuid, false);
- }
+ for (UUID changedUuid : this.changedNodes.keySet()) {
+ checkAgainstTypeDefinitions(changedUuid, false);
+ }
// Execute the batched operations ...
try {
@@ -726,6 +732,11 @@
*/
Set<UUID> uuidsUnderBranch = new HashSet<UUID>();
LinkedList<UUID> peersToCheck = new LinkedList<UUID>();
+
+ for (UUID changedUuid : branchUuids) {
+ checkAgainstTypeDefinitions(changedUuid, false);
+ }
+
for (UUID branchUuid : branchUuids) {
uuidsUnderBranch.add(branchUuid);
ChangedNodeInfo changedNode = changedNodes.get(branchUuid);
@@ -749,12 +760,6 @@
}
}
- for (UUID changedUuid : uuidsUnderBranch) {
- if (!this.deletedNodes.containsKey(changedUuid)) {
- checkAgainstTypeDefinitions(changedUuid, false);
- }
- }
-
// Now execute the branch ...
Graph.Batch branchBatch = store.batch(new
BatchRequestBuilder(branchRequests));
try {
Show replies by date