jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r431889 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state: ChildNodeEntry.java NodeState.java PathElementReference.java UUIDReference.java WorkspaceItemStateFactory.java
Date Wed, 16 Aug 2006 12:50:44 GMT
Author: mreutegg
Date: Wed Aug 16 05:50:43 2006
New Revision: 431889

URL: http://svn.apache.org/viewvc?rev=431889&view=rev
Log:
- Introduce getUUID() on ChildNodeEntry
- replace ChildNodeEntries.add(QName, NodeId) with ChildNodeEntries.add(QName, String)

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntry.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathElementReference.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntry.java?rev=431889&r1=431888&r2=431889&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntry.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntry.java
Wed Aug 16 05:50:43 2006
@@ -36,6 +36,13 @@
     public QName getName();
 
     /**
+     * @return the UUID of the node state which is referenced by this child node
+     * entry or <code>null</code> if the node state cannot be identified with
a
+     * UUID.
+     */
+    public String getUUID();
+
+    /**
      * @return the index of this child node entry to suppport same-name siblings.
      */
     public int getIndex();

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?rev=431889&r1=431888&r2=431889&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
Wed Aug 16 05:50:43 2006
@@ -184,7 +184,7 @@
             it = nodeState.getChildNodeEntries().iterator();
             while (it.hasNext()) {
                 ChildNodeEntry cne = (ChildNodeEntry) it.next();
-                childNodeEntries.add(cne.getName(), cne.getId());
+                childNodeEntries.add(cne.getName(), cne.getUUID());
             }
         }
     }
@@ -463,12 +463,16 @@
     /**
      * Adds a new <code>ChildNodeEntry</code>.
      *
-     * @param nodeName <code>QName</code> object specifying the name of the new
entry.
-     * @param id the id the new entry is refering to.
+     * @param nodeName <code>QName</code> object specifying the name of the new
+     *                 entry.
+     * @param uuid     the uuid the new entry is refering to or
+     *                 <code>null</code> if the child node state cannot be
+     *                 identified with a uuid.
      * @return the newly added <code>ChildNodeEntry</code>
      */
-    synchronized ChildNodeEntry addChildNodeEntry(QName nodeName, NodeId id) {
-        ChildNodeEntry entry = childNodeEntries.add(nodeName, id);
+    synchronized ChildNodeEntry addChildNodeEntry(QName nodeName,
+                                                  String uuid) {
+        ChildNodeEntry entry = childNodeEntries.add(nodeName, uuid);
         notifyNodeAdded(entry);
         return entry;
     }
@@ -529,7 +533,6 @@
     }
 
     /**
-    /**
      * @inheritDoc
      * @see ItemState#remove()
      */
@@ -825,7 +828,7 @@
         childNodeEntries.clear(); // TODO: any mre cleanup work to do? try some kind of merging?
         for (Iterator it = nodeEntries.iterator(); it.hasNext(); ) {
             ChildNodeEntry cne = (ChildNodeEntry) it.next();
-            childNodeEntries.add(cne.getName(), cne.getId());
+            childNodeEntries.add(cne.getName(), cne.getUUID());
         }
         // TODO: correct?
         notifyNodesReplaced();
