jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r293286 - in /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: nodetype/virtual/ state/ version/ virtual/
Date Mon, 03 Oct 2005 09:55:47 GMT
Author: tripod
Date: Mon Oct  3 02:55:40 2005
New Revision: 293286

URL: http://svn.apache.org/viewcvs?rev=293286&view=rev
Log:
JCR-234 - VersionTest.testGetUUID() fails
JCR-232 - jcr:baseVersion is not updated when the base version is removed from the version
history

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=293286&r1=293285&r2=293286&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
Mon Oct  3 02:55:40 2005
@@ -26,6 +26,7 @@
 import org.apache.jackrabbit.core.nodetype.ValueConstraint;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
+import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.virtual.AbstractVISProvider;
 import org.apache.jackrabbit.core.virtual.VirtualNodeState;
@@ -268,5 +269,12 @@
         } catch (UnsupportedEncodingException e) {
             throw new RepositoryException(e);
         }
+    }
+
+    /**
+     * @inheritDoc
+     */ 
+    public boolean setNodeReferences(NodeReferences refs) {
+        return false;
     }
 }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=293286&r1=293285&r2=293286&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Mon Oct  3 02:55:40 2005
@@ -35,6 +35,7 @@
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.io.PrintStream;
 
 import EDU.oswego.cs.dl.util.concurrent.ReadWriteLock;
@@ -327,6 +328,10 @@
 
         ChangeLog shared = new ChangeLog();
 
