Skip to content

Commit

Permalink
Merge branch 'master' into mutation-data-counts
Browse files Browse the repository at this point in the history
  • Loading branch information
7xuanlu authored Oct 9, 2023
2 parents 4b9d713 + 399ca10 commit 0805a70
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
30 changes: 17 additions & 13 deletions core/src/main/java/org/mskcc/cbio/portal/dao/JdbcDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.warn("\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"));
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public OAuth2DataAccessTokenServiceImpl oauth2DataAccessTokenService() {
}

@Bean("dataAccessTokenService")
@ConditionalOnProperty(name = "dat.method", havingValue = "none")
@ConditionalOnProperty(name = "dat.method", havingValue = "none", matchIfMissing = true)
public UnauthDataAccessTokenServiceImpl unauthDataAccessTokenService() {
return new UnauthDataAccessTokenServiceImpl();
}
Expand All @@ -65,4 +65,4 @@ public JwtDataAccessTokenServiceImpl jwtDataAccessTokenService() {
return new JwtDataAccessTokenServiceImpl();
}

}
}

0 comments on commit 0805a70

Please sign in to comment.