]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-4979: Move method getDatabaseName() which returns the database name for a...
authorRichard Millet <remillet@berkeley.edu>
Fri, 14 Dec 2012 20:18:04 +0000 (12:18 -0800)
committerRichard Millet <remillet@berkeley.edu>
Fri, 14 Dec 2012 20:18:04 +0000 (12:18 -0800)
services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java
services/config/src/main/java/org/collectionspace/services/common/config/ConfigUtils.java

index 0d0ac8e833676a91f954dd15faf8a4bfccab6fea..4074db550cced8b033ddf420037b61a13f1932d8 100644 (file)
@@ -19,6 +19,7 @@ package org.collectionspace.services.common.storage;
 \r
 import org.collectionspace.services.common.api.Tools;\r
 import org.collectionspace.services.common.config.ConfigUtils;\r
+import org.collectionspace.services.config.tenant.TenantBindingType;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
@@ -115,17 +116,7 @@ public class JDBCTools {
             logger.error(errMsg);\r
             throw new NamingException(errMsg);\r
         }\r
-       \r
-       // FIXME: REM - We can rid ourselves of this special case by using the DEFAULT_NUXEO_DATABASE_NAME as the default\r
-       // value for the "repositoryName" attribute in the tenant bindings XSD (XML Schema) definition.\r
-       //\r
-       // *Special Case* - Nuxeo's default repository name is "default" but the database is called "nuxeo"\r
-       //\r
-       if (dataSourceName.equals(JDBCTools.NUXEO_DATASOURCE_NAME) &&\r
-                       repositoryName.equals(JDBCTools.DEFAULT_NUXEO_REPOSITORY_NAME)) {\r
-               repositoryName = DEFAULT_NUXEO_DATABASE_NAME;\r
-       }\r
-        \r
+               \r
        /*\r
         * We synch this block as a workaround to not have separate DataSource instances for\r
         * each Nuxeo repo/DB.  Ideally, we should replace the need for this synch block by\r
@@ -141,7 +132,8 @@ public class JDBCTools {
                                (org.apache.tomcat.dbcp.dbcp.BasicDataSource)getDataSource(dataSourceName);\r
                // Get the template URL value from the JNDI datasource and substitute the databaseName\r
                String urlTemplate = dataSource.getUrl();\r
-               String connectionUrl = urlTemplate.replace(URL_DATABASE_NAME, repositoryName);\r
+               String databaseName = getDatabaseName(repositoryName);\r
+               String connectionUrl = urlTemplate.replace(URL_DATABASE_NAME, databaseName);\r
                dataSource.setUrl(connectionUrl);\r
                \r
                try {\r
@@ -290,6 +282,20 @@ public class JDBCTools {
         return result;\r
     }\r
     \r
+    /*\r
+     * By convention, the repository name and database name are the same.  However, this\r
+     * call encapulates that convention and allows overrides.\r
+     */\r
+    public static String getDatabaseName(String repoName) {\r
+       String result = repoName;\r
+       \r
+       if (result.equalsIgnoreCase(DEFAULT_NUXEO_REPOSITORY_NAME) == true) {\r
+               result = DEFAULT_NUXEO_DATABASE_NAME;\r
+       }\r
+       \r
+       return result;\r
+    }\r
+    \r
     /**\r
      * Returns the catalog name for an open JDBC connection.\r
      * \r
index 0957ca05b6cf444197ea891a4667a53f990c99f8..f7e17dcfb8c9c4dfa5dde13acedd15c8a526a659 100644 (file)
@@ -32,21 +32,7 @@ public class ConfigUtils {
                
        return result;
     }
-    
-    /*
-     * By convention, the repository name and database name are the same.  However, this
-     * call encapulates that convention and allows overrides.
-     */
-    public static String getDatabaseName(TenantBindingType tenantBindingType, String domainName) {
-       String result = getRepositoryName(tenantBindingType, domainName);
-       
-       if (result.equalsIgnoreCase(DEFAULT_NUXEO_REPOSITORY_NAME) == true) {
-               result = DEFAULT_NUXEO_DATABASE_NAME;
-       }
-       
-       return result;
-    }
-    
+        
     public static String getRepositoryName(TenantBindingType tenantBindingType, String domainName) {
                String result = null;