From: Richard Millet Date: Fri, 14 Dec 2012 19:49:46 +0000 (-0800) Subject: CSPACE-4979: Added method to ConfigUtils class called getDatabaseName() which returns... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=ae4d73bf82ede83a7dfed1e4f1ae0e312b3b5ad4;p=tmp%2Fjakarta-migration.git CSPACE-4979: Added method to ConfigUtils class called getDatabaseName() which returns the database name for a given tenant bindings repo domain. --- 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 614ab3a7b..0d0ac8e83 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 @@ -18,6 +18,7 @@ package org.collectionspace.services.common.storage; import org.collectionspace.services.common.api.Tools; +import org.collectionspace.services.common.config.ConfigUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,9 +42,9 @@ public class JDBCTools { public static String CSPACE_DATASOURCE_NAME = "CspaceDS"; public static String NUXEO_DATASOURCE_NAME = "NuxeoDS"; // Default database names - public static String DEFAULT_CSPACE_DATABASE_NAME = "cspace"; - public static String DEFAULT_NUXEO_REPOSITORY_NAME = "default"; - public static String DEFAULT_NUXEO_DATABASE_NAME = "nuxeo"; + public static String DEFAULT_CSPACE_DATABASE_NAME = ConfigUtils.DEFAULT_CSPACE_DATABASE_NAME; + public static String DEFAULT_NUXEO_REPOSITORY_NAME = ConfigUtils.DEFAULT_NUXEO_REPOSITORY_NAME; + public static String DEFAULT_NUXEO_DATABASE_NAME = ConfigUtils.DEFAULT_NUXEO_DATABASE_NAME; // // Private constants // 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 3e8c4e1a5..0957ca05b 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 @@ -11,6 +11,11 @@ import org.slf4j.LoggerFactory; public class ConfigUtils { final static Logger logger = LoggerFactory.getLogger(ConfigUtils.class); + // Default database names + public static String DEFAULT_CSPACE_DATABASE_NAME = "cspace"; + public static String DEFAULT_NUXEO_REPOSITORY_NAME = "default"; + public static String DEFAULT_NUXEO_DATABASE_NAME = "nuxeo"; + /* * Returns the list of repository/DB names defined by a tenant bindings file */ @@ -28,6 +33,20 @@ 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;