jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1525255 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: security/authorization/ security/user/ spi/lifecycle/
Date Sat, 21 Sep 2013 16:07:59 GMT
Author: jukka
Date: Sat Sep 21 16:07:59 2013
New Revision: 1525255

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

Use NodeBuilders in WorkspaceInitializer

Modified:
    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/user/UserInitializer.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/WorkspaceInitializer.java

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=1525255&r1=1525254&r2=1525255&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
Sat Sep 21 16:07:59 2013
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.oak.security.authorization;
 
-import javax.annotation.Nonnull;
-
 import com.google.common.collect.ImmutableList;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.Type;
@@ -28,7 +26,6 @@ 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;
@@ -45,13 +42,12 @@ import static org.apache.jackrabbit.JcrC
  */
 class AuthorizationInitializer implements WorkspaceInitializer, AccessControlConstants, PermissionConstants
{
 
-    @Nonnull
     @Override
-    public NodeState initialize(NodeState workspaceRoot, String workspaceName, QueryIndexProvider
indexProvider, CommitHook commitHook) {
-        NodeBuilder root = workspaceRoot.builder();
-
+    public void initialize(
+            NodeBuilder builder, String workspaceName,
+            QueryIndexProvider indexProvider, CommitHook commitHook) {
         // property index for rep:principalName stored in ACEs
-        NodeBuilder index = IndexUtils.getOrCreateOakIndex(root);
+        NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder);
         if (!index.hasChildNode("acPrincipalName")) {
             IndexUtils.createIndexDefinition(index, "acPrincipalName", true, false,
                     ImmutableList.<String>of(REP_PRINCIPAL_NAME),
@@ -59,13 +55,14 @@ class AuthorizationInitializer implement
         }
 
         // create the permission store and the root for this workspace.
-        NodeBuilder permissionStore = root.child(JCR_SYSTEM).child(REP_PERMISSION_STORE);
+        NodeBuilder permissionStore =
+                builder.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/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=1525255&r1=1525254&r2=1525255&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
Sat Sep 21 16:07:59 2013
@@ -16,10 +16,10 @@
  */
 package org.apache.jackrabbit.oak.security.user;
 
-
-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;
@@ -30,16 +30,15 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.index.IndexUtils;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
-import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
-import org.apache.jackrabbit.oak.spi.commit.PostCommitHook;
 import org.apache.jackrabbit.oak.spi.lifecycle.WorkspaceInitializer;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
 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.ApplyDiff;
+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;
 import org.slf4j.LoggerFactory;
@@ -84,19 +83,13 @@ class UserInitializer implements Workspa
     }
 
     //-----------------------------------------------< WorkspaceInitializer >---
-    @Nonnull
+
     @Override
-    public NodeState initialize(NodeState workspaceRoot, String workspaceName,
-                                QueryIndexProvider indexProvider,
-                                CommitHook commitHook) {
-        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);
-        }
+    public void initialize(
+            NodeBuilder builder, String workspaceName,
+            QueryIndexProvider indexProvider, CommitHook commitHook) {
+        NodeState base = builder.getNodeState();
+        MemoryNodeStore store = new MemoryNodeStore(base);
 
         Root root = new SystemRoot(store, commitHook, workspaceName, securityProvider, indexProvider);
 
@@ -141,7 +134,8 @@ class UserInitializer implements Workspa
             throw new RuntimeException(e);
         }
 
-        return store.getRoot();
+        NodeState target = store.getRoot();
+        target.compareAgainstBaseState(base, new ApplyDiff(builder));
     }
 
 }

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=1525255&r1=1525254&r2=1525255&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
Sat Sep 21 16:07:59 2013
@@ -28,9 +28,7 @@ import org.apache.jackrabbit.oak.spi.com
 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;
 
 public final class OakInitializer {
 
@@ -58,14 +56,15 @@ public final class OakInitializer {
                                   @Nonnull IndexEditorProvider indexEditor,
                                   @Nonnull QueryIndexProvider indexProvider,
                                   @Nonnull CommitHook commitHook) {
-        NodeStoreBranch branch = store.branch();
-        NodeState root = branch.getHead();
+        NodeBuilder builder = store.getRoot().builder();
         for (WorkspaceInitializer wspInit : initializer) {
-            root = wspInit.initialize(root, workspaceName, indexProvider, commitHook);
+            wspInit.initialize(builder, workspaceName, indexProvider, commitHook);
         }
-        branch.setRoot(root);
         try {
-            branch.merge(new EditorHook(new IndexUpdateProvider(indexEditor)), PostCommitHook.EMPTY);
+            store.merge(
+                    builder,
+                    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/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=1525255&r1=1525254&r2=1525255&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
Sat Sep 21 16:07:59 2013
@@ -16,11 +16,9 @@
  */
 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.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 
 /**
  * Initializer of a workspace and it's initial content. A module that needs
@@ -32,10 +30,10 @@ import org.apache.jackrabbit.oak.spi.sta
 public interface WorkspaceInitializer {
 
     WorkspaceInitializer DEFAULT = new WorkspaceInitializer() {
-        @Nonnull
         @Override
-        public NodeState initialize(NodeState workspaceRoot, String workspaceName, QueryIndexProvider
indexProvider, CommitHook commitHook) {
-            return workspaceRoot;
+        public void initialize(
+                NodeBuilder builder, String workspaceName,
+                QueryIndexProvider indexProvider, CommitHook commitHook) {
         }
     };
 
@@ -43,14 +41,13 @@ public interface WorkspaceInitializer {
      * Initialize the content of a new workspace. This method is called before
      * the workspace becomes available.
      *
-     * @param workspaceRoot The workspace root state.
+     * @param builder       builder for accessing and modifying the workspace
      * @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.
      */
-    @Nonnull
-    NodeState initialize(NodeState workspaceRoot, 
+    void initialize(NodeBuilder builder, 
                          String workspaceName,
                          QueryIndexProvider indexProvider,
                          CommitHook commitHook);



Mime
View raw message