From: Richard Millet Date: Fri, 14 Dec 2012 20:18:04 +0000 (-0800) Subject: CSPACE-4979: Move method getDatabaseName() which returns the database name for a... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=f25e3e3fa69e35b68a1f8685e494022e2fa2d117;p=tmp%2Fjakarta-migration.git CSPACE-4979: Move method getDatabaseName() which returns the database name for a given tenant bindings repo domain from ConfigUtils to JDBCTools class. --- diff --git a/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java b/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java index 0d0ac8e83..4074db550 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java +++ b/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java @@ -19,6 +19,7 @@ package org.collectionspace.services.common.storage; import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.config.ConfigUtils; +import org.collectionspace.services.config.tenant.TenantBindingType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -115,17 +116,7 @@ public class JDBCTools { logger.error(errMsg); throw new NamingException(errMsg); } - - // FIXME: REM - We can rid ourselves of this special case by using the DEFAULT_NUXEO_DATABASE_NAME as the default - // value for the "repositoryName" attribute in the tenant bindings XSD (XML Schema) definition. - // - // *Special Case* - Nuxeo's default repository name is "default" but the database is called "nuxeo" - // - if (dataSourceName.equals(JDBCTools.NUXEO_DATASOURCE_NAME) && - repositoryName.equals(JDBCTools.DEFAULT_NUXEO_REPOSITORY_NAME)) { - repositoryName = DEFAULT_NUXEO_DATABASE_NAME; - } - + /* * We synch this block as a workaround to not have separate DataSource instances for * each Nuxeo repo/DB. Ideally, we should replace the need for this synch block by @@ -141,7 +132,8 @@ public class JDBCTools { (org.apache.tomcat.dbcp.dbcp.BasicDataSource)getDataSource(dataSourceName); // Get the template URL value from the JNDI datasource and substitute the databaseName String urlTemplate = dataSource.getUrl(); - String connectionUrl = urlTemplate.replace(URL_DATABASE_NAME, repositoryName); + String databaseName = getDatabaseName(repositoryName); + String connectionUrl = urlTemplate.replace(URL_DATABASE_NAME, databaseName); dataSource.setUrl(connectionUrl); try { @@ -290,6 +282,20 @@ public class JDBCTools { 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(String repoName) { + String result = repoName; + + if (result.equalsIgnoreCase(DEFAULT_NUXEO_REPOSITORY_NAME) == true) { + result = DEFAULT_NUXEO_DATABASE_NAME; + } + + return result; + } + /** * Returns the catalog name for an open JDBC connection. * diff --git a/services/config/src/main/java/org/collectionspace/services/common/config/ConfigUtils.java b/services/config/src/main/java/org/collectionspace/services/common/config/ConfigUtils.java index 0957ca05b..f7e17dcfb 100644 --- a/services/config/src/main/java/org/collectionspace/services/common/config/ConfigUtils.java +++ b/services/config/src/main/java/org/collectionspace/services/common/config/ConfigUtils.java @@ -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;