jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1508051 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/core/ main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/ main/java/org/apache/jackrabbit/oak/security/privilege/ main/java/org/apache/jackrabbit/...
Date Mon, 29 Jul 2013 13:32:23 GMT
Author: mduerig
Date: Mon Jul 29 13:32:22 2013
New Revision: 1508051

URL: http://svn.apache.org/r1508051
Log:
OAK-932: RootImpl to AbstractRoot
Promote SystemRoot to top level class

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SystemRoot.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.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/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/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1508051&r1=1508050&r2=1508051&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Mon Jul 29 13:32:22 2013
@@ -32,7 +32,6 @@ import java.util.List;
 import javax.annotation.Nonnull;
 import javax.security.auth.Subject;
 
-import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.BlobFactory;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
@@ -43,7 +42,6 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.index.diffindex.UUIDDiffIndexProviderWrapper;
 import org.apache.jackrabbit.oak.query.QueryEngineImpl;
-import org.apache.jackrabbit.oak.security.authentication.SystemSubject;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
@@ -52,10 +50,8 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.commit.PostCommitHook;
 import org.apache.jackrabbit.oak.spi.commit.PostValidationHook;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
-import org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.security.Context;
-import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConfiguration;
@@ -153,18 +149,7 @@ public class RootImpl implements Root {
         secureBuilder = new SecureNodeBuilder(builder, getPermissionProvider(), getAcContext());
         rootTree = new MutableTree(this, secureBuilder, lastMove);
     }
