jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r792469 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: BatchedItemOperations.java util/ReferenceChangeTracker.java xml/SessionImporter.java xml/WorkspaceImporter.java
Date Thu, 09 Jul 2009 09:17:48 GMT
Author: jukka
Date: Thu Jul  9 09:17:47 2009
New Revision: 792469

URL: http://svn.apache.org/viewvc?rev=792469&view=rev
Log:
JCR-1232: Merge UUID to NodeId

Use NodeIds instead of UUIDs in ReferenceChangeTracker.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/ReferenceChangeTracker.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java?rev=792469&r1=792468&r2=792469&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
Thu Jul  9 09:17:47 2009
@@ -451,10 +451,10 @@
             InternalValue[] newVals = new InternalValue[values.length];
             for (int i = 0; i < values.length; i++) {
                 InternalValue val = values[i];
-                UUID original = val.getUUID();
-                UUID adjusted = refTracker.getMappedUUID(original);
+                NodeId original = new NodeId(val.getUUID());
+                NodeId adjusted = refTracker.getMappedId(original);
                 if (adjusted != null) {
-                    newVals[i] = InternalValue.create(adjusted);
+                    newVals[i] = InternalValue.create(adjusted.getUUID());
                     modified = true;
                 } else {
                     // reference doesn't need adjusting, just copy old value
@@ -1693,7 +1693,7 @@
                     id = new NodeId(UUID.randomUUID());
                     if (referenceable) {
                         // remember uuid mapping
-                        refTracker.mappedUUID(srcState.getNodeId().getUUID(), id.getUUID());
+                        refTracker.mappedId(srcState.getNodeId(), id);
                     }
                     break;
                 case CLONE:
@@ -1778,9 +1778,8 @@
                  * UUID instead of copying the whole subtree.
                  */
                 if (srcChildState.isShareable()) {
-                    UUID uuid = refTracker.getMappedUUID(srcChildState.getNodeId().getUUID());
-                    if (uuid != null) {
-                        NodeId mappedId = new NodeId(uuid);
+                    NodeId mappedId = refTracker.getMappedId(srcChildState.getNodeId());
+                    if (mappedId != null) {
                         if (stateMgr.hasItemState(mappedId)) {
                             NodeState destState = (NodeState) stateMgr.getItemState(mappedId);
                             if (!destState.isShareable()) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/ReferenceChangeTracker.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/ReferenceChangeTracker.java?rev=792469&r1=792468&r2=792469&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/ReferenceChangeTracker.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/ReferenceChangeTracker.java
Thu Jul  9 09:17:47 2009
@@ -16,51 +16,48 @@
  */
 package org.apache.jackrabbit.core.util;
 
-import org.apache.jackrabbit.uuid.UUID;
+import org.apache.jackrabbit.core.id.NodeId;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;
 
 /**
- * Simple helper class that can be used to keep track of uuid mappings
- * (e.g. if the uuid of an imported or copied node is mapped to a new uuid)
+ * Simple helper class that can be used to keep track of node id mappings
+ * (e.g. if the id of an imported or copied node is mapped to a new id)
  * and processed (e.g. imported or copied) reference properties that might
- * need correcting depending on the uuid mappings.
+ * need correcting depending on the id mappings.
  */
 public class ReferenceChangeTracker {
+
     /**
-     * mapping <original uuid> to <new uuid> of mix:referenceable nodes
+     * mapping from original id to new id of mix:referenceable nodes
      */
-    private final HashMap<UUID, UUID> uuidMap = new HashMap<UUID, UUID>();
+    private final Map<NodeId, NodeId> idMap = new HashMap<NodeId, NodeId>();
+
     /**
      * list of processed reference properties that might need correcting
      */
     private final ArrayList<Object> references = new ArrayList<Object>();
 
     /**
-     * Creates a new instance.
-     */
-    public ReferenceChangeTracker() {
-    }
-
-    /**
      * Resets all internal state.
      */
     public void clear() {
-        uuidMap.clear();
+        idMap.clear();
         references.clear();
     }
 
     /**
-     * Store the given uuid mapping for later lookup using
-     * <code>{@link #getMappedUUID(UUID)}</code>.
+     * Store the given id mapping for later lookup using
+     * <code>{@link #getMappedId(NodeId)}</code>.
      *
-     * @param oldUUID old uuid
-     * @param newUUID new uuid
+     * @param oldId old node id
+     * @param newId new node id
      */
-    public void mappedUUID(UUID oldUUID, UUID newUUID) {
-        uuidMap.put(oldUUID, newUUID);
+    public void mappedId(NodeId oldId, NodeId newId) {
+        idMap.put(oldId, newId);
     }
 
     /**
@@ -74,15 +71,15 @@
     }
 
     /**
-     * Returns the new UUID to which <code>oldUUID</code> has been mapped
+     * Returns the new node id to which <code>oldId</code> has been mapped
      * or <code>null</code> if no such mapping exists.
      *
-     * @param oldUUID old uuid
-     * @return mapped new uuid or <code>null</code> if no such mapping exists
-     * @see #mappedUUID(UUID, UUID)
+     * @param oldId old node id
+     * @return mapped new id or <code>null</code> if no such mapping exists
+     * @see #mappedId(NodeId, NodeId)
      */
-    public UUID getMappedUUID(UUID oldUUID) {
-        return uuidMap.get(oldUUID);
+    public NodeId getMappedId(NodeId oldId) {
+        return idMap.get(oldId);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java?rev=792469&r1=792468&r2=792469&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/SessionImporter.java
Thu Jul  9 09:17:47 2009
@@ -112,7 +112,7 @@
                     nodeInfo.getNodeTypeName(), nodeInfo.getMixinNames(), null);
             // remember uuid mapping
             if (node.isNodeType(NameConstants.MIX_REFERENCEABLE)) {
-                refTracker.mappedUUID(nodeInfo.getId().getUUID(), node.getNodeId().getUUID());
+                refTracker.mappedId(nodeInfo.getId(), node.getNodeId());
             }
         } else if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW) {
             // if conflicting node is shareable, then clone it
@@ -290,11 +290,11 @@
                 Value[] newVals = new Value[values.length];
                 for (int i = 0; i < values.length; i++) {
                     Value val = values[i];
-                    UUID original = UUID.fromString(val.getString());
-                    UUID adjusted = refTracker.getMappedUUID(original);
+                    NodeId original = new NodeId(UUID.fromString(val.getString()));
+                    NodeId adjusted = refTracker.getMappedId(original);
                     if (adjusted != null) {
                         newVals[i] = session.getValueFactory().createValue(
-                                session.getNodeByUUID(adjusted),
+                                session.getNodeByUUID(adjusted.getUUID()),
                                 prop.getType() != PropertyType.REFERENCE);
                     } else {
                         // reference doesn't need adjusting, just copy old value
@@ -304,10 +304,10 @@
                 prop.setValue(newVals);
             } else {
                 Value val = prop.getValue();
-                UUID original = UUID.fromString(val.getString());
-                UUID adjusted = refTracker.getMappedUUID(original);
+                NodeId original = new NodeId(UUID.fromString(val.getString()));
+                NodeId adjusted = refTracker.getMappedId(original);
                 if (adjusted != null) {
-                    prop.setValue(session.getNodeByUUID(adjusted));
+                    prop.setValue(session.getNodeById(adjusted).getUUID());
                 }
             }
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java?rev=792469&r1=792468&r2=792469&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/WorkspaceImporter.java
Thu Jul  9 09:17:47 2009
@@ -36,7 +36,6 @@
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
-import org.apache.jackrabbit.uuid.UUID;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -156,7 +155,7 @@
             // remember uuid mapping
             EffectiveNodeType ent = itemOps.getEffectiveNodeType(node);
             if (ent.includesNodeType(NameConstants.MIX_REFERENCEABLE)) {
-                refTracker.mappedUUID(nodeInfo.getId().getUUID(), node.getNodeId().getUUID());
+                refTracker.mappedId(nodeInfo.getId(), node.getNodeId());
             }
         } else if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW) {
             // if existing node is shareable, then instead of failing, create
@@ -607,11 +606,11 @@
                 InternalValue[] newVals = new InternalValue[values.length];
                 for (int i = 0; i < values.length; i++) {
                     InternalValue val = values[i];
-                    UUID original = val.getUUID();
-                    UUID adjusted = refTracker.getMappedUUID(original);
+                    NodeId original = new NodeId(val.getUUID());
+                    NodeId adjusted = refTracker.getMappedId(original);
                     if (adjusted != null) {
                         newVals[i] = InternalValue.create(
-                                adjusted,
+                                adjusted.getUUID(),
                                 prop.getType() != PropertyType.REFERENCE);
                         modified = true;
                     } else {



Mime
View raw message