@@ -849,7 +852,7 @@
         ChildNodeEntry oldEntry = childNodeEntries.remove(childId);
         if (oldEntry != null) {
             if (newParent == this) {
-                ChildNodeEntry newEntry = childNodeEntries.add(name, oldEntry.getId());
+                ChildNodeEntry newEntry = childNodeEntries.add(name, childState.getUUID());
                 notifyNodeAdded(newEntry);
                 notifyNodeRemoved(oldEntry);
             } else {
@@ -857,7 +860,7 @@
                 // re-parent target node
                 childState.setParent(newParent);
                 // add child node entry to new parent
-                newParent.addChildNodeEntry(newName, childId);
+                newParent.addChildNodeEntry(newName, childState.getUUID());
             }
         } else {
             throw new RepositoryException("Unexpected error: Child state to be renamed does
not exist.");
@@ -1024,7 +1027,7 @@
             return null;
         }
 
-        ChildNodeEntry add(QName nodeName, NodeId id) {
+        ChildNodeEntry add(QName nodeName, String uuid) {
             List siblings = null;
             Object obj = nameMap.get(nodeName);
             if (obj != null) {
@@ -1040,13 +1043,13 @@
                 }
             }
 
-            ChildNodeEntry entry = createChildNodeEntry(nodeName, id);
+            ChildNodeEntry entry = createChildNodeEntry(nodeName, uuid);
             if (siblings != null) {
                 siblings.add(entry);
             } else {
                 nameMap.put(nodeName, entry);
             }
-            entries.put(id, entry);
+            entries.put(idFactory.createNodeId(uuid), entry);
 
             return entry;
         }
@@ -1081,7 +1084,7 @@
             while (iter.hasNext()) {
                 ChildNodeEntry entry = (ChildNodeEntry) iter.next();
                 // delegate to add(QName, String) to maintain consistency
-                add(entry.getName(), entry.getId());
+                add(entry.getName(), entry.getUUID());
             }
         }
 
@@ -1166,17 +1169,20 @@
 
         /**
          * Creates a <code>ChildNodeEntry</code> instance based on
-         * <code>nodeName</code>, <code>id</code> and <code>index</code>.
+         * <code>nodeName</code> and an optional <code>uuid</code>.
          *
          * @param nodeName the name of the child node.
-         * @param id the id of the child node.
-         * @return
+         * @param uuid     the UUID of the child node. If <code>null</code> the
+         *                 child node cannot be identified with a UUID.
+         * @return the created child node entry.
          */
-        private ChildNodeEntry createChildNodeEntry(QName nodeName, NodeId id) {
-            if (id.getRelativePath() != null) {
-                return new PathElementReference(NodeState.this, nodeName, isf, idFactory);
+        private ChildNodeEntry createChildNodeEntry(QName nodeName, String uuid) {
+            if (uuid == null) {
+                return new PathElementReference(NodeState.this, nodeName,
+                        isf, idFactory);
             } else {
-                return new UUIDReference(NodeState.this, id, isf, nodeName);
+                return new UUIDReference(NodeState.this,
+                        idFactory.createNodeId(uuid), isf, nodeName);
             }
         }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathElementReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathElementReference.java?rev=431889&r1=431888&r2=431889&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathElementReference.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathElementReference.java
Wed Aug 16 05:50:43 2006
@@ -79,4 +79,13 @@
     public NodeId getId() {
         return idFactory.createNodeId(parent.getNodeId(), Path.create(getName(), getIndex()));
     }
+
+    /**
+     * This implementation always returns <code>null</code>.
+     * @inheritDoc
+     * @see ChildNodeEntry#getUUID()
+     */
+    public String getUUID() {
+        return null;
+    }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java?rev=431889&r1=431888&r2=431889&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java
Wed Aug 16 05:50:43 2006
@@ -85,4 +85,13 @@
     public NodeId getId() {
         return childId;
     }
+
+    /**
+     * This implementation always returns a non-null value.
+     * @inheritDoc
+     * @see ChildNodeEntry#getUUID()
+     */
+    public String getUUID() {
+        return childId.getUUID();
+    }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?rev=431889&r1=431888&r2=431889&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
Wed Aug 16 05:50:43 2006
@@ -120,8 +120,11 @@
             // references to child items
             for (IdIterator it = info.getNodeIds(); it.hasNext(); ) {
                 NodeInfo childInfo = service.getNodeInfo(sessionInfo, (NodeId) it.nextId());
-                NodeId childId = childInfo.getId();
-                state.addChildNodeEntry(childInfo.getQName(), childId);
+                String childUUID = null;
+                if (childInfo.getId().getRelativePath() == null) {
+                    childUUID = childInfo.getId().getUUID();
+                }
+                state.addChildNodeEntry(childInfo.getQName(), childUUID);
             }
 
             // references to properties



Mime
View raw message