jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r581168 - in /jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version: VersionItemStateManager.java VersionItemStateProvider.java VersionManagerImpl.java
Date Tue, 02 Oct 2007 09:27:28 GMT
Author: jukka
Date: Tue Oct  2 02:27:27 2007
New Revision: 581168

URL: http://svn.apache.org/viewvc?rev=581168&view=rev
Log:
1.3: Merged revision 550466 (JCR-978)

Added:
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateManager.java
      - copied unchanged from r550466, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateManager.java
Modified:
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
    jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java?rev=581168&r1=581167&r2=581168&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
Tue Oct  2 02:27:27 2007
@@ -25,7 +25,6 @@
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.state.NodeReferencesId;
-import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.core.virtual.VirtualNodeState;
 import org.apache.jackrabbit.core.virtual.VirtualPropertyState;
@@ -39,11 +38,6 @@
 class VersionItemStateProvider implements VirtualItemStateProvider, ItemStateListener {
 
     /**
-     * The version manager
-     */
-    private final VersionManagerImpl vMgr;
-
-    /**
      * The root node UUID for the version storage
      */
     private final NodeId historyRootId;
@@ -51,7 +45,7 @@
     /**
      * The item state manager directly on the version persistence mgr
      */
-    private final SharedItemStateManager stateMgr;
+    private final VersionItemStateManager stateMgr;
 
     /**
      * Map of returned items. this is kept for invalidating
@@ -59,13 +53,13 @@
     private ReferenceMap items = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK);
 
     /**
-     * Creates a bew vesuion manager
+     * Creates a new version manager
      *
      */
-    public VersionItemStateProvider(VersionManagerImpl vMgr, SharedItemStateManager stateMgr)
{
-        this.vMgr = vMgr;
+    public VersionItemStateProvider(NodeId historyRootId,
+                                    VersionItemStateManager stateMgr) {
+        this.historyRootId = historyRootId;
         this.stateMgr = stateMgr;
-        this.historyRootId = vMgr.getHistoryRootId();
 
         stateMgr.addListener(this);
     }
@@ -122,7 +116,7 @@
      * @inheritDoc
      */
     public boolean setNodeReferences(NodeReferences refs) {
-        return vMgr.setNodeReferences(refs);
+        return stateMgr.setNodeReferences(refs);
     }
 
     /**

Modified: jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=581168&r1=581167&r2=581168&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Tue Oct  2 02:27:27 2007
@@ -54,7 +54,6 @@
 import java.util.List;
 
 import javax.jcr.PropertyType;
-import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.version.Version;
@@ -100,9 +99,9 @@
     private final FileSystem fs;
 
     /**
-     * the shared state manager for the version storage
+     * the version state manager for the version storage
      */
-    private SharedItemStateManager sharedStateMgr;
+    private VersionItemStateManager sharedStateMgr;
 
     /**
      * the virtual item state provider that exposes the version storage
@@ -158,7 +157,7 @@
                 cl.added(pt);
                 pMgr.store(cl);
             }
-            sharedStateMgr = createSharedStateManager(pMgr, rootId, ntReg, cacheFactory);
+            sharedStateMgr = createItemStateManager(pMgr, rootId, ntReg, cacheFactory);
 
             stateMgr = new LocalItemStateManager(sharedStateMgr, escFactory, cacheFactory);
             stateMgr.addListener(this);
@@ -167,7 +166,8 @@
             historyRoot = new NodeStateEx(stateMgr, ntReg, nodeState, QName.JCR_VERSIONSTORAGE);
 
             // create the virtual item state provider
-            versProvider = new VersionItemStateProvider(this, sharedStateMgr);
+            versProvider = new VersionItemStateProvider(
+                    getHistoryRootId(), sharedStateMgr);
 
         } catch (ItemStateException e) {
             throw new RepositoryException(e);
@@ -405,47 +405,15 @@
     }
 
     /**
-     * Sets and stored the node references from external nodes.
-     * @param references
-     * @return <code>true</code> if the references could be set.
-     */
-    public boolean setNodeReferences(NodeReferences references) {
-        acquireWriteLock();
-        try {
-            // filter out version storage intern ones
-            NodeReferences refs = new NodeReferences(references.getId());
-            Iterator iter = references.getReferences().iterator();
-            while (iter.hasNext()) {
-                PropertyId id = (PropertyId) iter.next();
-                if (!hasItem(id.getParentId())) {
-                    refs.addReference(id);
-                }
-            }
-
-            ChangeLog log = new ChangeLog();
-            log.modified(refs);
-            pMgr.store(log);
-            return true;
-        } catch (ItemStateException e) {
-            log.error("Error while setting references: " + e.toString());
-            return false;
-        } finally {
-            releaseWriteLock();
-        }
-    }
-
-    /**
      * {@inheritDoc}
      */
     protected List getItemReferences(InternalVersionItem item) {
-        acquireReadLock();
         try {
-            NodeReferences refs = pMgr.load(new NodeReferencesId(item.getId()));
+            NodeReferences refs = stateMgr.getNodeReferences(
+                    new NodeReferencesId(item.getId()));
             return refs.getReferences();
         } catch (ItemStateException e) {
             return Collections.EMPTY_LIST;
-        } finally {
-            releaseReadLock();
         }
     }
 
@@ -466,7 +434,7 @@
     }
 
     /**
-     * Creates a <code>SharedItemStateManager</code> or derivative.
+     * Creates a <code>VersionItemStateManager</code> or derivative.
      *
      * @param pMgr          persistence manager
      * @param rootId        root node id
@@ -475,12 +443,11 @@
      * @return item state manager
      * @throws ItemStateException if an error occurs
      */
-    protected SharedItemStateManager createSharedStateManager(PersistenceManager pMgr,
-                                                              NodeId rootId,
-                                                              NodeTypeRegistry ntReg,
-                                                              ItemStateCacheFactory cacheFactory)
+    protected VersionItemStateManager createItemStateManager(PersistenceManager pMgr,
+                                                             NodeId rootId,
+                                                             NodeTypeRegistry ntReg,
+                                                             ItemStateCacheFactory cacheFactory)
             throws ItemStateException {
-
         return new VersionItemStateManager(pMgr, rootId, ntReg, cacheFactory);
     }
 
@@ -533,39 +500,6 @@
     }
 
     //--------------------------------------------------------< inner classes >
-    /**
-     * Spezialized SharedItemStateManager that filters out NodeReferences to
-     * non-versioning states.
-     */
-    protected class VersionItemStateManager extends SharedItemStateManager {
-
-        public VersionItemStateManager(PersistenceManager persistMgr,
-                                       NodeId rootNodeId,
-                                       NodeTypeRegistry ntReg,
-                                       ItemStateCacheFactory cacheFactory)
-                throws ItemStateException {
-            super(persistMgr, rootNodeId, ntReg, false, cacheFactory);
-        }
-
-        protected void checkReferentialIntegrity(ChangeLog changes)
-                throws ReferentialIntegrityException, ItemStateException {
-            // only store VV-type references and NV-type references
-
-            // check whether targets of modified node references exist
-            for (Iterator iter = changes.modifiedRefs(); iter.hasNext();) {
-                NodeReferences refs = (NodeReferences) iter.next();
-                NodeId id = refs.getTargetId();
-                // no need to check existence of target if there are no references
-                if (refs.hasReferences()) {
-                    if (!changes.has(id) && !hasItemState(id)) {
-                        // remove references
-                        iter.remove();
-                    }
-                }
-            }
-        }
-
-    }
 
     public static final class DynamicESCFactory implements EventStateCollectionFactory {
 



Mime
View raw message