jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r178171 - in /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: BatchedItemOperations.java NodeImpl.java SessionImpl.java
Date Tue, 24 May 2005 14:34:14 GMT
Author: tripod
Date: Tue May 24 07:34:14 2005
New Revision: 178171

URL: http://svn.apache.org/viewcvs?rev=178171&view=rev
Log:
- optimize move operations

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/BatchedItemOperations.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/BatchedItemOperations.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/BatchedItemOperations.java?rev=178171&r1=178170&r2=178171&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/BatchedItemOperations.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/BatchedItemOperations.java
Tue May 24 07:34:14 2005
@@ -422,6 +422,16 @@
 
         boolean renameOnly = srcParent.getUUID().equals(destParent.getUUID());
 
+        // remove from old parent
+        if (!renameOnly) {
+            target.removeParentUUID(srcParent.getUUID());
+        }
+        int srcNameIndex = srcName.getIndex();
+        if (srcNameIndex == 0) {
+            srcNameIndex = 1;
+        }
+        srcParent.removeChildNodeEntry(srcName.getName(), srcNameIndex);
+
         // add to new parent
         if (!renameOnly) {
             target.addParentUUID(destParent.getUUID());
@@ -433,17 +443,6 @@
                 findApplicableNodeDefinition(destName.getName(),
                         target.getNodeTypeName(), destParent);
         target.setDefinitionId(newTargetDef.getId());
-
-        // remove from old parent
-        if (!renameOnly) {
-            target.removeParentUUID(srcParent.getUUID());
-        }
-
-        int srcNameIndex = srcName.getIndex();
-        if (srcNameIndex == 0) {
-            srcNameIndex = 1;
-        }
-        srcParent.removeChildNodeEntry(srcName.getName(), srcNameIndex);
 
         // store states
         stateMgr.store(target);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?rev=178171&r1=178170&r2=178171&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java Tue May 24
07:34:14 2005
@@ -546,6 +546,16 @@
         return (NodeImpl) itemMgr.getItem(targetId);
     }
 
+    protected NodeImpl renameChildNodeLink(QName oldName, int index, String uuid, QName newName)
+            throws RepositoryException {
+        // modify the state of 'this', i.e. the parent node
+        NodeState thisState = (NodeState) getOrCreateTransientItemState();
+        thisState.removeChildNodeEntry(oldName, index);
+        thisState.addChildNodeEntry(newName, uuid);
+
+        return (NodeImpl) itemMgr.getItem(new NodeId(uuid));
+    }
+
 
     protected void removeChildProperty(String propName) throws RepositoryException {
         QName qName;

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java?rev=178171&r1=178170&r2=178171&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java Tue May
24 07:34:14 2005
@@ -911,21 +911,24 @@
         }
 
         // check lock status
-
         srcParentNode.checkLock();
         destParentNode.checkLock();
 
-        // do move operation
-
         String targetUUID = ((NodeState) targetNode.getItemState()).getUUID();
-        // add target to new parent
-        destParentNode.createChildNodeLink(destName.getName(), targetUUID);
-        // remove target from old parent
         int index = srcName.getIndex();
         if (index == 0) {
             index = 1;
         }
-        srcParentNode.removeChildNode(srcName.getName(), index);
+
+        if (srcParentNode.isSame(destParentNode)) {
+            // do rename
+            destParentNode.renameChildNodeLink(srcName.getName(), index, targetUUID, destName.getName());
+        } else {
+            // do move
+            destParentNode.createChildNodeLink(destName.getName(), targetUUID);
+            srcParentNode.removeChildNode(srcName.getName(), index);
+        }
+
         // change definition of target if necessary
         NodeDefinitionImpl oldTargetDef = (NodeDefinitionImpl) targetNode.getDefinition();
         NodeDefId oldTargetDefId = oldTargetDef.unwrap().getId();



Mime
View raw message