[dna-commits] DNA SVN: r1306 - in trunk: extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic and 1 other directory.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Thu Oct 22 20:54:08 EDT 2009


Author: bcarothers
Date: 2009-10-22 20:54:08 -0400 (Thu, 22 Oct 2009)
New Revision: 1306

Modified:
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
   trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java
Log:
DNA-518 JPA connector fails to properly clone or update from another workspace

Committed patch that pushes the desiredSegment down into the copyNode call (if the desiredSegment is specified). Previously, copyNode was silently converting the desiredSegment field into a desiredName.


Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java	2009-10-22 10:27:12 UTC (rev 1305)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java	2009-10-23 00:54:08 UTC (rev 1306)
@@ -37,6 +37,7 @@
 import org.apache.jackrabbit.test.api.NodeItemIsNewTest;
 import org.apache.jackrabbit.test.api.NodeOrderableChildNodesTest;
 import org.apache.jackrabbit.test.api.NodeRemoveMixinTest;
+import org.apache.jackrabbit.test.api.NodeTest;
 import org.apache.jackrabbit.test.api.PropertyItemIsModifiedTest;
 import org.apache.jackrabbit.test.api.PropertyItemIsNewTest;
 import org.apache.jackrabbit.test.api.PropertyTest;
@@ -198,7 +199,7 @@
             // addTestSuite(ReferencesTest.class);
             addTestSuite(SessionTest.class);
             // addTestSuite(SessionUUIDTest.class);
-            // DNA-518 addTestSuite(NodeTest.class);
+            addTestSuite(NodeTest.class);
             // addTestSuite(NodeUUIDTest.class);
             addTestSuite(NodeOrderableChildNodesTest.class);
             addTestSuite(PropertyTest.class);

Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java	2009-10-22 10:27:12 UTC (rev 1305)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java	2009-10-23 00:54:08 UTC (rev 1306)
@@ -1152,13 +1152,14 @@
                                      ActualLocation actualNewParent,
                                      UuidConflictBehavior uuidConflictBehavior,
                                      Name desiredName,
+                                     Path.Segment desiredSegment,
                                      Map<String, String> oldUuidsToNewUuids,
                                      Map<String, ChildEntity> addedLocations,
                                      Map<String, Location> deletedLocations ) {
         assert fromWorkspace != null;
         assert intoWorkspace != null;
         assert original != null;
-        assert desiredName != null;
+        assert (desiredName != null ? desiredSegment == null : desiredSegment != null) : "Either desiredName or desiredSegment must not be null";
         assert oldUuidsToNewUuids != null;
 
         // Assume that UUID isn't changing. If the conflict behavior says that it does change, the switch statement will handle it
@@ -1184,10 +1185,17 @@
                 break;
             case REPLACE_EXISTING_NODE:
                 try {
-                    existingLocation = getActualLocation(intoWorkspace, Location.create(oldUuid));
-                    deletedLocations.putAll(computeDeletedLocations(intoWorkspace, existingLocation.location, true));
+                    if (desiredSegment != null) {
+                        existingLocation = getActualLocation(intoWorkspace,
+                                                             Location.create(pathFactory.create(actualNewParent.location.getPath(),
+                                                                                                desiredSegment)));
+                        newUuid = existingLocation.childEntity.getId().getChildUuidString();
+
+                    } else {
+                        existingLocation = getActualLocation(intoWorkspace, Location.create(oldUuid));
+                        deletedLocations.putAll(computeDeletedLocations(intoWorkspace, existingLocation.location, true));
+                    }
                 } catch (PathNotFoundException pnfe) {
-
                 }
                 break;
             default:
@@ -1196,6 +1204,7 @@
         oldUuidsToNewUuids.put(original.getId().getChildUuidString(), newUuid);
 
         if (existingLocation != null && existingLocation.childEntity.getParentUuidString().equals(actualNewParent.uuid)) {
+            if (desiredName == null) desiredName = desiredSegment.getName();
             NamespaceEntity namespace = NamespaceEntity.findByUri(entities, desiredName.getNamespaceUri());
 
             ChildEntity existingChild = existingLocation.childEntity;
@@ -1285,6 +1294,7 @@
                                                      actualNewParent,
                                                      UuidConflictBehavior.ALWAYS_CREATE_NEW_UUID,
                                                      desiredName,
+                                                     null,
                                                      originalToNewUuid,
                                                      addedLocations,
                                                      deletedLocations).location;
@@ -1306,6 +1316,7 @@
                                   actualNewParent,
                                   UuidConflictBehavior.ALWAYS_CREATE_NEW_UUID,
                                   desiredName,
+                                  null,
                                   originalToNewUuid,
                                   addedLocations,
                                   deletedLocations);
@@ -1472,7 +1483,6 @@
                     ChildEntity original = originalIter.next();
 
                     Name desiredName = request.desiredName();
-                    if (desiredName == null) desiredName = fromPath.getLastSegment().getName();
                     actualToLocation = this.copyNode(entities,
                                                      fromWorkspace,
                                                      intoWorkspace,
@@ -1480,6 +1490,7 @@
                                                      actualNewParent,
                                                      conflictBehavior,
                                                      desiredName,
+                                                     desiredName != null ? null : fromPath.getLastSegment(),
                                                      originalToNewUuid,
                                                      addedLocations,
                                                      deletedLocations).location;
@@ -1501,6 +1512,7 @@
                                   actualNewParent,
                                   conflictBehavior,
                                   desiredName,
+                                  null,
                                   originalToNewUuid,
                                   addedLocations,
                                   deletedLocations);
@@ -2087,8 +2099,8 @@
                 } else {
 
                     ActualLocation actualBeforeLocation = getActualLocation(workspace, beforeLocation);
-                    ActualLocation actualIntoLocation = getActualLocation(workspace, Location.create(beforeLocation.getPath()
-                                                                                                                   .getParent()));
+                    ActualLocation actualIntoLocation = getActualLocation(workspace,
+                                                                          Location.create(beforeLocation.getPath().getParent()));
 
                     actualNewLocation = moveNodeBefore(workspace, actualLocation, actualIntoLocation, actualBeforeLocation);
                 }



More information about the dna-commits mailing list