jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1525155 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/ oak-core/s...
Date Fri, 20 Sep 2013 22:14:30 GMT
Author: jukka
Date: Fri Sep 20 22:14:30 2013
New Revision: 1525155

URL: http://svn.apache.org/r1525155
Log:
OAK-659: Move purge logic for transient changes below the NodeBuilder interface

\Revert troublesome revision 1525140

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/InitialContent.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationInitializer.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeInitializer.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserInitializer.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/WorkspaceInitializer.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java
    jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/LuceneInitializerHelper.java
    jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java
Fri Sep 20 22:14:30 2013
@@ -20,7 +20,7 @@ package org.apache.jackrabbit.oak.osgi;
 
 import org.apache.jackrabbit.oak.spi.lifecycle.CompositeInitializer;
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.osgi.framework.ServiceReference;
 
 /**
@@ -39,8 +39,8 @@ public class OsgiRepositoryInitializer
     }
 
     @Override
-    public void initialize(NodeBuilder builder) {
-        new CompositeInitializer(getServices()).initialize(builder);
+    public NodeState initialize(NodeState state) {
+        return new CompositeInitializer(getServices()).initialize(state);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
Fri Sep 20 22:14:30 2013
@@ -45,18 +45,11 @@ import org.apache.jackrabbit.oak.spi.sta
  */
 public class MemoryNodeStore extends AbstractNodeStore {
 
-    private final AtomicReference<NodeState> root;
+    private final AtomicReference<NodeState> root =
+            new AtomicReference<NodeState>(EMPTY_NODE);
 
     private final Map<String, NodeState> checkpoints = newHashMap();
 
-    public MemoryNodeStore(NodeState state) {
-        this.root = new AtomicReference<NodeState>(state);
-    }
-
-    public MemoryNodeStore() {
-        this(EMPTY_NODE);
-    }
-
     @Override
     public NodeState getRoot() {
         return root.get();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/InitialContent.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/InitialContent.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/InitialContent.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/InitialContent.java
Fri Sep 20 22:14:30 2013
@@ -16,26 +16,26 @@
  */
 package org.apache.jackrabbit.oak.plugins.nodetype.write;
 
-import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
-
 import com.google.common.collect.ImmutableList;
-
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.core.SystemRoot;
 import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
 import org.apache.jackrabbit.oak.plugins.index.IndexUtils;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
-import org.apache.jackrabbit.oak.plugins.memory.ModifiedNodeState;
 import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants;
 import org.apache.jackrabbit.oak.plugins.nodetype.RegistrationEditorProvider;
 import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
 import org.apache.jackrabbit.oak.spi.commit.EditorHook;
+import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
+import org.apache.jackrabbit.oak.spi.commit.PostCommitHook;
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 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;
 
 /**
  * {@code InitialContent} implements a {@link RepositoryInitializer} and
@@ -45,20 +45,13 @@ import org.apache.jackrabbit.oak.spi.sta
 @Service(RepositoryInitializer.class)
 public class InitialContent implements RepositoryInitializer, NodeTypeConstants {
 
-    public static final NodeState INITIAL_CONTENT = createInitialContent();
-
-    private static NodeState createInitialContent() {
-        NodeBuilder builder = EMPTY_NODE.builder();
-        new InitialContent().initialize(builder);
-        return ModifiedNodeState.squeeze(builder.getNodeState());
-    }
-
     @Override
-    public void initialize(NodeBuilder builder) {
-        builder.setProperty(JCR_PRIMARYTYPE, NT_REP_ROOT, Type.NAME);
+    public NodeState initialize(NodeState state) {
+        NodeBuilder root = state.builder();
+        root.setProperty(JCR_PRIMARYTYPE, NT_REP_ROOT, Type.NAME);
 
-        if (!builder.hasChildNode(JCR_SYSTEM)) {
-            NodeBuilder system = builder.child(JCR_SYSTEM);
+        if (!root.hasChildNode(JCR_SYSTEM)) {
+            NodeBuilder system = root.child(JCR_SYSTEM);
             system.setProperty(JCR_PRIMARYTYPE, NT_REP_SYSTEM, Type.NAME);
 
             system.child(JCR_VERSIONSTORAGE)
@@ -69,8 +62,8 @@ public class InitialContent implements R
                     .setProperty(JCR_PRIMARYTYPE, VersionConstants.REP_ACTIVITIES, Type.NAME);
         }
 
-        if (!builder.hasChildNode(IndexConstants.INDEX_DEFINITIONS_NAME)) {
-            NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder);
+        if (!root.hasChildNode(IndexConstants.INDEX_DEFINITIONS_NAME)) {
+            NodeBuilder index = IndexUtils.getOrCreateOakIndex(root);
 
             IndexUtils.createIndexDefinition(index, "uuid", true, true,
                     ImmutableList.<String>of(JCR_UUID), null);
@@ -80,10 +73,16 @@ public class InitialContent implements R
             // the cost of using the property index for "@primaryType is not null" is very
high
             nt.setProperty(IndexConstants.ENTRY_COUNT_PROPERTY_NAME, Long.valueOf(Long.MAX_VALUE));
         }
-
-        NodeStore store = new MemoryNodeStore(builder.getNodeState());
+        NodeStore store = new MemoryNodeStore();
+        NodeStoreBranch branch = store.branch();
+        branch.setRoot(root.getNodeState());
+        try {
+            branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        } catch (CommitFailedException e) {
+            throw new RuntimeException(e);
+        }
         BuiltInNodeTypes.register(new SystemRoot(store, new EditorHook(new RegistrationEditorProvider())));
-        builder.reset(store.getRoot());
+        return store.getRoot();
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationInitializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationInitializer.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationInitializer.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationInitializer.java
Fri Sep 20 22:14:30 2013
@@ -28,6 +28,7 @@ import org.apache.jackrabbit.oak.spi.lif
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AccessControlConstants;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
 import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
@@ -46,9 +47,11 @@ class AuthorizationInitializer implement
 
     @Nonnull
     @Override
-    public void initialize(NodeBuilder builder, String workspaceName, QueryIndexProvider
indexProvider, CommitHook commitHook) {
+    public NodeState initialize(NodeState workspaceRoot, String workspaceName, QueryIndexProvider
indexProvider, CommitHook commitHook) {
+        NodeBuilder root = workspaceRoot.builder();
+
         // property index for rep:principalName stored in ACEs
-        NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder);
+        NodeBuilder index = IndexUtils.getOrCreateOakIndex(root);
         if (!index.hasChildNode("acPrincipalName")) {
             IndexUtils.createIndexDefinition(index, "acPrincipalName", true, false,
                     ImmutableList.<String>of(REP_PRINCIPAL_NAME),
@@ -56,12 +59,13 @@ class AuthorizationInitializer implement
         }
 
         // create the permission store and the root for this workspace.
-        NodeBuilder permissionStore = builder.child(JCR_SYSTEM).child(REP_PERMISSION_STORE);
+        NodeBuilder permissionStore = root.child(JCR_SYSTEM).child(REP_PERMISSION_STORE);
         if (!permissionStore.hasProperty(JCR_PRIMARYTYPE)) {
             permissionStore.setProperty(JCR_PRIMARYTYPE, NT_REP_PERMISSION_STORE, Type.NAME);
         }
         if (!permissionStore.hasChildNode(workspaceName)) {
             permissionStore.child(workspaceName).setProperty(JcrConstants.JCR_PRIMARYTYPE,
NT_REP_PERMISSION_STORE, Type.NAME);
         }
+        return root.getNodeState();
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeInitializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeInitializer.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeInitializer.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeInitializer.java
Fri Sep 20 22:14:30 2013
@@ -16,17 +16,23 @@
  */
 package org.apache.jackrabbit.oak.security.privilege;
 
+
 import javax.jcr.RepositoryException;
 
 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.SystemRoot;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
 import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants;
+import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
+import org.apache.jackrabbit.oak.spi.commit.PostCommitHook;
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants;
 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;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,22 +47,33 @@ class PrivilegeInitializer implements Re
     private static final Logger log = LoggerFactory.getLogger(PrivilegeInitializer.class);
 
     @Override
-    public void initialize(NodeBuilder builder) {
-        NodeBuilder system = builder.child(JcrConstants.JCR_SYSTEM);
+    public NodeState initialize(NodeState state) {
+        NodeBuilder root = state.builder();
+        NodeBuilder system = root.child(JcrConstants.JCR_SYSTEM);
         system.setProperty(JcrConstants.JCR_PRIMARYTYPE, NodeTypeConstants.NT_REP_SYSTEM,
Type.NAME);
 
         if (!system.hasChildNode(REP_PRIVILEGES)) {
             NodeBuilder privileges = system.child(REP_PRIVILEGES);
             privileges.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PRIVILEGES, Type.NAME);
 
-            NodeStore store = new MemoryNodeStore(builder.getNodeState());
+            NodeStore store = new MemoryNodeStore();
+            NodeStoreBranch branch = store.branch();
+            try {
+                branch.setRoot(root.getNodeState());
+                branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+            } catch (CommitFailedException e) {
+                log.error("Failed to initialize privilege content ", e);
+                throw new RuntimeException(e);
+            }
+
             try {
                 new PrivilegeDefinitionWriter(new SystemRoot(store)).writeBuiltInDefinitions();
-                builder.reset(store.getRoot());
             } catch (RepositoryException e) {
                 log.error("Failed to register built-in privileges", e);
                 throw new RuntimeException(e);
             }
+            return store.getRoot();
         }
+        return root.getNodeState();
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserInitializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserInitializer.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserInitializer.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserInitializer.java
Fri Sep 20 22:14:30 2013
@@ -16,10 +16,10 @@
  */
 package org.apache.jackrabbit.oak.security.user;
 
-import javax.jcr.RepositoryException;
 
+import javax.annotation.Nonnull;
+import javax.jcr.RepositoryException;
 import com.google.common.base.Strings;
-
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
@@ -38,7 +38,7 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
 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.NodeStoreBranch;
 import org.apache.jackrabbit.oak.util.NodeUtil;
 import org.slf4j.Logger;
@@ -84,12 +84,20 @@ class UserInitializer implements Workspa
     }
 
     //-----------------------------------------------< WorkspaceInitializer >---
-
+    @Nonnull
     @Override
-    public void initialize(NodeBuilder builder, String workspaceName,
+    public NodeState initialize(NodeState workspaceRoot, String workspaceName,
                                 QueryIndexProvider indexProvider,
                                 CommitHook commitHook) {
-        MemoryNodeStore store = new MemoryNodeStore(builder.getNodeState());
+        MemoryNodeStore store = new MemoryNodeStore();
+        NodeStoreBranch branch = store.branch();
+        branch.setRoot(workspaceRoot);
+        try {
+            branch.merge(EmptyHook.INSTANCE, PostCommitHook.EMPTY);
+        } catch (CommitFailedException e) {
+            throw new RuntimeException(e);
+        }
+
         Root root = new SystemRoot(store, commitHook, workspaceName, securityProvider, indexProvider);
 
         UserConfiguration userConfiguration = securityProvider.getConfiguration(UserConfiguration.class);
@@ -133,7 +141,7 @@ class UserInitializer implements Workspa
             throw new RuntimeException(e);
         }
 
-        builder.reset(store.getRoot());
+        return store.getRoot();
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java
Fri Sep 20 22:14:30 2013
@@ -21,9 +21,6 @@ package org.apache.jackrabbit.oak.spi.li
 import java.util.Arrays;
 import java.util.Collection;
 
-import javax.annotation.Nonnull;
-
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 /**
@@ -44,9 +41,11 @@ public class CompositeInitializer implem
     }
 
     @Override
-    public void initialize(@Nonnull NodeBuilder builder) {
+    public NodeState initialize(NodeState state) {
+        NodeState newState = state;
         for (RepositoryInitializer tracker : initializers) {
-            tracker.initialize(builder);
+            newState = tracker.initialize(newState);
         }
+        return newState;
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
Fri Sep 20 22:14:30 2013
@@ -27,7 +27,6 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.commit.EditorHook;
 import org.apache.jackrabbit.oak.spi.commit.PostCommitHook;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
-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;
@@ -40,10 +39,11 @@ public final class OakInitializer {
     public static void initialize(@Nonnull NodeStore store,
                                   @Nonnull RepositoryInitializer initializer,
                                   @Nonnull IndexEditorProvider indexEditor) {
-        NodeBuilder builder = store.getRoot().builder();
-        initializer.initialize(builder);
+        NodeStoreBranch branch = store.branch();
+        NodeState before = branch.getHead();
+        branch.setRoot(initializer.initialize(before));
         try {
-            store.merge(builder, new EditorHook(new IndexUpdateProvider(indexEditor)), PostCommitHook.EMPTY);
+            branch.merge(new EditorHook(new IndexUpdateProvider(indexEditor)), PostCommitHook.EMPTY);
         } catch (CommitFailedException e) {
             throw new RuntimeException(e);
         }
@@ -55,12 +55,14 @@ public final class OakInitializer {
                                   @Nonnull IndexEditorProvider indexEditor,
                                   @Nonnull QueryIndexProvider indexProvider,
                                   @Nonnull CommitHook commitHook) {
-        NodeBuilder builder = store.getRoot().builder();
+        NodeStoreBranch branch = store.branch();
+        NodeState root = branch.getHead();
         for (WorkspaceInitializer wspInit : initializer) {
-            wspInit.initialize(builder, workspaceName, indexProvider, commitHook);
+            root = wspInit.initialize(root, workspaceName, indexProvider, commitHook);
         }
+        branch.setRoot(root);
         try {
-            store.merge(builder, new EditorHook(new IndexUpdateProvider(indexEditor)), PostCommitHook.EMPTY);
+            branch.merge(new EditorHook(new IndexUpdateProvider(indexEditor)), PostCommitHook.EMPTY);
         } catch (CommitFailedException e) {
             throw new RuntimeException(e);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java
Fri Sep 20 22:14:30 2013
@@ -18,9 +18,6 @@
  */
 package org.apache.jackrabbit.oak.spi.lifecycle;
 
-import javax.annotation.Nonnull;
-
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 /**
@@ -37,7 +34,8 @@ public interface RepositoryInitializer {
      */
     RepositoryInitializer DEFAULT = new RepositoryInitializer() {
         @Override
-        public void initialize(NodeBuilder builder) {
+        public NodeState initialize(NodeState state) {
+            return state;
         }
     };
 
@@ -47,8 +45,7 @@ public interface RepositoryInitializer {
      * have been initialized, so the implementation of this method should
      * check for that before blindly adding new content.
      *
-     * @param builder builder for accessing and modifying repository content
+     * @param state the current state of the repository
      */
-    void initialize(@Nonnull NodeBuilder builder);
-
+    NodeState initialize(NodeState state);
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/WorkspaceInitializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/WorkspaceInitializer.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/WorkspaceInitializer.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/WorkspaceInitializer.java
Fri Sep 20 22:14:30 2013
@@ -16,9 +16,11 @@
  */
 package org.apache.jackrabbit.oak.spi.lifecycle;
 
+import javax.annotation.Nonnull;
+
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 /**
  * Initializer of a workspace and it's initial content. A module that needs
@@ -30,8 +32,10 @@ import org.apache.jackrabbit.oak.spi.sta
 public interface WorkspaceInitializer {
 
     WorkspaceInitializer DEFAULT = new WorkspaceInitializer() {
+        @Nonnull
         @Override
-        public void initialize(NodeBuilder builder, String workspaceName, QueryIndexProvider
indexProvider, CommitHook commitHook) {
+        public NodeState initialize(NodeState workspaceRoot, String workspaceName, QueryIndexProvider
indexProvider, CommitHook commitHook) {
+            return workspaceRoot;
         }
     };
 
@@ -39,15 +43,15 @@ public interface WorkspaceInitializer {
      * Initialize the content of a new workspace. This method is called before
      * the workspace becomes available.
      *
-     * @param builder       Builder for accessing and modifying the workspace
+     * @param workspaceRoot The workspace root state.
      * @param workspaceName The name of the workspace that is being initialized.
      * @param indexProvider The query index provider used within this workspace.
      * @param commitHook    The commit hook(s) defined for this workspace.
      * @return The modified workspace root state.
      */
-    void initialize(NodeBuilder builder, 
+    @Nonnull
+    NodeState initialize(NodeState workspaceRoot, 
                          String workspaceName,
                          QueryIndexProvider indexProvider,
                          CommitHook commitHook);
-
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
Fri Sep 20 22:14:30 2013
@@ -22,6 +22,7 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME;
 import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefinition;
+import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_NODE_TYPES;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -52,7 +53,7 @@ public class IndexUpdateTest {
     private static final EditorHook HOOK = new EditorHook(
             new IndexUpdateProvider(new PropertyIndexEditorProvider()));
 
-    private NodeState root = InitialContent.INITIAL_CONTENT;
+    private NodeState root = new InitialContent().initialize(EMPTY_NODE);
 
     private NodeBuilder builder = root.builder();
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java
Fri Sep 20 22:14:30 2013
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.oak.query.A
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;
@@ -42,17 +43,17 @@ public class MultipleIndicesTest extends
                 .with(new InitialContent())
                 .with(new RepositoryInitializer() {
                     @Override
-                    public void initialize(NodeBuilder builder) {
-                        createIndexDefinition(
-                                getOrCreateOakIndex(builder), "pid",
+                    public NodeState initialize(NodeState state) {
+                        NodeBuilder root = state.builder();
+                        createIndexDefinition(getOrCreateOakIndex(root), "pid",
                                 true, false, ImmutableList.of("pid"), null);
                         createIndexDefinition(
-                                getOrCreateOakIndex(builder.child("content")),
+                                getOrCreateOakIndex(root.child("content")),
                                 "pid", true, false, ImmutableList.of("pid"),
                                 null);
+                        return root.getNodeState();
                     }
-                })
-                .with(new OpenSecurityProvider())
+                }).with(new OpenSecurityProvider())
                 .with(new PropertyIndexProvider())
                 .with(new PropertyIndexEditorProvider())
                 .createContentRepository();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
Fri Sep 20 22:14:30 2013
@@ -60,7 +60,7 @@ public class PropertyIndexTest {
 
     @Test
     public void testPropertyLookup() throws Exception {
-        NodeState root = InitialContent.INITIAL_CONTENT;
+        NodeState root = new InitialContent().initialize(EMPTY_NODE);
 
         // Add index definition
         NodeBuilder builder = root.builder();
@@ -105,7 +105,7 @@ public class PropertyIndexTest {
 
     @Test
     public void testCustomConfigPropertyLookup() throws Exception {
-        NodeState root = InitialContent.INITIAL_CONTENT;
+        NodeState root = new InitialContent().initialize(EMPTY_NODE);
 
         // Add index definition
         NodeBuilder builder = root.builder();
@@ -153,7 +153,7 @@ public class PropertyIndexTest {
      */
     @Test
     public void testCustomConfigNodeType() throws Exception {
-        NodeState root = InitialContent.INITIAL_CONTENT;
+        NodeState root = new InitialContent().initialize(EMPTY_NODE);
 
         // Add index definitions
         NodeBuilder builder = root.builder();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java
Fri Sep 20 22:14:30 2013
@@ -33,6 +33,7 @@ import org.apache.jackrabbit.oak.query.A
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.junit.Test;
 
 /**
@@ -45,10 +46,12 @@ public class RelativePathTest extends Ab
         return new Oak().with(new InitialContent())
                 .with(new RepositoryInitializer() {
                     @Override
-                    public void initialize(NodeBuilder builder) {
-                        NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder);
+                    public NodeState initialize(NodeState state) {
+                        NodeBuilder root = state.builder();
+                        NodeBuilder index = IndexUtils.getOrCreateOakIndex(root);
                         IndexUtils.createIndexDefinition(index, "myProp", true,
                                 false, ImmutableList.<String>of("myProp"), null);
+                        return root.getNodeState();
                     }
                 })
                 .with(new OpenSecurityProvider())

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java
Fri Sep 20 22:14:30 2013
@@ -38,7 +38,7 @@ public class TypeEditorTest {
     public void ignoreHidden() throws CommitFailedException {
         EditorHook hook = new EditorHook(new TypeEditorProvider());
 
-        NodeState root = InitialContent.INITIAL_CONTENT;
+        NodeState root = new InitialContent().initialize(EMPTY_NODE);
         NodeBuilder builder = root.builder();
 
         NodeState before = builder.getNodeState();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java
Fri Sep 20 22:14:30 2013
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.query;
 
 import static junit.framework.Assert.assertTrue;
 import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
+import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_NODE_TYPES;
 
 import java.text.ParseException;
@@ -31,10 +32,8 @@ import org.junit.Test;
  */
 public class SQL2ParserTest {
 
-    private final NodeState types = InitialContent.INITIAL_CONTENT
-            .getChildNode(JCR_SYSTEM)
-            .getChildNode(JCR_NODE_TYPES);
-
+    private final NodeState types = new InitialContent().initialize(EMPTY_NODE)
+            .getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES);
     private final SQL2Parser p = new SQL2Parser(types);
 
     @Test

Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/LuceneInitializerHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/LuceneInitializerHelper.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/LuceneInitializerHelper.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/LuceneInitializerHelper.java
Fri Sep 20 22:14:30 2013
@@ -24,6 +24,7 @@ import java.util.Set;
 
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 public class LuceneInitializerHelper implements RepositoryInitializer {
 
@@ -69,19 +70,22 @@ public class LuceneInitializerHelper imp
     }
 
     @Override
-    public void initialize(NodeBuilder builder) {
-        if (builder.hasChildNode(INDEX_DEFINITIONS_NAME)
-                && builder.getChildNode(INDEX_DEFINITIONS_NAME).hasChildNode(name))
{
-            // do nothing
-        } else if (filePath == null) {
-            newLuceneIndexDefinition(
-                    builder.child(INDEX_DEFINITIONS_NAME),
+    public NodeState initialize(NodeState state) {
+        if (state.hasChildNode(INDEX_DEFINITIONS_NAME)
+                && state.getChildNode(INDEX_DEFINITIONS_NAME)
+                        .hasChildNode(name)) {
+            return state;
+        }
+        NodeBuilder builder = state.builder();
+
+        if (filePath == null) {
+            newLuceneIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
                     name, propertyTypes, excludes, async);
         } else {
-            newLuceneFileIndexDefinition(
-                    builder.child(INDEX_DEFINITIONS_NAME),
+            newLuceneFileIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
                     name, propertyTypes, excludes, filePath, async);
         }
+        return builder.getNodeState();
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java?rev=1525155&r1=1525154&r2=1525155&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
Fri Sep 20 22:14:30 2013
@@ -55,7 +55,7 @@ public class LuceneIndexTest {
             new IndexUpdateProvider(
                     new LuceneIndexEditorProvider().with(analyzer)));
 
-    private NodeState root = InitialContent.INITIAL_CONTENT;
+    private NodeState root = new InitialContent().initialize(EMPTY_NODE);
 
     private NodeBuilder builder = root.builder();
 



Mime
View raw message