jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1556277 - in /jackrabbit/branches/2.6: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java
Date Tue, 07 Jan 2014 17:05:23 GMT
Author: reschke
Date: Tue Jan  7 17:05:23 2014
New Revision: 1556277

URL: http://svn.apache.org/r1556277
Log:
JCR-3711: in RepositoryChecker, when removing mix:versionable also add mix:referenceable (ported
to 2.6)

Modified:
    jackrabbit/branches/2.6/   (props changed)
    jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java
    jackrabbit/branches/2.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java

Propchange: jackrabbit/branches/2.6/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1556248

Modified: jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java?rev=1556277&r1=1556276&r2=1556277&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryChecker.java
Tue Jan  7 17:05:23 2014
@@ -23,6 +23,7 @@ import static org.apache.jackrabbit.spi.
 import static org.apache.jackrabbit.spi.commons.name.NameConstants.JCR_ROOTVERSION;
 import static org.apache.jackrabbit.spi.commons.name.NameConstants.JCR_VERSIONHISTORY;
 import static org.apache.jackrabbit.spi.commons.name.NameConstants.MIX_VERSIONABLE;
+import static org.apache.jackrabbit.spi.commons.name.NameConstants.MIX_REFERENCEABLE;
 
 import java.util.Calendar;
 import java.util.HashSet;
