Skip to content

Commit

Permalink
OAK-10784: o.a.j.o.plugins.migration.version.VersionableEditor should…
Browse files Browse the repository at this point in the history
… create the version storage node, if needed (apache#1438)

Implemented; improved logging.
  • Loading branch information
mbaedke authored May 8, 2024
1 parent f0ac80e commit 86befaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import static org.apache.jackrabbit.JcrConstants.JCR_UUID;
import static org.apache.jackrabbit.JcrConstants.MIX_REFERENCEABLE;
import static org.apache.jackrabbit.JcrConstants.MIX_VERSIONABLE;
import static org.apache.jackrabbit.oak.plugins.migration.version.VersionHistoryUtil.createVersionStorage;
import static org.apache.jackrabbit.oak.spi.version.VersionConstants.MIX_REP_VERSIONABLE_PATHS;
import static org.apache.jackrabbit.oak.plugins.migration.version.VersionHistoryUtil.addMixin;
import static org.apache.jackrabbit.oak.plugins.migration.version.VersionHistoryUtil.getVersionHistoryBuilder;
Expand Down Expand Up @@ -79,7 +80,7 @@ public class VersionableEditor extends DefaultEditor {

private VersionableEditor(Provider provider, NodeBuilder rootBuilder) {
this.rootBuilder = rootBuilder;
this.versionStorage = getVersionStorage(rootBuilder);
this.versionStorage = createVersionStorage(rootBuilder);
this.vMgr = new ReadWriteVersionManager(versionStorage, rootBuilder);

this.provider = provider;
Expand Down Expand Up @@ -140,8 +141,8 @@ public Editor childNodeAdded(String name, NodeState after) throws CommitFailedEx
NodeBuilder versionableBuilder = getNodeBuilder(rootBuilder, this.path);
removeVersionProperties(versionableBuilder, isReferenceable);
if (isVersionable.test(versionableBuilder.getNodeState())) {
logger.warn("Node {} is still versionable. Creating initial version history.", path);
createEmptyHistory(versionableBuilder);
logger.warn("Node {} is still versionable due to node type constraints. Creating initial version history.", path);
createInitialHistory(versionableBuilder);
}
}
}
Expand Down Expand Up @@ -169,7 +170,7 @@ private boolean isVersionHistoryExists(String versionableUuid) {
return getVersionHistoryBuilder(versionStorage, versionableUuid).exists();
}

private void createEmptyHistory(NodeBuilder versionable) throws CommitFailedException {
private void createInitialHistory(NodeBuilder versionable) throws CommitFailedException {
vMgr.getOrCreateVersionHistory(versionable, Collections.<String,Object>emptyMap());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
import static org.apache.jackrabbit.oak.api.Type.REFERENCE;
import static org.apache.jackrabbit.oak.api.Type.REFERENCES;
import static org.apache.jackrabbit.oak.plugins.memory.MultiGenericPropertyState.nameProperty;
import static org.apache.jackrabbit.oak.plugins.migration.version.VersionHistoryUtil.createVersionStorage;
import static org.apache.jackrabbit.oak.plugins.migration.version.VersionHistoryUtil.getVersionHistoryNodeState;
import static org.apache.jackrabbit.oak.plugins.migration.version.VersionHistoryUtil.getVersionStorage;

/**
* The VersionablePropertiesEditor adds missing versionable properties.
Expand All @@ -76,7 +76,7 @@ public final class VersionablePropertiesEditor extends DefaultEditor {
private VersionablePropertiesEditor(NodeBuilder rootBuilder) {
this.builder = rootBuilder;
this.rootBuilder = rootBuilder;
this.versionStorage = getVersionStorage(rootBuilder);
this.versionStorage = createVersionStorage(rootBuilder);
this.isVersionable = new TypePredicate(rootBuilder.getNodeState(), MIX_VERSIONABLE);
this.isNtVersion = new TypePredicate(rootBuilder.getNodeState(), NT_VERSION);
this.isFrozenNode = new TypePredicate(rootBuilder.getNodeState(), NT_FROZENNODE);
Expand Down

0 comments on commit 86befaf

Please sign in to comment.