jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r515167 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: hierarchy/EntryFactory.java hierarchy/NodeEntryImpl.java hierarchy/UniqueIdResolver.java state/WorkspaceItemStateFactory.java
Date Tue, 06 Mar 2007 15:53:52 GMT
Author: angela
Date: Tue Mar  6 07:53:51 2007
New Revision: 515167

URL: http://svn.apache.org/viewvc?view=rev&rev=515167
Log:
- adding a NodeEntry identified by uniqueID (or changing the uniqueID field) must remove any
other NodeEntry, that is identified by the same uniqueID.
- creating ItemState must assert, that the path of the info corresponds to the path of the
hierarchyEntry

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/UniqueIdResolver.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/hierarchy/EntryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java?view=diff&rev=515167&r1=515166&r2=515167
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
Tue Mar  6 07:53:51 2007
@@ -68,6 +68,9 @@
         return isf;
     }
 
+    public void notifyEntryCreated(NodeEntry entry) {
+        listener.entryCreated(entry);
+    }
 
     public void notifyIdChange(NodeEntry entry, String previousUniqueID) {
         listener.uniqueIdChanged(entry, previousUniqueID);
@@ -75,6 +78,8 @@
 
     //--------------------------------------------------------------------------
     public interface NodeEntryListener {
+
+        public void entryCreated(NodeEntry entry);
 
         public void uniqueIdChanged (NodeEntry entry, String previousUniqueID);
     }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java?view=diff&rev=515167&r1=515166&r2=515167
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
Tue Mar  6 07:53:51 2007
@@ -117,6 +117,8 @@
         super(parent, name, factory);
         this.uniqueID = uniqueID; // NOTE: don't use setUniqueID (for mod only)
         this.childNodeAttic = new ChildNodeAttic();
+
+        factory.notifyEntryCreated(this);
     }
 
     /**
@@ -1091,7 +1093,7 @@
             ItemState state = internalGetItemState();
             if (state == null || state.getStatus() != Status.NEW) {
                 try {
-                    NodeId id = (NodeId) getWorkspaceId();
+                    NodeId id = getWorkspaceId();
                     Iterator it = factory.getItemStateFactory().getChildNodeInfos(id);
                     while (it.hasNext()) {
                         ChildInfo ci = (ChildInfo) it.next();

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/UniqueIdResolver.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/UniqueIdResolver.java?view=diff&rev=515167&r1=515166&r2=515167
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/UniqueIdResolver.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/UniqueIdResolver.java
Tue Mar  6 07:53:51 2007
@@ -123,7 +123,19 @@
 
     //-------------------------------------< EntryFactory.NodeEntryListener >---
     /**
-     * @param entry
+     * @see EntryFactory.NodeEntryListener#entryCreated(NodeEntry)
+     */
+    public void entryCreated(NodeEntry entry) {
+        String uniqueID = entry.getUniqueID();
+        if (uniqueID != null) {
+            Object previous = lookUp.put(uniqueID, entry);
+            if (previous != null) {
+                ((NodeEntry) previous).remove();
+            }
+        }
+    }
+
+    /**
      * @see EntryFactory.NodeEntryListener#uniqueIdChanged(NodeEntry, String)
      */
     public void uniqueIdChanged(NodeEntry entry, String previousUniqueID) {
@@ -133,7 +145,11 @@
             }
             String uniqueID = entry.getUniqueID();
             if (uniqueID != null) {
-                lookUp.put(uniqueID, entry);
+                Object previous = lookUp.put(uniqueID, entry);
+                if (previous != null && previous != entry) {
+                    // some other entry existed before with the same uniqueID
+                    ((NodeEntry) previous).remove();
+                }
             }
         }
     }

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?view=diff&rev=515167&r1=515166&r2=515167
==============================================================================
--- 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
Tue Mar  6 07:53:51 2007
@@ -27,6 +27,7 @@
 import org.apache.jackrabbit.spi.RepositoryService;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.ItemInfo;
 import org.apache.jackrabbit.jcr2spi.WorkspaceManager;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry;
@@ -252,7 +253,9 @@
      * @param entry
      * @return the new <code>NodeState</code>.
      */
-    private NodeState createNodeState(NodeInfo info, NodeEntry entry) {
+    private NodeState createNodeState(NodeInfo info, NodeEntry entry) throws NoSuchItemStateException,
RepositoryException {
+        assertMatchingPath(info, entry);
+
         // make sure the entry has the correct ItemId
         // this make not be the case, if the hierachy has not been completely
         // resolved yet -> if uniqueID is present, set it on this entry or on
@@ -321,7 +324,9 @@
      * @param entry
      * @return the new <code>PropertyState</code>.
      */
-    private PropertyState createPropertyState(PropertyInfo info, PropertyEntry entry) {
+    private PropertyState createPropertyState(PropertyInfo info, PropertyEntry entry) throws
NoSuchItemStateException, RepositoryException {
+        assertMatchingPath(info, entry);
+
         // make sure uuid part of id is correct
         String uniqueID = info.getId().getUniqueID();
         if (uniqueID != null) {
@@ -359,6 +364,17 @@
         notifyCreated(state);
 
         return state;
+    }
+
+    /**
+     * Validation check: Path of the given ItemInfo must match to the Path of
+     * the HierarchyEntry. This is required for Items that are identified by
+     * a uniqueID that may move within the hierarchy upon restore or clone.
+     */
+    private void assertMatchingPath(ItemInfo info, HierarchyEntry entry) throws NoSuchItemStateException,
RepositoryException {
+        if (!info.getPath().equals(entry.getPath())) {
+            throw new NoSuchItemStateException("HierarchyEntry does not belong the given
ItemInfo.");
+        }
     }
 
     private static NodeEntry getAncestor(HierarchyEntry entry, int degree) {



Mime
View raw message