jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r650317 - in /jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version: AbstractVersionManager.java InternalVersion.java InternalVersionImpl.java VersionManagerImpl.java XAVersionManager.java
Date Mon, 21 Apr 2008 23:42:53 GMT
Author: jukka
Date: Mon Apr 21 16:42:52 2008
New Revision: 650317

URL: http://svn.apache.org/viewvc?rev=650317&view=rev
Log:
1.4: Merged revision 638303 (JCR-1476, without tests)

Modified:
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersion.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java?rev=650317&r1=650316&r2=650317&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
Mon Apr 21 16:42:52 2008
@@ -21,6 +21,7 @@
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.LocalItemStateManager;
 import org.apache.jackrabbit.core.state.NodeState;
@@ -59,6 +60,11 @@
     protected LocalItemStateManager stateMgr;
 
     /**
+     * Node type registry.
+     */
+    protected final NodeTypeRegistry ntReg;
+
+    /**
      * Persistent root node of the version histories.
      */
     protected NodeStateEx historyRoot;
@@ -78,6 +84,10 @@
                 }
             };
 
+    public AbstractVersionManager(NodeTypeRegistry ntReg) {
+        this.ntReg = ntReg;
+    }
+
     //-------------------------------------------------------< VersionManager >
 
     /**
@@ -528,5 +538,43 @@
      * @param item
      */
     protected void itemDiscarded(InternalVersionItem item) {
+    }
+
+    /**
+     * Creates an {@link InternalVersionItem} based on the {@link NodeState}
+     * identified by <code>id</code>.
+     *
+     * @param id    the node id of the version item.
+     * @return the version item or <code>null</code> if there is no node state
+     *         with the given <code>id</code>.
+     * @throws RepositoryException if an error occurs while reading from the
+     *                             version storage.
+     */
+    protected InternalVersionItem createInternalVersionItem(NodeId id)
+            throws RepositoryException {
+        try {
+            if (stateMgr.hasItemState(id)) {
+                NodeState state = (NodeState) stateMgr.getItemState(id);
+                NodeStateEx pNode = new NodeStateEx(stateMgr, ntReg, state, null);
+                NodeId parentId = pNode.getParentId();
+                InternalVersionItem parent = getItem(parentId);
+                Name ntName = state.getNodeTypeName();
+                if (ntName.equals(NameConstants.NT_FROZENNODE)) {
+                    return new InternalFrozenNodeImpl(this, pNode, parent);
+                } else if (ntName.equals(NameConstants.NT_VERSIONEDCHILD)) {
+                    return new InternalFrozenVHImpl(this, pNode, parent);
+                } else if (ntName.equals(NameConstants.NT_VERSION)) {
+                    return ((InternalVersionHistory) parent).getVersion(id);
+                } else if (ntName.equals(NameConstants.NT_VERSIONHISTORY)) {
+                    return new InternalVersionHistoryImpl(this, pNode);
+                } else {
+                    return null;
+                }
+            } else {
+                return null;
+            }
+        } catch (ItemStateException e) {
+            throw new RepositoryException(e);
+        }
     }
 }

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersion.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersion.java?rev=650317&r1=650316&r2=650317&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersion.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersion.java
Mon Apr 21 16:42:52 2008
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.core.version;
 
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.core.NodeId;
 
 import javax.jcr.version.Version;
 import java.util.Calendar;
@@ -40,6 +41,13 @@
      * @return the frozen node.
      */
     InternalFrozenNode getFrozenNode();
+
+    /**
+     * Returns the node id of the frozen node.
+     *
+     * @return the node id of the frozen node;
+     */
+    NodeId getFrozenNodeId();
 
     /**
      * Equivalent to {@link Version#getCreated()}

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java?rev=650317&r1=650316&r2=650317&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
Mon Apr 21 16:42:52 2008
@@ -108,14 +108,21 @@
     public InternalFrozenNode getFrozenNode() {
         // get frozen node
         try {
-            NodeState.ChildNodeEntry entry = node.getState().getChildNodeEntry(NameConstants.JCR_FROZENNODE,
1);
-            if (entry == null) {
-                throw new InternalError("version has no frozen node: " + getId());
-            }
-            return (InternalFrozenNode) vMgr.getItem(entry.getId());
+            return (InternalFrozenNode) vMgr.getItem(getFrozenNodeId());
         } catch (RepositoryException e) {
             throw new IllegalStateException("unable to retrieve frozen node: " + e);
         }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public NodeId getFrozenNodeId() {
+        NodeState.ChildNodeEntry entry = node.getState().getChildNodeEntry(NameConstants.JCR_FROZENNODE,
1);
+        if (entry == null) {
+            throw new InternalError("version has no frozen node: " + getId());
+        }
+        return entry.getId();
     }
 
     /**

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=650317&r1=650316&r2=650317&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Mon Apr 21 16:42:52 2008
@@ -112,11 +112,6 @@
     private final VersionItemStateProvider versProvider;
 
     /**
-     * the node type manager
-     */
-    private NodeTypeRegistry ntReg;
-
-    /**
      * the dynamic event state collection factory
      */
     private final DynamicESCFactory escFactory;