-
-    // TODO: review if these constructors really make sense and cannot be replaced.
-    public RootImpl(NodeStore store) {
-        this(store, EmptyHook.INSTANCE);
-    }
-
-    public RootImpl(NodeStore store, CommitHook hook) {
-        // FIXME: define proper default or pass workspace name with the constructor
-        this(store, hook, PostCommitHook.EMPTY, Oak.DEFAULT_WORKSPACE_NAME, SystemSubject.INSTANCE,
-                new OpenSecurityProvider(), new CompositeQueryIndexProvider());
-    }
-
+ 
     /**
      * Called whenever a method on this instance or on any {@code Tree} instance
      * obtained from this {@code Root} is called. This default implementation

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SystemRoot.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SystemRoot.java?rev=1508051&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SystemRoot.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SystemRoot.java
Mon Jul 29 13:32:22 2013
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.core;
+
+import org.apache.jackrabbit.oak.Oak;
+import org.apache.jackrabbit.oak.api.AuthInfo;
+import org.apache.jackrabbit.oak.api.ContentSession;
+import org.apache.jackrabbit.oak.api.Root;
+import org.apache.jackrabbit.oak.security.authentication.SystemSubject;
+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.query.CompositeQueryIndexProvider;
+import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
+import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
+import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
+import org.apache.jackrabbit.oak.spi.security.authentication.AuthInfoImpl;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+
+/**
+ *  Internal extension of the {@link RootImpl} to be used
+ *  when an usage of the system internal subject is needed.
+ */
+public class SystemRoot extends RootImpl {
+
+    public SystemRoot(NodeStore store, CommitHook hook, String workspaceName,
+            SecurityProvider securityProvider, QueryIndexProvider indexProvider) {
+        super(store, hook, PostCommitHook.EMPTY, workspaceName,
+                SystemSubject.INSTANCE, securityProvider, indexProvider);
+    }
+
+    public SystemRoot(NodeStore store) {
+        this(store, EmptyHook.INSTANCE);
+    }
+
+    public SystemRoot(NodeStore store, CommitHook hook) {
+        // FIXME: define proper default or pass workspace name with the
+        // constructor
+        this(store, hook, Oak.DEFAULT_WORKSPACE_NAME,
+                new OpenSecurityProvider(), new CompositeQueryIndexProvider());
+    }
+
+    @Override
+    public ContentSession getContentSession() {
+        return new ContentSession() {
+
+            @Override
+            public void close() {
+            }
+
+            @Override
+            public String getWorkspaceName() {
+                return SystemRoot.this.getWorkspaceName();
+            }
+
+            @Override
+            public Root getLatestRoot() {
+                throw new UnsupportedOperationException();
+            }
+
+            @Override
+            public AuthInfo getAuthInfo() {
+               return new AuthInfoImpl(null, null, SystemSubject.INSTANCE.getPrincipals());
  
+            }
+        };
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SystemRoot.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SystemRoot.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

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=1508051&r1=1508050&r2=1508051&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
Mon Jul 29 13:32:22 2013
@@ -21,7 +21,7 @@ import org.apache.felix.scr.annotations.
 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.RootImpl;
+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;
@@ -81,7 +81,7 @@ public class InitialContent implements R
         } catch (CommitFailedException e) {
             throw new RuntimeException(e);
         }
-        BuiltInNodeTypes.register(new RootImpl(store, new EditorHook(new RegistrationEditorProvider())));
+        BuiltInNodeTypes.register(new SystemRoot(store, new EditorHook(new RegistrationEditorProvider())));
         return store.getRoot();
     }
 

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=1508051&r1=1508050&r2=1508051&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
Mon Jul 29 13:32:22 2013
@@ -22,7 +22,7 @@ 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.RootImpl;
+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;
@@ -67,7 +67,7 @@ class PrivilegeInitializer implements Re
             }
 
             try {
-                new PrivilegeDefinitionWriter(new RootImpl(store)).writeBuiltInDefinitions();
+                new PrivilegeDefinitionWriter(new SystemRoot(store)).writeBuiltInDefinitions();
             } catch (RepositoryException e) {
                 log.error("Failed to register built-in privileges", e);
                 throw new RuntimeException(e);

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=1508051&r1=1508050&r2=1508051&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
Mon Jul 29 13:32:22 2013
@@ -16,24 +16,19 @@
  */
 package org.apache.jackrabbit.oak.security.user;
 
-import java.security.Principal;
-import java.util.Set;
+
 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.AuthInfo;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.Root;
-import org.apache.jackrabbit.oak.core.RootImpl;
+import org.apache.jackrabbit.oak.core.SystemRoot;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 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.security.authentication.SystemSubject;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
 import org.apache.jackrabbit.oak.spi.commit.PostCommitHook;
@@ -44,14 +39,12 @@ import org.apache.jackrabbit.oak.spi.sec
 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.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 import org.apache.jackrabbit.oak.util.NodeUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
 
 /**
  * Creates initial set of users to be present in a given workspace. This
@@ -105,7 +98,7 @@ class UserInitializer implements Workspa
             throw new RuntimeException(e);
         }
 
-        Root root = new SystemRootImpl(store, commitHook, workspaceName, securityProvider,
indexProvider);
+        Root root = new SystemRoot(store, commitHook, workspaceName, securityProvider, indexProvider);
 
         UserConfiguration userConfiguration = securityProvider.getConfiguration(UserConfiguration.class);
         UserManager userManager = userConfiguration.getUserManager(root, NamePathMapper.DEFAULT);
@@ -149,71 +142,4 @@ class UserInitializer implements Workspa
         }
         return store.getRoot();
     }
-
-    //--------------------------------------------------------< inner class >---
-
-    private class SystemRootImpl extends RootImpl {
-
-        private SystemRootImpl(NodeStore store, CommitHook hook,
-                               String workspaceName,
-                               SecurityProvider securityProvider,
-                               QueryIndexProvider indexProvider) {
-            super(store, hook, PostCommitHook.EMPTY, workspaceName, SystemSubject.INSTANCE,
-                    securityProvider, indexProvider);
-        }
-
-        @Override
-        public ContentSession getContentSession() {
-            return new ContentSession() {
-
-                private volatile boolean live = true;
-
-                private void checkLive() {
-                    checkState(live, "This session has been closed");
-                }
-
-                @Override
-                public void close() {
-                    live = false;
-                }
-
-                @Override
-                public String getWorkspaceName() {
-                    return SystemRootImpl.this.getWorkspaceName();
-                }
-
-                @Override
-                public Root getLatestRoot() {
-                    checkLive();
-                    return SystemRootImpl.this;
-                }
-
-                @Override
-                public AuthInfo getAuthInfo() {
-                    return new AuthInfo() {
-
-                        @Override
-                        public String getUserID() {
-                            return null;
-                        }
-
-                        @Override
-                        public Set<Principal> getPrincipals() {
-                            return SystemSubject.INSTANCE.getPrincipals();
-                        }
-
-                        @Override
-                        public String[] getAttributeNames() {
-                            return new String[]{};
-                        }
-
-                        @Override
-                        public Object getAttribute(String attributeName) {
-                            return null;
-                        }
-                    };
-                }
-            };
-        }
-    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java?rev=1508051&r1=1508050&r2=1508051&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
Mon Jul 29 13:32:22 2013
@@ -73,12 +73,12 @@ public class RootImplFuzzIT {
         MicroKernel mk1 = new MicroKernelImpl("./target/mk1/" + random.nextInt());
         store1 = new KernelNodeStore(mk1);
         mk1.commit("", "+\"/root\":{}", mk1.getHeadRevision(), "");
-        root1 = new RootImpl(store1);
+        root1 = new SystemRoot(store1);
 
         MicroKernel mk2 = new MicroKernelImpl("./target/mk2/" + random.nextInt());
         store2 = new KernelNodeStore(mk2);
         mk2.commit("", "+\"/root\":{}", mk2.getHeadRevision(), "");
-        root2 = new RootImpl(store2);
+        root2 = new SystemRoot(store2);
     }
 
     @Test



Mime
View raw message