From ae123d5ea962e3f19a8dfaaa097c3e0bc6b0de72 Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Fri, 6 Dec 2019 17:09:09 +0100 Subject: [PATCH 1/9] Add support to override properties trough env vars --- .../ca/uhn/fhir/jpa/starter/HapiProperties.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java index 621ba335989..01eb7d75a23 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java @@ -14,6 +14,7 @@ import java.io.FileInputStream; import java.io.InputStream; import java.util.Arrays; +import java.util.Locale; import java.util.Properties; import java.util.Set; import java.util.stream.Collectors; @@ -159,13 +160,21 @@ private static Properties loadOverrideProperties() { } private static String getProperty(String propertyName) { - Properties properties = HapiProperties.getProperties(); + String env = "HAPI_" + propertyName.toUpperCase(Locale.US); + env = env.replace(".", "_"); + env = env.replace("-", "_"); + + String propertyValue = System.getenv(env); + if (propertyValue != null) { + return propertyValue; + } + Properties properties = HapiProperties.getProperties(); if (properties != null) { - return properties.getProperty(propertyName); + propertyValue = properties.getProperty(propertyName); } - return null; + return propertyValue; } private static String getProperty(String propertyName, String defaultValue) { From ed6d167b5df60e0c6f9e2e2c7d0b31a32da9452d Mon Sep 17 00:00:00 2001 From: "Matt Morgis (ELS-PHI)" Date: Fri, 13 Dec 2019 11:40:50 -0500 Subject: [PATCH 2/9] chore: remove .orig file from a past merge --- pom.xml.orig | 430 --------------------------------------------------- 1 file changed, 430 deletions(-) delete mode 100644 pom.xml.orig diff --git a/pom.xml.orig b/pom.xml.orig deleted file mode 100644 index 79261e47b9c..00000000000 --- a/pom.xml.orig +++ /dev/null @@ -1,430 +0,0 @@ - - 4.0.0 - - - - ca.uhn.hapi.fhir - hapi-fhir -<<<<<<< HEAD - 4.1.0 -======= - 4.0.3 ->>>>>>> master - - - hapi-fhir-jpaserver-starter - - - 3.5.0 - - - - - org.eclipse.jetty.websocket - websocket-api - ${jetty_version} - - - org.eclipse.jetty.websocket - websocket-client - ${jetty_version} - - - mysql - mysql-connector-java - 8.0.11 - - - - - com.sun.mail - javax.mail - - - javax.activation - activation - - - - - - - - ca.uhn.hapi.fhir - hapi-fhir-base - ${project.version} - - - - - ca.uhn.hapi.fhir - hapi-fhir-jpaserver-base - ${project.version} - - - org.springframework - spring-jcl - - - commons-logging - commons-logging - - - - - - - ca.uhn.hapi.fhir - hapi-fhir-testpage-overlay - ${project.version} - war - provided - - - ca.uhn.hapi.fhir - hapi-fhir-testpage-overlay - ${project.version} - classes - provided - - - - - ch.qos.logback - logback-classic - - - - - javax.servlet - javax.servlet-api - provided - - - - - org.thymeleaf - thymeleaf - - - - - - org.springframework - spring-web - - - - - org.apache.commons - commons-dbcp2 - - - commons-logging - commons-logging - - - - - - - com.h2database - h2 - - - - - org.webjars - bootstrap - 3.3.7 - - - org.webjars - Eonasdan-bootstrap-datetimepicker - 4.17.43 - - - org.webjars - font-awesome - 5.8.2 - - - org.webjars.bower - awesome-bootstrap-checkbox - 1.0.1 - - - org.webjars - jstimezonedetect - 1.0.6 - - - org.webjars - select2 - 4.0.3 - - - org.webjars.bower - jquery - 3.3.1 - - - org.webjars.bower - moment - 2.15.1 - - - - - org.eclipse.jetty - jetty-servlets - test - - - org.eclipse.jetty - jetty-servlet - test - - - org.eclipse.jetty.websocket - websocket-server - test - - - org.eclipse.jetty - jetty-server - test - - - org.eclipse.jetty - jetty-util - test - - - org.eclipse.jetty - jetty-webapp - test - - - - - - javax.interceptor - javax.interceptor-api - provided - - - - ca.uhn.hapi.fhir - hapi-fhir-test-utilities - ${project.version} - test - - - - - - war - - HAPI FHIR JPA Server - Starter Project - - - - oss-snapshots - - false - - https://oss.sonatype.org/content/repositories/snapshots/ - - - - - - - hapi-fhir-jpaserver - - - - - org.eclipse.jetty - jetty-maven-plugin - 9.4.8.v20180619 - - - /hapi-fhir-jpaserver - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - - - org.apache.maven.plugins - maven-war-plugin - - - - ${maven.build.timestamp} - - - - - ca.uhn.hapi.fhir - hapi-fhir-testpage-overlay - - - src/main/webapp/WEB-INF/web.xml - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - true - - - - - integration-test - verify - - - - - - - org.basepom.maven - duplicate-finder-maven-plugin - - - default - verify - - check - - true - - - - true - false - - - - .*\.txt$ - .*\.html$ - - - - - - - - - From 7ca00a7325ae8e3ca7817880e7810683fdeab30e Mon Sep 17 00:00:00 2001 From: "Matt Morgis (ELS-PHI)" Date: Fri, 13 Dec 2019 11:45:45 -0500 Subject: [PATCH 3/9] feat: add postgresql support --- README.md | 68 ++++++++++++++++++++++++++++++++----------------------- pom.xml | 14 ++++++++---- 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 70c67ed467e..04c4e50be12 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ Note that this project is specifically intended for end users of the HAPI FHIR J In order to use this sample, you should have: -* [This project](https://github.com/hapifhir/hapi-fhir-jpaserver-starter) checked out. You may wish to create a GitHub Fork of the project and check that out instead so that you can customize the project and save the results to GitHub. -* Oracle Java (JDK) installed: Minimum JDK8 or newer. -* Apache Maven build tool (newest version) +- [This project](https://github.com/hapifhir/hapi-fhir-jpaserver-starter) checked out. You may wish to create a GitHub Fork of the project and check that out instead so that you can customize the project and save the results to GitHub. +- Oracle Java (JDK) installed: Minimum JDK8 or newer. +- Apache Maven build tool (newest version) # Running Locally -The easiest way to run this server is to run it directly in Maven using a built-in Jetty server. To do this, change `src/main/resources/hapi.properties` `server_address` and `server.base` with the values commented out as *For Jetty, use this* and then execute the following command: +The easiest way to run this server is to run it directly in Maven using a built-in Jetty server. To do this, change `src/main/resources/hapi.properties` `server_address` and `server.base` with the values commented out as _For Jetty, use this_ and then execute the following command: ``` mvn jetty:run @@ -25,28 +25,40 @@ Then, browse to the following link to use the server: [http://localhost:8080/hapi-fhir-jpaserver/](http://localhost:8080/hapi-fhir-jpaserver/) If you need to run this server on a different port (using Maven), you can change the port in the run command as follows: + ``` mvn -Djetty.port=8888 jetty:run ``` + And replacing 8888 with the port of your choice. # Configuration -Much of this HAPI starter project can be configured using the properties file in *src/main/resources/hapi.properties*. By default, this starter project is configured to use Derby as the database. +Much of this HAPI starter project can be configured using the properties file in _src/main/resources/hapi.properties_. By default, this starter project is configured to use Derby as the database. ## MySql To configure the starter app to use MySQL, instead of the default Derby, update the hapi.properties file to have the following: -* datasource.driver=com.mysql.jdbc.Driver -* datasource.url=jdbc:mysql://localhost:3306/hapi_dstu3 -* hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect -* datasource.username=admin -* datasource.password=admin +- datasource.driver=com.mysql.jdbc.Driver +- datasource.url=jdbc:mysql://localhost:3306/hapi_dstu3 +- hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect +- datasource.username=admin +- datasource.password=admin -Because the integration tests within the project rely on the default Derby database configuration, it is important to either explicity skip the integration tests during the build process, i.e., `mvn install -DskipTests`, or delete the tests altogether. Failure to skip or delete the tests once you've configured MySQL for the datasource.driver, datasource.url, and hibernate.dialect as outlined above will result in build errors and compilation failure. +## PostgreSQL -It is important to use MySQL5Dialect when using MySQL version 5+. +To configure the starter app to use PostgreSQL, instead of the default Derby, update the hapi.properties file to have the following: + +- datasource.driver=org.postgresql.Driver +- datasource.url=jdbc:postgresql://localhost:5432/hapi_dstu3 +- hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect +- datasource.username=admin +- datasource.password=admin + +Because the integration tests within the project rely on the default Derby database configuration, it is important to either explicity skip the integration tests during the build process, i.e., `mvn install -DskipTests`, or delete the tests altogether. Failure to skip or delete the tests once you've configured PostgreSQL for the datasource.driver, datasource.url, and hibernate.dialect as outlined above will result in build errors and compilation failure. + +It is important to use PostgreSQL95Dialect when using PostgreSQL version 10+. # Customizing The Web Testpage UI @@ -79,20 +91,20 @@ Again, browse to the following link to use the server (note that the port 8080 m # Deploy with docker compose Docker compose is a simple option to build and deploy container. To deploy with docker compose, you should build the project -with ```mvn clean install``` and then bring up the containers with ```docker-compose up -d --build```. The server can be -reached at http://localhost:8080/hapi-fhir-jpaserver/. +with `mvn clean install` and then bring up the containers with `docker-compose up -d --build`. The server can be +reached at http://localhost:8080/hapi-fhir-jpaserver/. -In order to use another port, change the `ports` parameter -inside ``docker-compose.yml`` to ```8888:8080```, where 8888 is a port of your choice. +In order to use another port, change the `ports` parameter +inside `docker-compose.yml` to `8888:8080`, where 8888 is a port of your choice. -The docker compose set also includes my MySQL database, if you choose to use MySQL instead of derby, change the following +The docker compose set also includes my MySQL database, if you choose to use MySQL instead of derby, change the following properties in hapi.properties: -* datasource.driver=com.mysql.jdbc.Driver -* datasource.url=jdbc:mysql://hapi-fhir-mysql:3306/hapi -* hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect -* datasource.username=admin -* datasource.password=admin +- datasource.driver=com.mysql.jdbc.Driver +- datasource.url=jdbc:mysql://hapi-fhir-mysql:3306/hapi +- hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect +- datasource.username=admin +- datasource.password=admin # Running hapi-fhir-jpaserver-example in Tomcat from IntelliJ @@ -114,7 +126,7 @@ Add a Run Configuration for running hapi-fhir-jpaserver-example under Tomcat - Uncheck the "After launch" checkbox - On the "Deployment" tab, click the green + - Select "Artifact" -- Select "hapi-fhir-jpaserver-example:war" +- Select "hapi-fhir-jpaserver-example:war" - In "Application context" type /hapi Run the configuration. @@ -130,13 +142,13 @@ It is important to use MySQL5Dialect when using MySQL version 5+. # Enabling Subscriptions -The server may be configured with subscription support by enabling properties in the [hapi.properties](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/hapi.properties) file: +The server may be configured with subscription support by enabling properties in the [hapi.properties](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/hapi.properties) file: -* `subscription.resthook.enabled` - Enables REST Hook subscriptions, where the server will make an outgoing connection to a remote REST server +- `subscription.resthook.enabled` - Enables REST Hook subscriptions, where the server will make an outgoing connection to a remote REST server -* `subscription.email.enabled` - Enables email subscriptions. Note that you must also provide the connection details for a usable SMTP server. +- `subscription.email.enabled` - Enables email subscriptions. Note that you must also provide the connection details for a usable SMTP server. -* `subscription.websocket.enabled` - Enables websocket subscriptions. With this enabled, your server will accept incoming websocket connections on the following URL (this example uses the default context path and port, you may need to tweak depending on your deployment environment): [ws://localhost:8080/hapi-fhir-jpaserver/websocket](ws://localhost:8080/hapi-fhir-jpaserver/websocket) +- `subscription.websocket.enabled` - Enables websocket subscriptions. With this enabled, your server will accept incoming websocket connections on the following URL (this example uses the default context path and port, you may need to tweak depending on your deployment environment): [ws://localhost:8080/hapi-fhir-jpaserver/websocket](ws://localhost:8080/hapi-fhir-jpaserver/websocket) # Using ElasticSearch @@ -151,4 +163,4 @@ elasticsearch.username=SomeUsername elasticsearch.password=SomePassword elasticsearch.required_index_status=YELLOW elasticsearch.schema_management_strategy=CREATE -``` \ No newline at end of file +``` diff --git a/pom.xml b/pom.xml index b14ae08a541..eac756ab8db 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,5 @@ - + 4.0.0 + + org.postgresql + postgresql + 42.2.9 + @@ -213,8 +219,8 @@ org.eclipse.jetty jetty-webapp test - -