jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r156420 - incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
Date Mon, 07 Mar 2005 12:32:38 GMT
Author: jukka
Date: Mon Mar  7 04:32:38 2005
New Revision: 156420

URL: http://svn.apache.org/viewcvs?view=rev&rev=156420
Log:
Oops, forgot to include the default workspace creation code. (JCR-53)

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/RepositoryConfig.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/RepositoryConfig.java?view=diff&r1=156419&r2=156420
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
Mon Mar  7 04:32:38 2005
@@ -105,7 +105,7 @@
      * a subfolder with a workspace configuration file for every workspace
      * in the repository)
      */
-    private String wspConfigRootDir;
+    private String workspaceDirectory;
 
     /**
      * name of default workspace
@@ -120,7 +120,7 @@
     /**
      * the versioning config
      */
-    private VersioningConfig vConfig;
+    private VersioningConfig vc;
 
     public RepositoryConfig(
             Element config, ConfigurationParser parser,
@@ -133,25 +133,27 @@
         this.appName = name;
         this.wspConfigs = new HashMap();
         this.fsc = fsc;
-        this.wspConfigRootDir = root;
+        this.workspaceDirectory = root;
         this.defaultWspName = defaultWspName;
         this.amConfig = amc;
-        this.vConfig = vc;
+        this.vc = vc;
     }
 
     private void init() throws ConfigurationException {
         fsc.init();
-        vConfig.init();
+        vc.init();
 
-        File root = new File(wspConfigRootDir);
-        if (!root.exists()) {
-            root.mkdirs();
+        // Get the workspace root directory (create it if not found)
+        File directory = new File(workspaceDirectory);
+        if (!directory.exists()) {
+            directory.mkdirs();
         }
 
-        File[] files = root.listFiles();
+        // Get all workspace subdirectories
+        File[] files = directory.listFiles();
         if (files == null) {
             throw new ConfigurationException(
-                    "Invalid workspace root directory: " + wspConfigRootDir);
+                    "Invalid workspace root directory: " + workspaceDirectory);
         }
 
         for (int i = 0; i < files.length; i++) {
@@ -161,6 +163,15 @@
                 addWorkspaceConfig(config);
             }
         }
+
+        if (wspConfigs.isEmpty()) {
+            // create initial default workspace
+            createWorkspaceConfig(defaultWspName);
+        } else if (!wspConfigs.containsKey(defaultWspName)) {
+            throw new ConfigurationException(
+                    "no configuration found for default workspace: "
+                    + defaultWspName);
+        }
     }
 
     private WorkspaceConfig loadWorkspaceConfig(File directory)
@@ -205,7 +216,7 @@
     public synchronized WorkspaceConfig createWorkspaceConfig(String name)
             throws ConfigurationException {
         // create the workspace folder (i.e. the workspace home directory)
-        File wspFolder = new File(wspConfigRootDir, name);
+        File wspFolder = new File(workspaceDirectory, name);
         if (!wspFolder.mkdir()) {
             String msg = "Failed to create the workspace home directory: " + wspFolder.getPath();
             throw new ConfigurationException(msg);
@@ -290,7 +301,7 @@
      * @return the workspaces config root directory
      */
     public String getWorkspacesConfigRootDir() {
-        return wspConfigRootDir;
+        return workspaceDirectory;
     }
 
     /**
@@ -328,7 +339,7 @@
      * @return a <code>VersioningConfig</code> object
      */
     public VersioningConfig getVersioningConfig() {
-        return vConfig;
+        return vc;
     }
 
     /**



Mime
View raw message