PrivilegeInitializer should not attempt to create jcr:system node
@@ -25,7 +25,6 @@ import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
import org.apache.jackrabbit.oak.plugins.tree.RootProvider;
import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
-import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants;
import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants;
import org.apache.jackrabbit.oak.spi.state.ApplyDiff;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -54,9 +53,10 @@ class PrivilegeInitializer implements RepositoryInitializer, PrivilegeConstants
@Override
public void initialize(@Nonnull NodeBuilder builder) {
- NodeBuilder system = builder.child(JcrConstants.JCR_SYSTEM);
- system.setProperty(JcrConstants.JCR_PRIMARYTYPE, NodeTypeConstants.NT_REP_SYSTEM, Type.NAME);
-
+ if (!builder.hasChildNode(JcrConstants.JCR_SYSTEM)) {
+ throw new IllegalStateException("Missing " + JcrConstants.JCR_SYSTEM + " node, NodeStore not initialized.");
+ }
+ NodeBuilder system = builder.getChildNode(JcrConstants.JCR_SYSTEM);
if (!system.hasChildNode(REP_PRIVILEGES)) {
NodeBuilder privileges = system.child(REP_PRIVILEGES);
privileges.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PRIVILEGES, Type.NAME);
