Skip to content

Commit

Permalink
Merge pull request #279 from OHDSI/release-1.17.1
Browse files Browse the repository at this point in the history
Commons Release 1.17.1
  • Loading branch information
anton-abushkevich authored Feb 8, 2021
2 parents d71f4a6 + 9fe9d9e commit 6e58df1
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 89 deletions.
2 changes: 1 addition & 1 deletion arachne-common-types/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>arachne-commons-bundle</artifactId>
<groupId>com.odysseusinc.arachne</groupId>
<version>1.17.0</version>
<version>1.17.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
16 changes: 10 additions & 6 deletions arachne-common-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>arachne-commons-bundle</artifactId>
<groupId>com.odysseusinc.arachne</groupId>
<version>1.17.0</version>
<version>1.17.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -14,9 +14,10 @@

<properties>
<java.version>1.8</java.version>
<spring.version>5.1.7.RELEASE</spring.version>
<handlebars.version>4.0.6</handlebars.version>
<commons.io.version>2.5</commons.io.version>
<spring.version>5.1.17.RELEASE</spring.version>
<handlebars.version>4.2.0</handlebars.version>
<commons.io.version>2.8.0</commons.io.version>
<commons.lang.version>3.11</commons.lang.version>
</properties>

<dependencies>
Expand All @@ -28,7 +29,10 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand All @@ -43,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand Down
27 changes: 15 additions & 12 deletions arachne-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.odysseusinc.arachne</groupId>
<artifactId>arachne-commons-bundle</artifactId>
<version>1.17.0</version>
<version>1.17.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -16,11 +16,11 @@

<properties>
<java.version>1.8</java.version>
<commons.io.version>2.8.0</commons.io.version>
<springfox.swagger2.version>2.9.2</springfox.swagger2.version>
<commons.lang.version>3.11</commons.lang.version>
<flyway.version>4.2.0</flyway.version>
<jackson.version>2.11.2</jackson.version>
<activemq.version>5.15.14</activemq.version>
<guava.version>30.1-jre</guava.version>
<jackson.version>2.10.5</jackson.version>
<springfox.swagger2.version>2.9.2</springfox.swagger2.version>
</properties>

<dependencies>
Expand All @@ -34,7 +34,6 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons.lang.version}</version>
</dependency>

<dependency>
Expand All @@ -50,7 +49,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<version>2.10.5.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>

<!-- Start ActiveMQ -->
Expand All @@ -62,12 +66,12 @@
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<version>5.14.5</version>
<version>${activemq.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-kahadb-store</artifactId>
<version>5.14.5</version>
<version>${activemq.version}</version>
</dependency>
<!-- End ActiveMQ -->

Expand All @@ -84,7 +88,6 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
Expand Down Expand Up @@ -124,8 +127,8 @@
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.odysseusinc.arachne.commons.utils;


import com.google.common.collect.ImmutableMap;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.odysseusinc.arachne.commons.utils;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;

import org.junit.Test;

Expand Down
2 changes: 1 addition & 1 deletion arachne-no-handler-found-exception-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.odysseusinc.arachne</groupId>
<artifactId>arachne-commons-bundle</artifactId>
<version>1.17.0</version>
<version>1.17.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions arachne-scheduler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.odysseusinc.arachne</groupId>
<artifactId>arachne-commons-bundle</artifactId>
<version>1.17.0</version>
<version>1.17.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -68,7 +68,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.21.RELEASE</version>
<version>${spring.version}</version>
</dependency>
</dependencies>

Expand Down
4 changes: 1 addition & 3 deletions arachne-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.odysseusinc.arachne</groupId>
<artifactId>arachne-commons-bundle</artifactId>
<version>1.17.0</version>
<version>1.17.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -17,7 +17,6 @@
<properties>
<java.version>1.8</java.version>
<spring.boot.version>1.5.22.RELEASE</spring.boot.version>
<commons.lang3.version>3.11</commons.lang3.version>
<jackrabbit.version>2.21.3</jackrabbit.version>
</properties>

Expand All @@ -40,7 +39,6 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons.lang3.version}</version>
</dependency>
<dependency>
<groupId>javax.jcr</groupId>
Expand Down
14 changes: 2 additions & 12 deletions arachne-sys-settings/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.odysseusinc.arachne</groupId>
<artifactId>arachne-commons-bundle</artifactId>
<version>1.17.0</version>
<version>1.17.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -17,23 +17,13 @@
<properties>
<java.version>1.8</java.version>
<springfox.swagger2.version>2.9.2</springfox.swagger2.version>
<postgresql.version>42.2.1</postgresql.version>
<postgresql.version>42.2.15</postgresql.version>
<flyway.version>4.2.0</flyway.version>
<spring.jasypt.version>1.18</spring.jasypt.version>
</properties>

<dependencies>

