jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1446162 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/Oak.java main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java test/java/org/apache/jackrabbit/oak/OakTest.java
Date Thu, 14 Feb 2013 13:11:55 GMT
Author: angela
Date: Thu Feb 14 13:11:55 2013
New Revision: 1446162

URL: http://svn.apache.org/r1446162
Log:
OAK-625 : Ability to pass workspace name to a CommitHook (wip)

- move definition of default workspacename completely to OAK.java
- add test for Oak#with(String defaultWorkspaceName)

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/OakTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java?rev=1446162&r1=1446161&r2=1446162&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java Thu Feb
14 13:11:55 2013
@@ -62,6 +62,11 @@ import static com.google.common.collect.
  */
 public class Oak {
 
+    /**
+     * Constant for the default workspace name
+     */
+    public static final String DEFAULT_WORKSPACE_NAME = "default";
+
     private final MicroKernel kernel;
 
     private final List<RepositoryInitializer> initializers = newArrayList();
@@ -79,7 +84,7 @@ public class Oak {
     // TODO: review if we really want to have the OpenSecurityProvider as default.
     private SecurityProvider securityProvider = new OpenSecurityProvider();
 
-    private String defaultWorkspaceName;
+    private String defaultWorkspaceName = DEFAULT_WORKSPACE_NAME;
 
     public Oak(MicroKernel kernel) {
         this.kernel = kernel;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java?rev=1446162&r1=1446161&r2=1446162&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
Thu Feb 14 13:11:55 2013
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.oak.core;
 
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 import javax.jcr.Credentials;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.security.auth.login.LoginException;
@@ -37,8 +38,6 @@ import org.apache.jackrabbit.oak.spi.sta
  */
 public class ContentRepositoryImpl implements ContentRepository {
 
-    private static final String DEFAULT_WORKSPACE_NAME = "default";
-
     private final String defaultWorkspaceName;
     private final SecurityProvider securityProvider;
     private final QueryIndexProvider indexProvider;
@@ -51,15 +50,14 @@ public class ContentRepositoryImpl imple
      * @param nodeStore            the node store this repository is based upon.
      * @param defaultWorkspaceName the default workspace name;
      * @param indexProvider        index provider
-     * @param securityProvider     The configured security provider or {@code null} if
-     *                             default implementations should be used.
+     * @param securityProvider     The configured security provider.
      */
-    public ContentRepositoryImpl(NodeStore nodeStore,
-                                 String defaultWorkspaceName,
-                                 QueryIndexProvider indexProvider,
-                                 SecurityProvider securityProvider) {
+    public ContentRepositoryImpl(@Nonnull NodeStore nodeStore,
+                                 @Nonnull String defaultWorkspaceName,
+                                 @Nullable QueryIndexProvider indexProvider,
+                                 @Nonnull SecurityProvider securityProvider) {
         this.nodeStore = nodeStore;
-        this.defaultWorkspaceName = (defaultWorkspaceName == null) ? DEFAULT_WORKSPACE_NAME
: defaultWorkspaceName;
+        this.defaultWorkspaceName = defaultWorkspaceName;
         this.indexProvider = indexProvider != null ? indexProvider : new CompositeQueryIndexProvider();
         this.securityProvider = securityProvider;
     }
@@ -73,7 +71,7 @@ public class ContentRepositoryImpl imple
         }
 
         // TODO: support multiple workspaces. See OAK-118
-        if (!DEFAULT_WORKSPACE_NAME.equals(workspaceName)) {
+        if (!defaultWorkspaceName.equals(workspaceName)) {
             throw new NoSuchWorkspaceException(workspaceName);
         }
 

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/OakTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/OakTest.java?rev=1446162&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/OakTest.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/OakTest.java Thu
Feb 14 13:11:55 2013
@@ -0,0 +1,67 @@
+/*
+ * 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;
+
+import javax.jcr.NoSuchWorkspaceException;
+
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.api.ContentSession;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * OakTest... TODO
+ */
+public class OakTest {
+
+    @Test
+    public void testWithDefaultWorkspaceName() throws Exception {
+        ContentRepository repo = new Oak().with("test").createContentRepository();
+
+        String[] valid = new String[] {null, "test"};
+        for (String wspName : valid) {
+            ContentSession cs = null;
+            try {
+                cs = repo.login(null, wspName);
+                assertEquals("test", cs.getWorkspaceName());
+            } finally {
+                if (cs != null) {
+                    cs.close();
+                }
+            }
+        }
+
+        String[] invalid = new String[] {"", "another", Oak.DEFAULT_WORKSPACE_NAME};
+        for (String wspName : invalid) {
+            ContentSession cs = null;
+            try {
+                cs = repo.login(null, wspName);
+                fail("invalid workspace nam");
+            } catch (NoSuchWorkspaceException e) {
+                // success
+            } finally {
+                if (cs != null) {
+                    cs.close();
+                }
+            }
+        }
+
+    }
+
+}
\ No newline at end of file



Mime
View raw message