+        // set of virtual node references
+        // todo: remember by provider
+        LinkedList virtualRefs = new LinkedList();
+
         EventStateCollection events = null;
         if (obsMgr != null) {
             events = obsMgr.createEventStateCollection();
@@ -345,14 +350,25 @@
             while (iter.hasNext()) {
                 NodeReferences refs = (NodeReferences) iter.next();
                 NodeId id = new NodeId(refs.getUUID());
-                if (refs.hasReferences()) {
-                    if (!local.has(id) && !hasItemState(id)) {
-                        String msg = "Target node " + id
-                                + " of REFERENCE property does not exist";
-                        throw new ItemStateException(msg);
+                // if targetid is in virtual provider, transfer to its modified set
+                for (int i = 0; i < virtualProviders.length; i++) {
+                    VirtualItemStateProvider provider = virtualProviders[i];
+                    if (provider.hasItemState(id)) {
+                        virtualRefs.add(refs);
+                        refs = null;
+                        break;
                     }
                 }
-                shared.modified(refs);
+                if (refs != null) {
+                    if (refs.hasReferences()) {
+                        if (!local.has(id) && !hasItemState(id)) {
+                            String msg = "Target node " + id
+                                    + " of REFERENCE property does not exist";
+                            throw new ItemStateException(msg);
+                        }
+                    }
+                    shared.modified(refs);
+                }
             }
 
             boolean succeeded = false;
@@ -447,6 +463,17 @@
 
             /* Let the shared item listeners know about the change */
             shared.persisted();
+
+            /* notify virtual providers about node references */
+            iter = virtualRefs.iterator();
+            while (iter.hasNext()) {
+                NodeReferences refs = (NodeReferences) iter.next();
+                for (int i = 0; i < virtualProviders.length; i++) {
+                    if (virtualProviders[i].setNodeReferences(refs)) {
+                    break;
+                    }
+                }
+            }
 
             // downgrade to read lock
             acquireReadLock();

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java?rev=293286&r1=293285&r2=293286&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
Mon Oct  3 02:55:40 2005
@@ -19,6 +19,7 @@
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.core.ItemId;
 import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
@@ -146,10 +147,30 @@
     }
 
     /**
+     * called by the version manager when a dynamic property needs to be
+     * invalidated.
+     *
+     * @param id
+     */
+    synchronized void onPropertyChanged(PropertyId id) {
+        ItemState item = (ItemState) items.get(id);
+        if (item != null) {
+            item.discard();
+        }
+    }
+
+    /**
+     * @inheritDoc
+     */ 
+    public boolean setNodeReferences(NodeReferences refs) {
+        return vMgr.setNodeReferences(refs);
+    }
+
+    /**
      * @inheritDoc
      */
     public boolean hasItemState(ItemId id) {
-        return stateMgr.hasItemState(id);
+        return items.get(id) != null || stateMgr.hasItemState(id);
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=293286&r1=293285&r2=293286&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Mon Oct  3 02:55:40 2005
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core.version;
 
 import org.apache.commons.collections.map.ReferenceMap;
-import org.apache.jackrabbit.core.ItemId;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.PropertyId;
@@ -28,7 +27,6 @@
 import org.apache.jackrabbit.core.observation.DelegatingObservationDispatcher;
 import org.apache.jackrabbit.core.observation.EventState;
 import org.apache.jackrabbit.core.state.ChangeLog;
-import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
 import org.apache.jackrabbit.core.state.NodeReferences;
@@ -107,7 +105,7 @@
     /**
      * Map of returned items. this is kept for invalidating
      */
-    private ReferenceMap items = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK);
+    //private ReferenceMap items = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK);
 
     /**
      * Map of returned items. this is kept for invalidating
@@ -414,20 +412,20 @@
     public synchronized Version checkin(NodeImpl node) throws RepositoryException {
         SessionImpl session = (SessionImpl) node.getSession();
         InternalVersion version = internalCheckin(node);
-        // need to recalc successor prop
-        InternalVersion[] preds = version.getPredecessors();
-        for (int i=0; i<preds.length; i++) {
-            ItemState state = (ItemState) items.remove(new PropertyId(preds[i].getId(), QName.JCR_SUCCESSORS));
-            if (state != null) {
-                state.discard();
-            }
-        }
-        invalidateItem(new NodeId(version.getVersionHistory().getId()), true);
+
         VersionImpl v = (VersionImpl) session.getNodeByUUID(version.getId());
 
         // generate observation events
         List events = new ArrayList();
+
         generateAddedEvents(events, (NodeImpl) v.getParent(), v, true);
+
+        // invalidate predecessors successor property
+        InternalVersion[] preds = version.getPredecessors();
+        for (int i=0; i<preds.length; i++) {
+            PropertyId propId = new PropertyId(preds[i].getId(), QName.JCR_SUCCESSORS);
+            versProvider.onPropertyChanged(propId);
+        }
         obsMgr.dispatch(events, session);
 
         return v;
@@ -557,7 +555,12 @@
             }
         }
 
-        invalidateItem(new NodeId(vh.getId()), true);
+        // invalidate predecessors successor properties
+        InternalVersion preds[] = version.getInternalVersion().getPredecessors();
+        for (int i=0; i<preds.length; i++) {
+            PropertyId propId = new PropertyId(preds[i].getId(), QName.JCR_SUCCESSORS);
+            versProvider.onPropertyChanged(propId);
+        }
         obsMgr.dispatch(events, session);
     }
 
@@ -623,7 +626,6 @@
                     labelNode.getSession()
             ));
         }
-        invalidateItem(new NodeId(labelNode.internalGetUUID()), true);
         obsMgr.dispatch(events, session);
         if (v == null) {
             return null;
@@ -702,6 +704,17 @@
         }
     }
 
+    public boolean setNodeReferences(NodeReferences refs) {
+        try {
+            InternalVersionItem item = getItem(refs.getTargetId().getUUID());
+            setItemReferences(item, refs.getReferences());
+            return true;
+        } catch (RepositoryException e) {
+            log.error("Error while setting references: " + e.toString());
+            return false;
+        }
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -745,32 +758,6 @@
             log.error("Error while storing", e);
         }
     }
-
-    /**
-     * invalidates the item
-     *
-     * @param id
-     */
-    private void invalidateItem(ItemId id, boolean recursive) {
-        ItemState state = (ItemState) items.get(id);
-        if (state != null) {
-            if (recursive && state instanceof NodeState) {
-                NodeState nState = (NodeState) state;
-                Iterator iter = nState.getPropertyNames().iterator();
-                while (iter.hasNext()) {
-                    QName propName = (QName) iter.next();
-                    invalidateItem(new PropertyId(nState.getUUID(), propName), false);
-                }
-                iter = nState.getChildNodeEntries().iterator();
-                while (iter.hasNext()) {
-                    NodeState.ChildNodeEntry pe = (NodeState.ChildNodeEntry) iter.next();
-                    invalidateItem(new NodeId(pe.getUUID()), true);
-                }
-            }
-            state.notifyStateUpdated();
-        }
-    }
-
 
     /**
      * returns the id of the version history root node

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java?rev=293286&r1=293285&r2=293286&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
Mon Oct  3 02:55:40 2005
@@ -20,6 +20,7 @@
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.state.ItemStateListener;
 import org.apache.jackrabbit.core.state.ItemStateManager;
+import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.name.QName;
 
 import javax.jcr.RepositoryException;
@@ -72,5 +73,14 @@
     VirtualNodeState createNodeState(VirtualNodeState parent, QName name,
                                             String uuid, QName nodeTypeName)
             throws RepositoryException;
+
+    /**
+     * Informs this provider that the node references to one of its states has
+     * changed.
+     *
+     * @param refs
+     * @return <code>true</code> if the reference target is one of its items.
+     */
+    boolean setNodeReferences(NodeReferences refs);
 
 }



Mime
View raw message