<!--<dependency>-->
<!--<groupId>org.hibernate</groupId>-->
<!--<artifactId>hibernate-validator</artifactId>-->
<!--<version>5.2.4.Final</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.fasterxml.jackson.core</groupId>-->
<!--<artifactId>jackson-annotations</artifactId>-->
<!--<version>2.8.3</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@
package com.odysseusinc.arachne.system.settings.config;

import com.ulisesbocchio.jasyptspringboot.EncryptablePropertyResolver;
import java.io.IOException;
import java.net.URI;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.sql.DataSource;
import org.postgresql.ds.PGPoolingDataSource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
Expand All @@ -51,59 +48,46 @@ public class SpringPropertiesConfig {
private static final String SQL = "SELECT * FROM system_settings WHERE value IS NOT NULL";
private static final Logger LOG = LoggerFactory.getLogger(SpringPropertiesConfig.class);

private DataSource getDataSource(EncryptablePropertyResolver encryptablePropertyResolver, ConfigurableEnvironment environment)
throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, SQLException {

final String datasourceUrl = environment.getProperty("spring.datasource.url");
final String datasourceUsername = environment.getProperty("spring.datasource.username");
final String datasourcePassword = environment.getProperty("spring.datasource.password");
final String connectionUrl = encryptablePropertyResolver.resolvePropertyValue(datasourceUrl);
final String user = encryptablePropertyResolver.resolvePropertyValue(datasourceUsername);
final String password = encryptablePropertyResolver.resolvePropertyValue(datasourcePassword);
DriverManager.registerDriver((Driver) Class.forName("org.postgresql.Driver").newInstance());
final String cleanURI = connectionUrl.substring(5);
final URI uri = URI.create(cleanURI);
final PGPoolingDataSource ds = new PGPoolingDataSource();
ds.setServerName(uri.getHost());
ds.setPortNumber(uri.getPort());
ds.setDatabaseName(uri.getPath().substring(1));
ds.setUser(user);
ds.setPassword(password);
ds.setMaxConnections(10);
return ds;
private Connection getConnection(EncryptablePropertyResolver encryptablePropertyResolver, ConfigurableEnvironment environment)
throws SQLException {

final String datasourceUrl = environment.getProperty("spring.datasource.url");
final String datasourceUsername = environment.getProperty("spring.datasource.username");
final String datasourcePassword = environment.getProperty("spring.datasource.password");
final String connectionUrl = encryptablePropertyResolver.resolvePropertyValue(datasourceUrl);
final String user = encryptablePropertyResolver.resolvePropertyValue(datasourceUsername);
final String password = encryptablePropertyResolver.resolvePropertyValue(datasourcePassword);
return DriverManager.getConnection(connectionUrl, user, password);
}

private Map getDbProperties(DataSource dataSource, EncryptablePropertyResolver encryptablePropertyResolver) {
private Map<String, Object> getDbProperties(Connection connection, EncryptablePropertyResolver encryptablePropertyResolver) throws SQLException {

Map<String, Object> loadedProperties = new HashMap<>();

try {
Connection connection = dataSource.getConnection();
try (Statement statement = connection.createStatement()) {
try (ResultSet rs = statement.executeQuery(SQL)) {
while (rs.next()) {
String name = rs.getString("name");
String value = rs.getString("value");
value = encryptablePropertyResolver.resolvePropertyValue(value);
loadedProperties.put(name, value);
}
try (Statement statement = connection.createStatement()) {
try (ResultSet rs = statement.executeQuery(SQL)) {
while (rs.next()) {
String name = rs.getString("name");
String value = rs.getString("value");
value = encryptablePropertyResolver.resolvePropertyValue(value);
loadedProperties.put(name, value);
}
}
} catch (SQLException e) {
LOG.error("Error loading properties", e);
}

return loadedProperties;
}

@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(
EncryptablePropertyResolver encryptablePropertyResolver, ConfigurableEnvironment environment
) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, SQLException {
) throws SQLException {

DataSource dataSource = getDataSource(encryptablePropertyResolver, environment);
Properties dbProps = new Properties();
dbProps.putAll(getDbProperties(dataSource, encryptablePropertyResolver));
try (Connection connection = getConnection(encryptablePropertyResolver, environment)) {
dbProps.putAll(getDbProperties(connection, encryptablePropertyResolver));
} catch (SQLException e) {
LOG.error("Error loading properties", e);
}

PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();

Expand Down
4 changes: 1 addition & 3 deletions data-source-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>com.odysseusinc.arachne</groupId>
<artifactId>arachne-commons-bundle</artifactId>
<version>1.17.0</version>
<version>1.17.1</version>
<relativePath>../</relativePath>
</parent>

Expand All @@ -38,7 +38,6 @@

<properties>
<java.version>1.8</java.version>
<commons.lang3.version>3.11</commons.lang3.version>
</properties>

<dependencies>
Expand All @@ -55,7 +54,6 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons.lang3.version}</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
Expand Down
Loading

0 comments on commit 6e58df1

Please sign in to comment.