@@ -180,7 +181,7 @@ class RepositoryChecker {
 
         try {
             String type = isVersioned ? "in-use" : "candidate";
-            
+
             log.debug("Checking " + type + " version history of node {}", nid);
 
             String intro = "Removing references to an inconsistent " + type
@@ -197,7 +198,7 @@ class RepositoryChecker {
             message = intro + " (getting the InternalVersionHistory)";
 
             InternalVersionHistory vh = null;
-            
+
             try {
                 vh = versionManager.getVersionHistoryOfNode(nid);
             }
@@ -215,7 +216,7 @@ class RepositoryChecker {
                 }
             } else { 
                 vhid = vh.getId();
-                
+
                 // additional checks, see JCR-3101
 
                 message = intro + " (getting the version names failed)";
@@ -269,6 +270,8 @@ class RepositoryChecker {
 
         Set<Name> mixins = new HashSet<Name>(node.getMixinTypeNames());
         if (mixins.remove(MIX_VERSIONABLE)) {
+            // we are keeping jcr:uuid, so we need to make sure the type info stays valid
+            mixins.add(MIX_REFERENCEABLE);
             modified.setMixinTypeNames(mixins);
         }
 
@@ -278,29 +281,29 @@ class RepositoryChecker {
         removeProperty(modified, JCR_ISCHECKEDOUT);
 
         workspaceChanges.modified(modified);
-        
+
         if (vhid != null) {
             // attempt to rename the version history, so it doesn't interfere with
             // a future attempt to put the node under version control again 
             // (see JCR-3115)
-            
+
             log.info("trying to rename version history of node " + node.getId());
 
             NameFactory nf = NameFactoryImpl.getInstance();
-            
+
             // Name of VHR in parent folder is ID of versionable node
             Name vhrname = nf.create(Name.NS_DEFAULT_URI, node.getId().toString());
 
             try {
                 NodeState vhrState = versionManager.getPersistenceManager().load(vhid);
                 NodeState vhrParentState = versionManager.getPersistenceManager().load(vhrState.getParentId());
-                
+
                 if (vhrParentState.hasChildNodeEntry(vhrname)) {
                     NodeState modifiedParent = (NodeState) vworkspaceChanges.get(vhrState.getParentId());
                     if (modifiedParent == null) {
                         modifiedParent = new NodeState(vhrParentState, NodeState.STATUS_EXISTING_MODIFIED,
true);
                     }
-                    
+
                     Calendar now = Calendar.getInstance();
                     String appendme = " (disconnected by RepositoryChecker on "
                             + ISO8601.format(now) + ")";

Modified: jackrabbit/branches/2.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java?rev=1556277&r1=1556276&r2=1556277&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java
Tue Jan  7 17:05:23 2014
@@ -103,17 +103,17 @@ public class AutoFixCorruptNode extends 
             test.addMixin("mix:referenceable");
 
             String lost = test.getIdentifier();
-            
+
             Node lnf = root.addNode("lost+found");
             lnf.addMixin("mix:referenceable");
             String lnfid = lnf.getIdentifier();
-            
+
             s.save();
 
             Node brokenNode = parent;
             UUID destroy = UUID.fromString(brokenNode.getIdentifier());
             s.logout();
-            
+
             destroyBundle(destroy, "workspaces/default");
 
             s = openSession(rep, false);
@@ -123,12 +123,12 @@ public class AutoFixCorruptNode extends 
             // now retry with lost+found functionality
             ConsistencyReport report2 = TestHelper.checkConsistency(s, true, lnfid);
             assertTrue("Report should have reported broken nodes", !report2.getItems().isEmpty());
-            
+
             s.logout();
-            
+
             s = openSession(rep, false);
             Node q = s.getNodeByIdentifier(lost);
-            
+
             // check the node was moved
             assertEquals(lnfid, q.getParent().getIdentifier());
         } finally {
@@ -162,14 +162,14 @@ public class AutoFixCorruptNode extends 
             String vhrRootVersionId = vhr.getNode("jcr:rootVersion").getIdentifier();
             UUID destroy = UUID.fromString(brokenNode.getIdentifier());
             s.logout();
-            
+
             destroyBundle(destroy, "version");
 
             s = openSession(rep, false);
 
             ConsistencyReport report = TestHelper.checkVersionStoreConsistency(s, false,
null);
             assertTrue("Report should have reported broken nodes", !report.getItems().isEmpty());
-            
+
             try {
                 test = s.getRootNode().getNode("test");
                 vhr = s.getWorkspace().getVersionManager()
@@ -188,31 +188,31 @@ public class AutoFixCorruptNode extends 
             test = s.getRootNode().getNode("test");
             // versioning should be disabled now
             assertFalse(test.isNodeType("mix:versionable"));
-            
+
             try {
                 // try to enable versioning again
                 test.addMixin("mix:versionable");
                 s.save();
-                
+
                 fail("enabling versioning succeeded unexpectedly");
             }
             catch (Exception e) {
                 // we expect this to fail
             }
-            
+
             s.logout();
-            
+
             // now redo after running fixup on versioning storage
             s = openSession(rep, false);
 
             report = TestHelper.checkVersionStoreConsistency(s, true, null);
             assertTrue("Report should have reported broken nodes", !report.getItems().isEmpty());
             int reportitems = report.getItems().size();
-            
+
             // problems should now be fixed
             report = TestHelper.checkVersionStoreConsistency(s, false, null);
             assertTrue("Some problems should have been fixed but are not: " + report, report.getItems().size()
< reportitems);
-            
+
             // get a fresh session
             s.logout();
             s = openSession(rep, false);
@@ -220,11 +220,11 @@ public class AutoFixCorruptNode extends 
             test = s.getRootNode().getNode("test");
             // versioning should be disabled now
             assertFalse(test.isNodeType("mix:versionable"));
-            
+
             // try to enable versioning again
             test.addMixin("mix:versionable");
             s.save();
-            
+
             Node oldRootVersion = s.getNodeByIdentifier(vhrRootVersionId);
             try {
                 String path = oldRootVersion.getPath();
@@ -233,7 +233,7 @@ public class AutoFixCorruptNode extends 
             catch (ItemNotFoundException ex) {
                 // orphaned
             }
-            
+
             Node newRootVersion = s.getWorkspace().getVersionManager()
                     .getVersionHistory(test.getPath()).getRootVersion();
             assertFalse(
@@ -262,7 +262,8 @@ public class AutoFixCorruptNode extends 
             Node root = s.getRootNode();
 
             // add nodes /test and /test/missing
-            Node test = root.addNode("test");
+            Node test = root.addNode("test", "nt:file");
+            test.addNode("jcr:content", "nt:unstructured");
             test.addMixin("mix:versionable");
 
             s.save();
@@ -274,17 +275,17 @@ public class AutoFixCorruptNode extends 
 
             Node brokenNode = vhr.getNode("jcr:rootVersion");
             String vhrId = vhr.getIdentifier();
-            
+
             UUID destroy = UUID.fromString(brokenNode.getIdentifier());
             s.logout();
-            
+
             destroyBundle(destroy, "version");
 
             s = openSession(rep, false);
 
             ConsistencyReport report = TestHelper.checkVersionStoreConsistency(s, false,
null);
             assertTrue("Report should have reported broken nodes", !report.getItems().isEmpty());
-            
+
             try {
                 test = s.getRootNode().getNode("test");
                 vhr = s.getWorkspace().getVersionManager()
@@ -303,39 +304,42 @@ public class AutoFixCorruptNode extends 
             test = s.getRootNode().getNode("test");
             // versioning should be disabled now
             assertFalse(test.isNodeType("mix:versionable"));
-            
+
             try {
                 // try to enable versioning again
                 test.addMixin("mix:versionable");
                 s.save();
-                
+
                 fail("enabling versioning succeeded unexpectedly");
             }
             catch (Exception e) {
                 // we expect this to fail
             }
-            
+
             s.logout();
-            
+
             // now redo after running fixup on versioning storage
             s = openSession(rep, false);
 
             report = TestHelper.checkVersionStoreConsistency(s, true, null);
             assertTrue("Report should have reported broken nodes", !report.getItems().isEmpty());
             int reportitems = report.getItems().size();
-            
+
             // problems should now be fixed
             report = TestHelper.checkVersionStoreConsistency(s, false, null);
             assertTrue("Some problems should have been fixed but are not: " + report, report.getItems().size()
< reportitems);
-            
+
             test = s.getRootNode().getNode("test");
             // versioning should be disabled now
             assertFalse(test.isNodeType("mix:versionable"));
-            
+            // jcr:uuid property should still be present
+            assertTrue(test.hasProperty("jcr:uuid"));
+            // ...and have a proper definition
+            assertNotNull(test.getProperty("jcr:uuid").getDefinition().getName());
             // try to enable versioning again
             test.addMixin("mix:versionable");
             s.save();
-            
+
             Node oldVHR = s.getNodeByIdentifier(vhrId);
             Node newVHR = s.getWorkspace().getVersionManager().getVersionHistory(test.getPath());
 
@@ -345,11 +349,11 @@ public class AutoFixCorruptNode extends 
 
             // name should be same plus suffix
             assertTrue(oldVHR.getName().startsWith(newVHR.getName()));
-            
+
             // try a checkout / checkin
             s.getWorkspace().getVersionManager().checkout(test.getPath());
             s.getWorkspace().getVersionManager().checkin(test.getPath());
-            
+
         } finally {
             s.logout();
             System.setProperty("org.apache.jackrabbit.version.recovery",
@@ -384,23 +388,23 @@ public class AutoFixCorruptNode extends 
 
             Node brokenNode = vhr.getNode("jcr:rootVersion");
             String vhrId = vhr.getIdentifier();
-            
+
             UUID destroy = UUID.fromString(brokenNode.getIdentifier());
 
             // disable versioning
             test.removeMixin("mix:versionable");
             s.save();
-            
+
             s.logout();
-            
-            
+
+
             destroyBundle(destroy, "version");
 
             s = openSession(rep, false);
 
             ConsistencyReport report = TestHelper.checkVersionStoreConsistency(s, false,
null);
             assertTrue("Report should have reported broken nodes", !report.getItems().isEmpty());
-            
+
             s.logout();
 
             System.setProperty("org.apache.jackrabbit.version.recovery", "true");
@@ -413,7 +417,7 @@ public class AutoFixCorruptNode extends 
             test = s.getRootNode().getNode("test");
             // versioning should still be disabled
             assertFalse(test.isNodeType("mix:versionable"));
-            
+
             // try to enable versioning again
             test.addMixin("mix:versionable");
             s.save();
@@ -427,7 +431,7 @@ public class AutoFixCorruptNode extends 
 
             // name should be same plus suffix
             assertTrue(oldVHR.getName().startsWith(newVHR.getName()));
-            
+
             // try a checkout / checkin
             s.getWorkspace().getVersionManager().checkout(test.getPath());
             s.getWorkspace().getVersionManager().checkin(test.getPath());



Mime
View raw message