From a93926a54e27bbd42818f3bb73f91921378c6a10 Mon Sep 17 00:00:00 2001 From: Jukka Zitting Date: Tue, 20 Nov 2012 12:32:41 +0200 Subject: [PATCH] OAK-410: RepositoryInitializer runs before the CommitHooks are in place Run the required index hooks as a part of the initializer --- .../jackrabbit/oak/plugins/nodetype/InitialContent.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/InitialContent.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/InitialContent.java index 620b1bc..40c0ae1 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/InitialContent.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/InitialContent.java @@ -22,10 +22,14 @@ import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.core.RootImpl; +import org.apache.jackrabbit.oak.plugins.index.IndexHookManager; +import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexHookProvider; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; +import org.apache.jackrabbit.oak.spi.commit.CommitHook; import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer; import org.apache.jackrabbit.oak.spi.security.user.UserConstants; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; +import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStore; import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch; @@ -43,7 +47,8 @@ public class InitialContent implements RepositoryInitializer { public void initialize(NodeStore store) { NodeStoreBranch branch = store.branch(); - NodeBuilder root = branch.getRoot().builder(); + NodeState before = branch.getRoot(); + NodeBuilder root = before.builder(); root.setProperty("jcr:primaryType", "rep:root", Type.NAME); if (!root.hasChildNode("jcr:system")) { @@ -95,7 +100,9 @@ public class InitialContent implements RepositoryInitializer { .setProperty("reindex", true); } try { - branch.setRoot(root.getNodeState()); + CommitHook hook = + new IndexHookManager(new PropertyIndexHookProvider()); + branch.setRoot(hook.processCommit(before, root.getNodeState())); branch.merge(); } catch (CommitFailedException e) { throw new RuntimeException(e); // TODO: shouldn't need the wrapper -- 1.7.10.msysgit.1