jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject svn commit: r1439927 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence: bundle/ConsistencyCheckerImpl.java check/ReportItem.java check/ReportItemImpl.java
Date Tue, 29 Jan 2013 15:22:04 GMT
Author: unico
Date: Tue Jan 29 15:21:54 2013
New Revision: 1439927

URL: http://svn.apache.org/viewvc?rev=1439927&view=rev
Log:
JCR-3277 Add consistency type information to consistency report items

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/ConsistencyCheckerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItemImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/ConsistencyCheckerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/ConsistencyCheckerImpl.java?rev=1439927&r1=1439926&r2=1439927&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/ConsistencyCheckerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/ConsistencyCheckerImpl.java
Tue Jan 29 15:21:54 2013
@@ -257,7 +257,6 @@ public class ConsistencyCheckerImpl {
                 NodePropBundle childBundle = null;
                 NodeInfo childNodeInfo = infos.get(childNodeId);
 
-                String message = null;
                 // does the child exist?
                 if (childNodeInfo == null) {
                     // try to load the bundle
@@ -277,8 +276,9 @@ public class ConsistencyCheckerImpl {
                                 }
                             }
                             if (childNodeEntry != null) {
-                                message = "NodeState '" + id + "' references inexistent child
'" + childNodeId + "'";
+                                String message = "NodeState '" + id + "' references inexistent
child '" + childNodeId + "'";
                                 log.error(message);
+                                addMessage(reports, childNodeId, message, ReportItem.Type.MISSING);
                                 missingChildren.add(childNodeEntry);
                             }
                         } else {
@@ -313,8 +313,9 @@ public class ConsistencyCheckerImpl {
                                 }
                                 if (childNodeEntry != null) {
                                     // indeed we have a disconnected child
-                                    message = "ChildNode has invalid parent id: '" + cp +
"' (instead of '" + id + "')";
+                                    String message = "Node has invalid parent id: '" + cp
+ "' (instead of '" + id + "')";
                                     log.error(message);
+                                    addMessage(reports, childNodeId, message, ReportItem.Type.DISCONNECTED);
                                     disconnectedChildren.add(childNodeEntry);
                                 }
                             } else {
@@ -324,13 +325,10 @@ public class ConsistencyCheckerImpl {
                         }
                     }
                 }
-                if (message != null) {
-                    addMessage(reports, id, message);
-                }
             } catch (ItemStateException e) {
                 // problem already logged (loadBundle called with
                 // logDetailedErrors=true)
-                addMessage(reports, id, e.getMessage());
+                addMessage(reports, id, e.getMessage(), ReportItem.Type.ERROR);
             }
         }
         // remove child node entry (if fixing is enabled)
@@ -367,7 +365,7 @@ public class ConsistencyCheckerImpl {
                                 // indeed we have an orphaned node
                                 String message = "NodeState '" + id + "' references inexistent
parent id '" + parentId + "'";
                                 log.error(message);
-                                addMessage(reports, id, message);
+                                addMessage(reports, id, message, ReportItem.Type.ORPHANED);
                                 if (fix && lostNFoundId != null) {
                                     // add a child to lost+found
                                     NodePropBundle lfBundle = pm.loadBundle(lostNFoundId);
@@ -425,7 +423,7 @@ public class ConsistencyCheckerImpl {
                                         + "' is not referenced by its parent node '"
                                         + parentId + "'";
                                 log.error(message);
-                                addMessage(reports, id, message);
+                                addMessage(reports, id, message, ReportItem.Type.ABANDONED);
                                 if (fix) {
                                     int l = (int) System.currentTimeMillis();
                                     int r = new Random().nextInt();
@@ -450,7 +448,7 @@ public class ConsistencyCheckerImpl {
             String message = "Error reading node '" + parentId
                     + "' (parent of '" + id + "'): " + e;
             log.error(message);
-            addMessage(reports, id, message);
+            addMessage(reports, id, message, ReportItem.Type.ERROR);
         }
     }
 
@@ -459,21 +457,18 @@ public class ConsistencyCheckerImpl {
      */
     private boolean isVirtualNode(NodeId id) {
         String s = id.toString();
-        if ("cafebabe-cafe-babe-cafe-babecafebabe".equals(s)) {
-            // root node isn't virtual
-            return false;
-        }
-        else {
-            // all other system nodes are
-            return s.endsWith("babecafebabe");
-        }
+        return !isRoot(s) && s.endsWith("babecafebabe");
+    }
+
+    private boolean isRoot(String id) {
+        return "cafebabe-cafe-babe-cafe-babecafebabe".equals(id);
     }
 
 
-    private void addMessage(Set<ReportItem> reports, NodeId id, String message) {
+    private void addMessage(Set<ReportItem> reports, NodeId id, String message, ReportItem.Type
type) {
 
         if (reports != null || listener != null) {
-            ReportItem ri = new ReportItemImpl(id.toString(), message);
+            ReportItem ri = new ReportItemImpl(id.toString(), message, type);
 
             if (reports != null) {
                 reports.add(ri);
@@ -520,4 +515,5 @@ public class ConsistencyCheckerImpl {
             log.error(pm + ": Error storing fixed bundle: " + e);
         }
     }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItem.java?rev=1439927&r1=1439926&r2=1439927&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItem.java
Tue Jan 29 15:21:54 2013
@@ -17,10 +17,14 @@
 package org.apache.jackrabbit.core.persistence.check;
 
 /**
- * An item reported inside a {@link ConsistencyChecker.Report}.
+ * An item reported inside a {@link ConsistencyReport}.
  */
 public interface ReportItem {
 
+    public enum Type {
+        ORPHANED, DISCONNECTED, ABANDONED, MISSING, ERROR
+    }
+
     /**
      * @return node id to which the message applies
      */
@@ -30,4 +34,10 @@ public interface ReportItem {
      * @return message
      */
     public String getMessage();
+
+    /**
+     * @return the type of inconsistency
+     */
+    public Type getType();
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItemImpl.java?rev=1439927&r1=1439926&r2=1439927&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItemImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/check/ReportItemImpl.java
Tue Jan 29 15:21:54 2013
@@ -20,10 +20,12 @@ public class ReportItemImpl implements R
 
     private final String nodeId;
     private final String message;
+    private final Type type;
 
-    public ReportItemImpl(String nodeId, String message) {
+    public ReportItemImpl(String nodeId, String message, Type type) {
         this.nodeId = nodeId;
         this.message = message;
+        this.type = type;
     }
 
     public String getNodeId() {
@@ -35,7 +37,12 @@ public class ReportItemImpl implements R
     }
 
     @Override
+    public Type getType() {
+        return type;
+    }
+
+    @Override
     public String toString() {
-        return nodeId + " -- " + message;
+        return type + ": " + nodeId + " -- " + message;
     }
 }



Mime
View raw message