jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1186802 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: RepositoryChecker.java version/InternalVersionManagerBase.java
Date Thu, 20 Oct 2011 13:46:42 GMT
Author: reschke
Date: Thu Oct 20 13:46:42 2011
New Revision: 1186802

URL: http://svn.apache.org/viewvc?rev=1186802&view=rev
Log:
JCR-3115: Versioning fixup leaves persistence in a state where the node can't be made versionable
again

Extend checker so that it gets the same VersionHistoryInfo object that other code gets when
versioning gets enabled again.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java?rev=1186802&r1=1186801&r2=1186802&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java
Thu Oct 20 13:46:42 2011
@@ -41,6 +41,7 @@ import org.apache.jackrabbit.core.versio
 import org.apache.jackrabbit.core.version.InternalVersion;
 import org.apache.jackrabbit.core.version.InternalVersionHistory;
 import org.apache.jackrabbit.core.version.InternalVersionManagerImpl;
+import org.apache.jackrabbit.core.version.VersionHistoryInfo;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NameFactory;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
@@ -129,14 +130,23 @@ class RepositoryChecker {
             try {
                 log.debug("Checking version history of node {}", nid);
 
-                message = "Removing references to a missing version history of node " + nid;
+                String intro = "Removing references to an inconsistent version history of
node "
+                    + nid;
+
+                message = intro + " (getting the VersionInfo)";
+                VersionHistoryInfo vhi = versionManager.getVersionHistoryInfoForNode(node);
+                if (vhi != null) {
+                    // get the version history's node ID as early as possible
+                    // so we can attempt a fixup even when the next call fails
+                    vhid = vhi.getVersionHistoryId();
+                }
+
+                message = intro + " (getting the InternalVersionHistory)";
                 InternalVersionHistory vh = versionManager.getVersionHistoryOfNode(nid);
 
                 vhid = vh.getId();
                 
                 // additional checks, see JCR-3101
-                String intro = "Removing references to an inconsistent version history of
node "
-                    + nid;
 
                 message = intro + " (getting the version names failed)";
                 Name[] versionNames = vh.getVersionNames();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java?rev=1186802&r1=1186801&r2=1186802&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
Thu Oct 20 13:46:42 2011
@@ -305,11 +305,14 @@ abstract class InternalVersionManagerBas
     }
 
     /**
-     * {@inheritDoc}
+     * Returns information about the version history of the specified node
+     * or <code>null</code> when unavailable.
+     *
+     * @param vNode node whose version history should be returned
+     * @return identifiers of the version history and root version nodes
+     * @throws RepositoryException if an error occurs
      */
-    public VersionHistoryInfo getVersionHistory(Session session, NodeState node,
-                                                NodeId copiedFrom)
-            throws RepositoryException {
+    public VersionHistoryInfo getVersionHistoryInfoForNode(NodeState node) throws RepositoryException
{
         VersionHistoryInfo info = null;
 
         VersioningLock.ReadLock lock = acquireReadLock();
@@ -335,6 +338,17 @@ abstract class InternalVersionManagerBas
             lock.release();
         }
 
+        return info;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public VersionHistoryInfo getVersionHistory(Session session, NodeState node,
+                                                NodeId copiedFrom)
+            throws RepositoryException {
+        VersionHistoryInfo info = getVersionHistoryInfoForNode(node);
+
         if (info == null) {
             info = createVersionHistory(session, node, copiedFrom);
         }



Mime
View raw message