@@ -136,10 +131,10 @@
                               NodeId rootParentId,
                               ItemStateCacheFactory cacheFactory,
                               ISMLocking ismLocking) throws RepositoryException {
+        super(ntReg);
         try {
             this.pMgr = pMgr;
             this.fs = fs;
-            this.ntReg = ntReg;
             this.escFactory = new DynamicESCFactory(obsMgr);
 
             // need to store the version storage root directly into the persistence manager
@@ -257,37 +252,20 @@
             synchronized (versionItems) {
                 InternalVersionItem item = (InternalVersionItem) versionItems.get(id);
                 if (item == null) {
-                    if (stateMgr.hasItemState(id)) {
-                        NodeState state = (NodeState) stateMgr.getItemState(id);
-                        NodeStateEx pNode = new NodeStateEx(stateMgr, ntReg, state, null);
-                        NodeId parentId = pNode.getParentId();
-                        InternalVersionItem parent = getItem(parentId);
-                        Name ntName = state.getNodeTypeName();
-                        if (ntName.equals(NameConstants.NT_FROZENNODE)) {
-                            item = new InternalFrozenNodeImpl(this, pNode, parent);
-                        } else if (ntName.equals(NameConstants.NT_VERSIONEDCHILD)) {
-                            item = new InternalFrozenVHImpl(this, pNode, parent);
-                        } else if (ntName.equals(NameConstants.NT_VERSION)) {
-                            item = ((InternalVersionHistory) parent).getVersion(id);
-                        } else if (ntName.equals(NameConstants.NT_VERSIONHISTORY)) {
-                            item = new InternalVersionHistoryImpl(this, pNode);
-                        } else {
-                            return null;
-                        }
+                    item = createInternalVersionItem(id);
+                    if (item != null) {
+                        versionItems.put(id, item);
                     } else {
                         return null;
                     }
-                    versionItems.put(id, item);
                 }
                 return item;
             }
-        } catch (ItemStateException e) {
-            throw new RepositoryException(e);
         } finally {
             releaseReadLock();
         }
     }
-
+    
     /**
      * {@inheritDoc}
      * <p/>

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java?rev=650317&r1=650316&r2=650317&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
Mon Apr 21 16:42:52 2008
@@ -75,11 +75,6 @@
     private final VersionManagerImpl vMgr;
 
     /**
-     * Node type registry.
-     */
-    private NodeTypeRegistry ntReg;
-
-    /**
      * The session that uses this version manager.
      */
     private SessionImpl session;
@@ -100,9 +95,8 @@
     public XAVersionManager(VersionManagerImpl vMgr, NodeTypeRegistry ntReg,
                             SessionImpl session, ItemStateCacheFactory cacheFactory)
             throws RepositoryException {
-
+        super(ntReg);
         this.vMgr = vMgr;
-        this.ntReg = ntReg;
         this.session = session;
         this.stateMgr = new XAItemStateManager(vMgr.getSharedStateMgr(),
                 this, CHANGE_LOG_ATTRIBUTE_NAME, cacheFactory);
@@ -366,7 +360,13 @@
             history = makeLocalCopy(history);
             xaItems.put(history.getId(), history);
         }
-        return super.checkin(history, node);
+        InternalVersion version = super.checkin(history, node);
+        NodeId frozenNodeId = version.getFrozenNodeId();
+        InternalVersionItem frozenNode = createInternalVersionItem(frozenNodeId);
+        if (frozenNode != null) {
+            xaItems.put(frozenNodeId, frozenNode);
+        }
+        return version;
     }
 
     /**



Mime
View raw message