jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1438100 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: Oak.java core/ContentRepositoryImpl.java
Date Thu, 24 Jan 2013 17:42:39 GMT
Author: angela
Date: Thu Jan 24 17:42:39 2013
New Revision: 1438100

URL: http://svn.apache.org/viewvc?rev=1438100&view=rev
Log:
OAK-589 : Make default workspace name configurable

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=1438100&r1=1438099&r2=1438100&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 Jan
24 17:42:39 2013
@@ -84,6 +84,8 @@ public class Oak {
 
     private ConflictHandler conflictHandler;
 
+    private String defaultWorkspaceName;
+
     public Oak(MicroKernel kernel) {
         this.kernel = kernel;
     }
@@ -92,10 +94,24 @@ public class Oak {
         this(new MicroKernelImpl());
     }
 
+    /**
+     * Sets the default workspace name that should be used in case of login
+     * with {@code null} workspace name. If this method has not been called
+     * some internal default value will be used.
+     *
+     * @param defaultWorkspaceName The name of the default workspace.
+     * @return this builder.
+     */
+    @Nonnull
+    public Oak with(@Nonnull String defaultWorkspaceName) {
+        this.defaultWorkspaceName = defaultWorkspaceName;
+        return this;
+    }
+
     @Nonnull
     public Oak with(@Nonnull RepositoryInitializer initializer) {
-       initializers.add(checkNotNull(initializer));
-       return this;
+        initializers.add(checkNotNull(initializer));
+        return this;
     }
 
     /**
@@ -233,6 +249,7 @@ public class Oak {
 
         return new ContentRepositoryImpl(
                 store,
+                defaultWorkspaceName,
                 conflictHandler,
                 CompositeQueryIndexProvider.compose(queryIndexProviders),
                 securityProvider);

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=1438100&r1=1438099&r2=1438100&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 Jan 24 17:42:39 2013
@@ -21,7 +21,6 @@ import javax.jcr.Credentials;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.security.auth.login.LoginException;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
@@ -36,7 +35,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * {@link MicroKernel}-based implementation of
+ * {@code MicroKernel}-based implementation of
  * the {@link ContentRepository} interface.
  */
 public class ContentRepositoryImpl implements ContentRepository {
@@ -46,9 +45,9 @@ public class ContentRepositoryImpl imple
      */
     private static final Logger LOG = LoggerFactory.getLogger(ContentRepositoryImpl.class);
 
-    // FIXME OAK-589 : retrieve default wsp-name from configuration
     private static final String DEFAULT_WORKSPACE_NAME = "default";
 
+    private final String defaultWorkspaceName;
     private final SecurityProvider securityProvider;
     private final QueryIndexProvider indexProvider;
     private final NodeStore nodeStore;
@@ -59,16 +58,19 @@ public class ContentRepositoryImpl imple
      * initialized components.
      *
      * @param nodeStore        the node store this repository is based upon.
+     * @param defaultWorkspaceName the default workspace name;
      * @param conflictHandler  The conflict handler.
      * @param indexProvider    index provider
      * @param securityProvider The configured security provider or {@code null} if
      *                         default implementations should be used.
      */
     public ContentRepositoryImpl(NodeStore nodeStore,
+                                 String defaultWorkspaceName,
                                  ConflictHandler conflictHandler,
                                  QueryIndexProvider indexProvider,
                                  SecurityProvider securityProvider) {
         this.nodeStore = nodeStore;
+        this.defaultWorkspaceName = (defaultWorkspaceName == null) ? DEFAULT_WORKSPACE_NAME
: defaultWorkspaceName;
         this.conflictHandler = conflictHandler;
         this.indexProvider = indexProvider != null ? indexProvider : new CompositeQueryIndexProvider();
         this.securityProvider = securityProvider;
@@ -79,7 +81,7 @@ public class ContentRepositoryImpl imple
     public ContentSession login(Credentials credentials, String workspaceName)
             throws LoginException, NoSuchWorkspaceException {
         if (workspaceName == null) {
-            workspaceName = DEFAULT_WORKSPACE_NAME;
+            workspaceName = defaultWorkspaceName;
         }
 
         // TODO: support multiple workspaces. See OAK-118



Mime
View raw message