*/\r
public String createWhereClauseForPartialMatch(String dataSourceName,\r
String repositoryName,\r
+ String cspaceInstanceId,\r
String field,\r
boolean startingWildcard,\r
String partialTerm);\r
import org.collectionspace.services.common.config.ConfigUtils;\r
import org.collectionspace.services.common.config.ServicesConfigReaderImpl;\r
import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;\r
+import org.collectionspace.services.common.context.ServiceBindingUtils;\r
import org.collectionspace.services.common.init.AddIndices;\r
import org.collectionspace.services.config.service.InitHandler.Params.Field;\r
import org.collectionspace.services.common.init.IInitHandler;\r
throw new RuntimeException("Unknown CollectionSpace services client type: " + getClientType());\r
}\r
//\r
- // Create all the default user accounts and permissions\r
+ // Create all the default user accounts and permissions. Since some of our "cspace" database config files\r
+ // for Spring need to be created at build time, the "cspace" database already will be suffixed with the\r
+ // correct 'cspaceInstanceId' so we don't need to pass it to the JDBCTools methods.\r
//\r
try {\r
AuthorizationCommon.createDefaultWorkflowPermissions(tenantBindingConfigReader);\r
String cspaceDatabaseName = getCspaceDatabaseName();\r
- DatabaseProductType databaseProductType = JDBCTools.getDatabaseProductType(JDBCTools.CSPACE_DATASOURCE_NAME, cspaceDatabaseName);\r
+ DatabaseProductType databaseProductType = JDBCTools.getDatabaseProductType(JDBCTools.CSPACE_DATASOURCE_NAME,\r
+ cspaceDatabaseName);\r
AuthorizationCommon.createDefaultAccounts(tenantBindingConfigReader, databaseProductType,\r
cspaceDatabaseName);\r
} catch (Exception e) {\r
//\r
//Loop through all tenants in tenant-bindings.xml\r
//\r
+ String cspaceInstanceId = getCspaceInstanceId();\r
for (TenantBindingType tbt : tenantBindingTypeMap.values()) {\r
List<String> repositoryNameList = ConfigUtils.getRepositoryNameList(tbt);\r
if (repositoryNameList != null && repositoryNameList.isEmpty() == false) {\r
// 1\r
fields.add(field);\r
}\r
- addindices.onRepositoryInitialized(JDBCTools.NUXEO_DATASOURCE_NAME, repositoryName, null, fields, null);\r
+ addindices.onRepositoryInitialized(JDBCTools.NUXEO_DATASOURCE_NAME, repositoryName, cspaceInstanceId,\r
+ null, fields, null);\r
}\r
} else {\r
String errMsg = "repositoryNameList was empty or null.";\r
//\r
//Loop through all tenants in tenant-bindings.xml\r
//\r
+ String cspaceInstanceId = getCspaceInstanceId();\r
for (TenantBindingType tbt : tenantBindingTypeMap.values()) {\r
//\r
//Loop through all the services in this tenant\r
//\r
List<ServiceBindingType> sbtList = tbt.getServiceBindings();\r
for (ServiceBindingType sbt: sbtList) {\r
- String repositoryName = ConfigUtils.getRepositoryName(tbt, sbt.getRepositoryDomain()); // Each service can have a different repo domain\r
+ String repositoryName = null;\r
+ if (sbt.getType().equalsIgnoreCase(ServiceBindingUtils.SERVICE_TYPE_SECURITY) == false) {\r
+ repositoryName = ConfigUtils.getRepositoryName(tbt, sbt.getRepositoryDomain()); // Each service can have a different repo domain\r
+ }\r
//Get the list of InitHandler elements, extract the first one (only one supported right now) and fire it using reflection.\r
List<org.collectionspace.services.config.service.InitHandler> list = sbt.getInitHandler();\r
if (list != null && list.size() > 0) {\r
Object o = instantiate(initHandlerClassname, IInitHandler.class);\r
if (o != null && o instanceof IInitHandler){\r
IInitHandler handler = (IInitHandler)o;\r
- handler.onRepositoryInitialized(JDBCTools.NUXEO_DATASOURCE_NAME, repositoryName, sbt, fields, props);\r
+ handler.onRepositoryInitialized(JDBCTools.NUXEO_DATASOURCE_NAME, repositoryName, cspaceInstanceId,\r
+ sbt, fields, props);\r
//The InitHandler may be the default one,\r
// or specialized classes which still implement this interface and are registered in tenant-bindings.xml.\r
}\r
TenantBindingConfigReaderImpl tenantBindingConfigReader,\r
DatabaseProductType databaseProductType,\r
String cspaceDatabaseName) throws Exception {\r
- if (logger.isDebugEnabled()) {\r
- logger.debug("ServiceMain.createDefaultAccounts starting...");\r
- }\r
+\r
+ logger.debug("ServiceMain.createDefaultAccounts starting...");\r
\r
- String cspaceDbName = tenantBindingConfigReader.getRepositoryDomain(null).getStorageName();\r
Hashtable<String, String> tenantInfo = getTenantNamesFromConfig(tenantBindingConfigReader);\r
- \r
Connection conn = null;\r
// TODO - need to put in tests for existence first.\r
// We could just look for the accounts per tenant up front, and assume that\r
}\r
\r
if (result == null) {\r
- logger.warn("Could not retrieve a lifecycle transition definition list from: "\r
- + serviceBinding.getName()\r
- + " with tenant ID = "\r
- + tenantBinding.getId()); \r
+ if (serviceBinding.getType().equalsIgnoreCase(ServiceBindingUtils.SERVICE_TYPE_SECURITY) == false) {\r
+ logger.warn("Could not retrieve a lifecycle transition definition list from: "\r
+ + serviceBinding.getName()\r
+ + " with tenant ID = "\r
+ + tenantBinding.getId());\r
+ }\r
// return an empty list \r
result = new TransitionDefList();\r
} else {\r
- logger.debug("Successfully etrieved a lifecycle transition definition list from: "\r
+ logger.debug("Successfully retrieved a lifecycle transition definition list from: "\r
+ serviceBinding.getName()\r
+ " with tenant ID = "\r
+ tenantBinding.getId());\r
import java.util.List;
import org.apache.commons.io.FileUtils;
-import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.api.JEEServerDeployment;
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.config.service.ServiceBindingType;
import org.nuxeo.ecm.core.api.ClientException;\r
import org.nuxeo.ecm.core.api.DocumentModel;\r
import java.lang.IndexOutOfBoundsException;\r
-import java.util.GregorianCalendar;\r
-import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;\r
import org.collectionspace.services.common.api.Tools;\r
import org.collectionspace.services.common.document.DocumentUtils;\r
import org.slf4j.Logger;\r
@Override\r
public void onRepositoryInitialized(String dataSourceName,\r
String repositoryName,\r
+ String cspaceInstanceId,\r
ServiceBindingType sbt, \r
List<Field> fields, \r
List<Property> properties) throws Exception {\r
if(Tools.notEmpty(param) && (param.indexOf(',')>-1)){\r
String[] fieldNames = param.split(",");\r
for (String fn: fieldNames){\r
- rows = addOneIndex(dataSourceName, repositoryName, tableName, fn);\r
+ rows = addOneIndex(dataSourceName, repositoryName, cspaceInstanceId, tableName, fn);\r
}\r
} else {\r
- rows = addOneIndex(dataSourceName, repositoryName, tableName, fieldName);\r
+ rows = addOneIndex(dataSourceName, repositoryName, cspaceInstanceId, tableName, fieldName);\r
}\r
}\r
}\r
\r
private int addOneIndex(String dataSourceName,\r
- String repositoryName, \r
+ String repositoryName,\r
+ String cspaceInstanceId,\r
String tableName, \r
String columnName) {\r
int rows = 0;\r
String indexName = tableName + INDEX_SEP + columnName + INDEX_SUFFIX;\r
try {\r
DatabaseProductType databaseProductType = JDBCTools.getDatabaseProductType(dataSourceName, repositoryName);\r
- if (indexExists(dataSourceName, repositoryName, databaseProductType,\r
+ if (indexExists(dataSourceName, repositoryName, cspaceInstanceId, databaseProductType,\r
tableName, columnName, indexName)) {\r
logger.trace("Index already exists for column " + columnName\r
+ " in table " + tableName);\r
//\r
// If this assumption is no longer valid, we might instead\r
// identify the relevant repository from the table name here.\r
- rows = JDBCTools.executeUpdate(dataSourceName, repositoryName, sql);\r
+ rows = JDBCTools.executeUpdate(dataSourceName, repositoryName, cspaceInstanceId, sql);\r
logger.trace("Index added to column ("+columnName+") on table ("+tableName+")");\r
}\r
return rows;\r
\r
private boolean indexExists(String dataSourceName,\r
String repositoryName,\r
+ String cspaceInstanceId,\r
DatabaseProductType databaseProductType,\r
String tableName, \r
String colName, \r
//\r
// If this assumption is no longer valid, we might instead\r
// identify the relevant repository from the table name here.\r
- conn = JDBCTools.getConnection(dataSourceName, repositoryName);\r
+ conn = JDBCTools.getConnection(dataSourceName, repositoryName, cspaceInstanceId);\r
stmt = conn.createStatement();\r
rs = stmt.executeQuery(sql);\r
if (rs.next()) {\r
public interface IInitHandler {\r
public void onRepositoryInitialized(String dataSourceName,\r
String repositoryName,\r
+ String cspaceInstanceId,\r
ServiceBindingType sbt, \r
List<Field> fields, \r
List<Property> property) throws Exception;\r
@Override\r
public void onRepositoryInitialized(String dataSourceName,\r
String repositoryName,\r
- ServiceBindingType sbt, \r
+ String cspaceInstanceId,\r
+ ServiceBindingType sbt,\r
List<Field> fields, \r
List<Property> properties) throws Exception {\r
\r
@Override
public void onRepositoryInitialized(String dataSourceName,
String repositoryName,
+ String cspaceInstanceId,
ServiceBindingType sbt,
List<Field> fields,
List<Property> properties) throws Exception {
for (Field field : fields) {
datatype = getDatatypeFromLogicalType(databaseProductType, field.getType());
// If the field is already of the desired datatype, skip it.
- if (fieldHasDesiredDatatype(dataSourceName, repositoryName, databaseProductType, field, datatype)) {
+ if (fieldHasDesiredDatatype(dataSourceName, repositoryName, cspaceInstanceId, databaseProductType,
+ field, datatype)) {
logger.trace("Field " + field.getTable() + "." + field.getCol()
+ " is already of desired datatype " + datatype);
continue;
//
// If this assumption is no longer valid, we might instead
// identify the relevant repository from the table name here.
- rows = JDBCTools.executeUpdate(dataSourceName, repositoryName, sql);
+ rows = JDBCTools.executeUpdate(dataSourceName, repositoryName, cspaceInstanceId, sql);
}
} catch (Exception e) {
throw e;
private boolean fieldHasDesiredDatatype(String dataSourceName,
String repositoryName,
+ String cspaceInstanceId,
DatabaseProductType databaseProductType,
Field field, String datatype) {
ResultSet rs = null;
try {
- conn = JDBCTools.getConnection(dataSourceName, repositoryName);
+ conn = JDBCTools.getConnection(dataSourceName, repositoryName, cspaceInstanceId);
stmt = conn.createStatement();
- String databaseName = JDBCTools.getDatabaseName(dataSourceName, repositoryName, conn);
+ String databaseName = JDBCTools.getDatabaseName(dataSourceName, repositoryName, cspaceInstanceId, conn);
if (databaseProductType == DatabaseProductType.MYSQL) {
sql = "SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS "
@Override
public void onRepositoryInitialized(String dataSourceName,
String repositoryName,
+ String cspaceInstanceId,
ServiceBindingType sbt,
List<Field> fields,
List<Property> properties) throws Exception {
logger.warn(CANNOT_PERFORM_TASKS_MESSAGE);
continue;
}
- runScript(dataSourceName, repositoryName, scriptContents, "resource path " + scriptPath);
+ runScript(dataSourceName, repositoryName, cspaceInstanceId, scriptContents, "resource path " + scriptPath);
}
// Next, run a second sequence of SQL scripts, where those scripts may be
logger.warn(CANNOT_PERFORM_TASKS_MESSAGE);
continue;
}
- runScript(dataSourceName, repositoryName, scriptContents, "file " + scriptFile.getName());
+ runScript(dataSourceName, repositoryName, cspaceInstanceId, scriptContents, "file " + scriptFile.getName());
}
}
return sb.toString();
}
- private void runScript(String dataSourceName, String repositoryName, String scriptContents, String scriptPath) {
+ private void runScript(String dataSourceName, String repositoryName, String cspaceInstanceId, String scriptContents, String scriptPath) {
int rows = 0;
try {
- rows = JDBCTools.executeUpdate(dataSourceName, repositoryName, scriptContents);
+ rows = JDBCTools.executeUpdate(dataSourceName, repositoryName, cspaceInstanceId, scriptContents);
} catch (Throwable e) {
logger.warn("Running SQL script from " + scriptPath + " resulted in error: ", e.getMessage());
rows = -1;
static public String createWhereClauseForPartialMatch(ServiceContext ctx,\r
String field,\r
String partialTerm) throws Exception {\r
+ String cspaceInstanceId = ServiceMain.getInstance().getCspaceInstanceId();\r
String repositoryName = ctx.getRepositoryName();\r
// Otherwise, generate that list and cache it for re-use.\r
TenantBindingConfigReaderImpl tReader =\r
|| Boolean.parseBoolean(ptStartingWildcardValue);\r
\r
return queryManager.createWhereClauseForPartialMatch(queryManager.getDatasourceName(),\r
- repositoryName, field, ptStartingWildcard, partialTerm);\r
+ repositoryName, cspaceInstanceId, field, ptStartingWildcard, partialTerm);\r
}\r
\r
/**\r
private static Pattern advSearchSqlWildcard = Pattern.compile(".*?[I]*LIKE\\s*\\\"\\%\\\".*?");\r
\r
\r
- private static String getLikeForm(String dataSourceName, String repositoryName) {\r
+ private static String getLikeForm(String dataSourceName, String repositoryName, String cspaceInstanceId) {\r
if (SEARCH_LIKE_FORM == null) {\r
try {\r
- DatabaseProductType type = JDBCTools.getDatabaseProductType(dataSourceName, repositoryName);\r
+ DatabaseProductType type = JDBCTools.getDatabaseProductType(dataSourceName, repositoryName, cspaceInstanceId);\r
if (type == DatabaseProductType.MYSQL) {\r
SEARCH_LIKE_FORM = IQueryManager.SEARCH_LIKE;\r
} else if (type == DatabaseProductType.POSTGRESQL) {\r
@Override\r
public String createWhereClauseForPartialMatch(String dataSourceName,\r
String repositoryName,\r
+ String cspaceInstanceId,\r
String field,\r
boolean startingWildcard,\r
String partialTerm) {\r
\r
StringBuilder ptClause = new StringBuilder(trimmed.length()+field.length()+20);\r
ptClause.append(field);\r
- ptClause.append(getLikeForm(dataSourceName, repositoryName));\r
+ ptClause.append(getLikeForm(dataSourceName, repositoryName, cspaceInstanceId));\r
ptClause.append(startingWildcard?"'%":"'");\r
ptClause.append(unescapedSingleQuote.matcher(trimmed).replaceAll("\\\\'"));\r
ptClause.append("%'");\r
return result;\r
}\r
\r
- public static Connection getConnection(String dataSourceName, String repositoryName) throws NamingException, SQLException {\r
+ //\r
+ // Use this version of the getConnection() method when you don't want to qualify the database name\r
+ // with a CollectionSpace instance ID.\r
+ //\r
+ public static Connection getConnection(String dataSourceName,\r
+ String databaseName) throws NamingException, SQLException {\r
+ return getConnection(dataSourceName, databaseName, null);\r
+ }\r
+ \r
+ public static Connection getConnection(String dataSourceName,\r
+ String repositoryName,\r
+ String cspaceInstanceId) throws NamingException, SQLException {\r
Connection result = null;\r
\r
if (Tools.isEmpty(dataSourceName) || Tools.isEmpty(repositoryName)) {\r
BasicDataSource dataSource = (BasicDataSource)getDataSource(dataSourceName);\r
// Get the template URL value from the JNDI datasource and substitute the databaseName\r
String urlTemplate = dataSource.getUrl();\r
- String databaseName = getDatabaseName(repositoryName);\r
+ String databaseName = getDatabaseName(repositoryName, cspaceInstanceId);\r
String connectionUrl = urlTemplate.replace(URL_DATABASE_NAME, databaseName);\r
\r
// ATTENTION!\r
return result;\r
}\r
\r
- public static CachedRowSet executeQuery(String dataSourceName, String repositoryName, String sql) throws Exception {\r
+ public static CachedRowSet executeQuery(String dataSourceName, String repositoryName, String cspaceInstanceId, String sql) throws Exception {\r
Connection conn = null;\r
Statement stmt = null;\r
try {\r
- conn = getConnection(dataSourceName, repositoryName);\r
+ conn = getConnection(dataSourceName, repositoryName, cspaceInstanceId);\r
stmt = conn.createStatement();\r
\r
RowSetFactory rowSetFactory = RowSetProvider.newFactory();\r
}\r
\r
public static CachedRowSet executePreparedQuery(final PreparedStatementBuilder builder,\r
- String dataSourceName, String repositoryName) throws Exception {\r
+ String dataSourceName, String repositoryName, String cspaceInstanceId) throws Exception {\r
Connection conn = null;\r
PreparedStatement ps = null;\r
try {\r
- conn = getConnection(dataSourceName, repositoryName);\r
+ conn = getConnection(dataSourceName, repositoryName, cspaceInstanceId);\r
RowSetFactory rowSetFactory = RowSetProvider.newFactory();\r
CachedRowSet crs = rowSetFactory.createCachedRowSet();\r
ps = builder.build(conn);\r
// FIXME: This method's code significantly overlaps that of executePrepareQuery(), above,\r
// and the two could be refactored into a single method, if desired.\r
public static List<CachedRowSet> executePreparedQueries(final List<PreparedStatementBuilder> builders,\r
- String dataSourceName, String repositoryName, Boolean executeWithinTransaction) throws Exception {\r
+ String dataSourceName, String repositoryName, String cspaceInstanceId, Boolean executeWithinTransaction) throws Exception {\r
Connection conn = null;\r
PreparedStatement ps = null;\r
List<CachedRowSet> results = new ArrayList<>();\r
try {\r
- conn = getConnection(dataSourceName, repositoryName);\r
+ conn = getConnection(dataSourceName, repositoryName, cspaceInstanceId);\r
if (executeWithinTransaction) {\r
conn.setAutoCommit(false);\r
}\r
}\r
} catch (Exception e) {\r
int rowcount = ps.executeUpdate();\r
+ logger.debug(String.format("Row count for builder %s is %d", ps.toString(), rowcount));\r
// Throw uncaught exception here if update attempt also fails\r
}\r
}\r
}\r
}\r
\r
- public static int executeUpdate(String dataSourceName, String repositoryName, String sql) throws Exception {\r
+ public static int executeUpdate(String dataSourceName,\r
+ String repositoryName, \r
+ String cspaceInstanceId, \r
+ String sql) throws Exception {\r
Connection conn = null;\r
Statement stmt = null;\r
try {\r
- conn = getConnection(dataSourceName, repositoryName);\r
+ conn = getConnection(dataSourceName, repositoryName, cspaceInstanceId);\r
stmt = conn.createStatement();\r
int rows = stmt.executeUpdate(sql);\r
stmt.close();\r
* @return the database product name\r
*/\r
public static String getDatabaseProductName(String dataSourceName,\r
- String repositoryName) {\r
+ String repositoryName,\r
+ String cspaceInstanceId) {\r
if (DBProductName == null) {\r
Connection conn = null;\r
try {\r
- conn = getConnection(dataSourceName, repositoryName);\r
+ conn = getConnection(dataSourceName, repositoryName, cspaceInstanceId);\r
DBProductName = conn.getMetaData().getDatabaseProductName();\r
} catch (Exception e) {\r
if (logger.isTraceEnabled() == true) {\r
* @return an enumerated value identifying the database product type\r
* @throws Exception \r
*/\r
+ public static DatabaseProductType getDatabaseProductType(String dataSourceName,\r
+ String repositoryName,\r
+ String cspaceInstanceId) throws Exception {\r
+ DatabaseProductType result = DatabaseProductType.UNRECOGNIZED;\r
+ \r
+ String productName = getDatabaseProductName(dataSourceName, repositoryName, cspaceInstanceId);\r
+ if (productName.matches("(?i).*mysql.*")) {\r
+ result = DatabaseProductType.MYSQL;\r
+ } else if (productName.matches("(?i).*postgresql.*")) {\r
+ result = DatabaseProductType.POSTGRESQL;\r
+ } else {\r
+ throw new Exception("Unrecognized database system " + productName);\r
+ }\r
+ \r
+ return result;\r
+ }\r
+ \r
+ //\r
+ // Same as method above except the cspace instance ID is not needed.\r
+ //\r
public static DatabaseProductType getDatabaseProductType(String dataSourceName,\r
String repositoryName) throws Exception {\r
DatabaseProductType result = DatabaseProductType.UNRECOGNIZED;\r
\r
- String productName = getDatabaseProductName(dataSourceName, repositoryName);\r
+ String productName = getDatabaseProductName(dataSourceName, repositoryName, null);\r
if (productName.matches("(?i).*mysql.*")) {\r
result = DatabaseProductType.MYSQL;\r
} else if (productName.matches("(?i).*postgresql.*")) {\r
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, String cspaceInstanceId) {\r
String result = repoName;\r
\r
result = DEFAULT_NUXEO_DATABASE_NAME;\r
}\r
\r
- result = result + cspaceInstanceId;\r
+ //\r
+ // If we have a non-null 'cspaceInstanceId' instance ID then we need to append it\r
+ // as a suffix to the database name.\r
+ //\r
+ if (cspaceInstanceId != null && !cspaceInstanceId.trim().isEmpty()) {\r
+ if (result.endsWith(cspaceInstanceId) == false) { // ensure we don't already have the suffix\r
+ result = result + cspaceInstanceId;\r
+ }\r
+ }\r
\r
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 cspaceInstanceId = ServiceMain.getInstance().getCspaceInstanceId();\r
- return getDatabaseName(repoName, cspaceInstanceId);\r
- }\r
- \r
+ \r
/**\r
* Returns the catalog/database name for an open JDBC connection.\r
* \r
*/\r
public static String getDatabaseName(String dataSourceName,\r
String repositoryName,\r
+ String cspaceInstanceId,\r
Connection conn) throws Exception {\r
String databaseName = null;\r
\r
\r
// Format of the PostgreSQL JDBC URL:\r
// http://jdbc.postgresql.org/documentation/80/connect.html\r
- if (getDatabaseProductType(dataSourceName, repositoryName) == DatabaseProductType.POSTGRESQL) {\r
+ if (getDatabaseProductType(dataSourceName, repositoryName, cspaceInstanceId) == DatabaseProductType.POSTGRESQL) {\r
String tokens[] = urlStr.split(JDBC_URL_DATABASE_SEPARATOR);\r
databaseName = tokens[tokens.length - 1];\r
// Format of the MySQL JDBC URL:\r
// http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html\r
// FIXME: the last token could contain optional parameters, not accounted for here.\r
- } else if (getDatabaseProductType(dataSourceName, repositoryName) == DatabaseProductType.MYSQL) {\r
+ } else if (getDatabaseProductType(dataSourceName, repositoryName, cspaceInstanceId) == DatabaseProductType.MYSQL) {\r
String tokens[] = urlStr.split(JDBC_URL_DATABASE_SEPARATOR);\r
databaseName = tokens[tokens.length - 1];\r
}\r
final Boolean EXECUTE_WITHIN_TRANSACTION = true;
Set<String> docIds = new HashSet<>();
try {
+ String cspaceInstanceId = ServiceMain.getInstance().getCspaceInstanceId();
List<CachedRowSet> resultsList = JDBCTools.executePreparedQueries(builders,
- dataSourceName, repositoryName, EXECUTE_WITHIN_TRANSACTION);
+ dataSourceName, repositoryName, cspaceInstanceId, EXECUTE_WITHIN_TRANSACTION);
// At least one set of results is expected, from the second prepared
// statement to be executed.
public static String getRepositoryName(TenantBindingType tenantBindingType, String domainName) {
String result = null;
-
if (domainName != null && domainName.trim().isEmpty() == false) {
List<RepositoryDomainType> repoDomainList = tenantBindingType.getRepositoryDomain();
if (repoDomainList != null && repoDomainList.isEmpty() == false) {
}
}
} else {
- logger.error(String.format("No domain name was specified on call to getRepositoryName() method."));
+ logger.error(String.format("There was no domain name specified on a call to getRepositoryName() method."));
}
if (result == null && logger.isTraceEnabled()) {
package org.collectionspace.services.report.nuxeo;\r
\r
import java.sql.Connection;\r
-import java.sql.ResultSet;\r
import java.sql.SQLException;\r
import java.sql.Statement;\r
import java.util.List;\r
\r
-import javax.sql.DataSource;\r
-\r
import org.collectionspace.services.common.api.Tools;\r
import org.collectionspace.services.common.init.IInitHandler;\r
import org.collectionspace.services.common.init.InitHandler;\r
@Override\r
public void onRepositoryInitialized(String dataSourceName,\r
String repositoryName,\r
+ String cspaceInstanceId,\r
ServiceBindingType sbt, \r
List<Field> fields, \r
List<Property> propertyList) throws Exception {\r
}\r
}\r
}\r
+ \r
Connection conn = null;\r
Statement stmt = null;\r
String sql = "";\r
try {\r
- DatabaseProductType databaseProductType = JDBCTools.getDatabaseProductType(dataSourceName, repositoryName);\r
+ DatabaseProductType databaseProductType = JDBCTools.getDatabaseProductType(dataSourceName, repositoryName,\r
+ cspaceInstanceId);\r
if (databaseProductType == DatabaseProductType.MYSQL) {\r
// Nothing to do: MYSQL already does wildcard grants in init_db.sql\r
} else if(databaseProductType != DatabaseProductType.POSTGRESQL) {\r