jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r920982 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java
Date Tue, 09 Mar 2010 16:57:16 GMT
Author: jukka
Date: Tue Mar  9 16:57:15 2010
New Revision: 920982

URL: http://svn.apache.org/viewvc?rev=920982&view=rev
Log:
JCR-2551: Recovery from a lost version history

Use proper logging in RepositoryChecker. Also remove the jcr:isCheckedOut property when fixing
a broken version history reference.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.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=920982&r1=920981&r2=920982&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
Tue Mar  9 16:57:15 2010
@@ -16,7 +16,9 @@
  */
 package org.apache.jackrabbit.core;
 
+import static org.apache.jackrabbit.core.RepositoryImpl.SYSTEM_ROOT_NODE_ID;
 import static org.apache.jackrabbit.spi.commons.name.NameConstants.JCR_BASEVERSION;
+import static org.apache.jackrabbit.spi.commons.name.NameConstants.JCR_ISCHECKEDOUT;
 import static org.apache.jackrabbit.spi.commons.name.NameConstants.JCR_PREDECESSORS;
 import static org.apache.jackrabbit.spi.commons.name.NameConstants.JCR_VERSIONHISTORY;
 import static org.apache.jackrabbit.spi.commons.name.NameConstants.MIX_VERSIONABLE;
@@ -35,6 +37,8 @@ import org.apache.jackrabbit.core.state.
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.version.InternalVersionManager;
 import org.apache.jackrabbit.spi.Name;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Tool for checking for and optionally fixing consistency issues in a
@@ -44,6 +48,12 @@ import org.apache.jackrabbit.spi.Name;
  */
 class RepositoryChecker {
 
+    /**
+     * Logger instance.
+     */
+    private static final Logger log =
+        LoggerFactory.getLogger(RepositoryChecker.class);
+
     private final PersistenceManager workspace;
 
     private final ChangeLog workspaceChanges;
@@ -61,12 +71,13 @@ class RepositoryChecker {
     public void check(NodeId id, boolean recurse)
             throws RepositoryException {
         try {
+            log.debug("Checking consistency of node {}", id);
             NodeState state = workspace.load(id);
             checkVersionHistory(state);
 
             if (recurse) {
                 for (ChildNodeEntry child : state.getChildNodeEntries()) {
-                    if (child.getId() != RepositoryImpl.SYSTEM_ROOT_NODE_ID) {
+                    if (!SYSTEM_ROOT_NODE_ID.equals(child.getId())) {
                         check(child.getId(), recurse);
                     }
                 }
@@ -77,9 +88,8 @@ class RepositoryChecker {
     }
 
     public void fix() throws RepositoryException {
-        System.out.println("Fixing workspace issues");
         if (workspaceChanges.hasUpdates()) {
-            System.out.println("... workspace has issues");
+            log.warn("Fixing repository inconsistencies");
             try {
                 workspace.store(workspaceChanges);
             } catch (ItemStateException e) {
@@ -87,16 +97,18 @@ class RepositoryChecker {
                 throw new RepositoryException(
                         "Failed to fix workspace inconsistencies", e);
             }
+        } else {
+            log.info("No repository inconcistencies found");
         }
     }
 
     private void checkVersionHistory(NodeState node) {
         if (node.hasPropertyName(JCR_VERSIONHISTORY)) {
-            System.out.println("Checking version history of node " + node.getNodeId());
+            log.debug("Checking version history of node {}", node.getNodeId());
             try {
                 versionManager.getVersionHistoryOfNode(node.getNodeId());
             } catch (Exception e) {
-                e.printStackTrace();
+                log.info("Removing references to a missing version history", e);
                 removeVersionHistoryReferences(node);
             }
         }
@@ -114,6 +126,7 @@ class RepositoryChecker {
         removeProperty(modified, JCR_VERSIONHISTORY);
         removeProperty(modified, JCR_BASEVERSION);
         removeProperty(modified, JCR_PREDECESSORS);
+        removeProperty(modified, JCR_ISCHECKEDOUT);
 
         workspaceChanges.modified(modified);
     }



Mime
View raw message