You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2022/09/29 12:11:53 UTC
[jackrabbit-oak] branch 1.22 updated: OAK-9891:added fix of issue 'Removal (purge) of version of a node does not remove associated labels' to 1.22 branch
This is an automated email from the ASF dual-hosted git repository.
mreutegg pushed a commit to branch 1.22
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/1.22 by this push:
new 37a682d654 OAK-9891:added fix of issue 'Removal (purge) of version of a node does not remove associated labels' to 1.22 branch
new cadb87b872 Merge pull request #716 from ArunOnCloud/1.22
37a682d654 is described below
commit 37a682d654cd74fa2052ab533f20898bd346b06a
Author: arunram <ar...@adobe.com>
AuthorDate: Thu Sep 22 14:44:36 2022 +0530
OAK-9891:added fix of issue 'Removal (purge) of version of a node does not remove associated labels' to 1.22 branch
---
.../plugins/version/ReadWriteVersionManager.java | 2 +-
.../oak/jcr/version/VersionHistoryTest.java | 41 ++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
index ed0dbfae42..ca27c4bd30 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
@@ -183,7 +183,7 @@ public class ReadWriteVersionManager extends ReadOnlyVersionManager {
NodeBuilder versionNode = vh.getChildNode(versionName);
String versionId = versionNode.getProperty(JCR_UUID).getValue(Type.STRING);
// unregister from labels
- for (String label : getVersionLabels(versionRelPath, versionId)) {
+ for (String label : getVersionLabels(historyRelPath, versionId)) {
removeVersionLabel(historyRelPath, label);
}
// reconnected predecessors and successors of the version being removed
diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryTest.java
index 2e99325f8e..e46cd3e1ec 100644
--- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryTest.java
+++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryTest.java
@@ -19,12 +19,17 @@ package org.apache.jackrabbit.oak.jcr.version;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import javax.jcr.version.Version;
import javax.jcr.version.VersionHistory;
+import javax.jcr.version.VersionIterator;
import javax.jcr.version.VersionManager;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.test.AbstractJCRTest;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Contains {@link VersionHistory} related tests.
*/
@@ -123,4 +128,40 @@ public class VersionHistoryTest extends AbstractJCRTest {
assertTrue("Session.getNodeByUUID() did not return VersionHistory object for a nt:versionHistory node.",
superuser.getNodeByUUID(uuid) instanceof VersionHistory);
}
+
+ public void testRemoveVersionLabelWithRemovalOfVersion() throws RepositoryException {
+ int createVersions = 3;
+ Node n = testRootNode.addNode(nodeName1, testNodeType);
+ n.addMixin(mixVersionable);
+ superuser.save();
+ for (int i = 0; i < createVersions; i++) {
+ versionManager.checkout(n.getPath());
+ versionManager.checkin(n.getPath());
+ }
+
+ VersionHistory vhr = versionManager.getVersionHistory(n.getPath());
+ // initialize versionName
+ String versionName = "";
+ VersionIterator allversions = vhr.getAllVersions();
+ int count = 0;
+ while (allversions.hasNext()) {
+ Version version = allversions.nextVersion();
+ if(count == 1) {
+ versionName = version.getName();
+ }
+ count++;
+ }
+ int versionLabelCount = 3;
+ List<String> versionLabels = new ArrayList<>();
+ for(int i = 0; i < versionLabelCount; i++) {
+ String labelName = "Label_" + versionName + "_" + i;
+ vhr.addVersionLabel(versionName, labelName,false);
+ versionLabels.add(labelName);
+ }
+ vhr.removeVersion(versionName);
+ for(String label : versionLabels) {
+ assertFalse("version label should not exist", vhr.hasVersionLabel(label));
+ }
+
+ }
}
\ No newline at end of file