From b3fd93f97e209de91cbf630eafbd810f8602612a Mon Sep 17 00:00:00 2001 From: Avery Wang Date: Mon, 9 Oct 2023 09:41:13 -0700 Subject: [PATCH] replace assertion with warning to ensure compatibility with backend importer --- .../mskcc/cbio/portal/dao/JdbcDataSource.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcDataSource.java b/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcDataSource.java index 00bcb76b7cb..8f99d76bfb3 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcDataSource.java +++ b/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcDataSource.java @@ -4,11 +4,15 @@ import org.mskcc.cbio.portal.util.DatabaseProperties; import org.apache.commons.lang3.StringUtils; import org.springframework.util.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Data source that self-initializes based on cBioPortal configuration. */ public class JdbcDataSource extends BasicDataSource { + + private static final Logger LOG = LoggerFactory.getLogger(JdbcDataSource.class); public JdbcDataSource () { DatabaseProperties dbProperties = DatabaseProperties.getInstance(); @@ -20,17 +24,17 @@ public JdbcDataSource () { String database = dbProperties.getDbName(); String enablePooling = (!StringUtils.isBlank(dbProperties.getDbEnablePooling())) ? dbProperties.getDbEnablePooling(): "false"; String connectionURL = dbProperties.getConnectionURL(); - - Assert.isTrue( - !defined(host) && !defined(database) && !defined(dbProperties.getDbUseSSL()), - "\n----------------------------------------------------------------------------------------------------------------" + - "-- Connection error:\n" + - "-- You try to connect to the database using the deprecated 'db.host', 'db.portal_db_name' and 'db.use_ssl' properties.\n" + - "-- Please remove these properties and use the 'db.connection_string' property instead. See https://docs.cbioportal.org/deployment/customization/portal.properties-reference/\n" + - "-- for assistance on building a valid connection string.\n" + - "----------------------------------------------------------------------------------------------------------------\n" - ); - + + if (defined(host) || defined(database) || defined(dbProperties.getDbUseSSL())) { + LOG.info("\n----------------------------------------------------------------------------------------------------------------" + + "-- Connection error:\n" + + "-- You try to connect to the database using the deprecated 'db.host', 'db.portal_db_name' and 'db.use_ssl' properties.\n" + + "-- Please remove these properties and use the 'db.connection_string' property instead. See https://docs.cbioportal.org/deployment/customization/portal.properties-reference/\n" + + "-- for assistance on building a valid connection string.\n" + + "----------------------------------------------------------------------------------------------------------------\n" + ); + } + Assert.hasText(userName, errorMessage("username", "db.user")); Assert.hasText(password, errorMessage("password", "db.password")); Assert.hasText(mysqlDriverClassName, errorMessage("driver class name", "db.driver")); @@ -53,11 +57,11 @@ public JdbcDataSource () { this.setValidationQuery("SELECT 1"); this.setJmxName("org.cbioportal:DataSource=" + database); } - + private String errorMessage(String displayName, String propertyName) { return String.format("No %s provided for database connection. Please set '%s' in portal.properties.", displayName, propertyName); } - + private boolean defined(String property) { return property != null && !property.isEmpty(); }