From 9268c1ad3b4e147b125d87750360017cbbeb1293 Mon Sep 17 00:00:00 2001 From: Sean McIlvenna Date: Mon, 11 Feb 2019 11:19:50 -0800 Subject: [PATCH 1/4] Adding properties to HapiProperties: * subscription.resthook.enabled * subscription.email.enabled * allow_placeholder_references --- .../uhn/fhir/jpa/demo/FhirServerConfig.java | 9 +-- .../ca/uhn/fhir/jpa/demo/HapiProperties.java | 56 ++++++++++++------- src/main/resources/hapi.properties | 3 + 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java b/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java index 1f6182b..7e3a887 100644 --- a/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java @@ -46,16 +46,17 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 { retVal.setAllowMultipleDelete(HapiProperties.getAllowMultipleDelete()); retVal.setAllowExternalReferences(HapiProperties.getAllowExternalReferences()); retVal.setExpungeEnabled(HapiProperties.getExpungeEnabled()); - + retVal.setAutoCreatePlaceholderReferenceTargets(HapiProperties.getAllowPlaceholderReferences()); + // You can enable these if you want to support Subscriptions from your server - if (false) { + if (HapiProperties.getSubscriptionRestHookEnabled()) { retVal.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.RESTHOOK); } - if (false) { + if (HapiProperties.getSubscriptionEmailEnabled()) { retVal.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.EMAIL); } - return retVal; + return retVal; } @Bean diff --git a/src/main/java/ca/uhn/fhir/jpa/demo/HapiProperties.java b/src/main/java/ca/uhn/fhir/jpa/demo/HapiProperties.java index a04a429..183db20 100644 --- a/src/main/java/ca/uhn/fhir/jpa/demo/HapiProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/demo/HapiProperties.java @@ -1,3 +1,4 @@ + package ca.uhn.fhir.jpa.demo; import ca.uhn.fhir.context.ConfigurationException; @@ -11,30 +12,33 @@ import java.io.InputStream; import java.util.Properties; public class HapiProperties { - public static final String SERVER_ADDRESS = "server_address"; - public static final String DEFAULT_PRETTY_PRINT = "default_pretty_print"; - public static final String MAX_PAGE_SIZE = "max_page_size"; - public static final String DEFAULT_PAGE_SIZE = "default_page_size"; - public static final String LOGGER_NAME = "logger.name"; - public static final String LOGGER_FORMAT = "logger.format"; - public static final String ALLOW_EXTERNAL_REFERENCES = "allow_external_references"; - public static final String ALLOW_MULTIPLE_DELETE = "allow_multiple_delete"; - public static final String DATASOURCE_PASSWORD = "datasource.password"; - public static final String DATASOURCE_USERNAME = "datasource.username"; - public static final String DATASOURCE_URL = "datasource.url"; - public static final String DATASOURCE_DRIVER = "datasource.driver"; - public static final String LOGGER_LOG_EXCEPTIONS = "logger.log_exceptions"; - public static final String LOGGER_ERROR_FORMAT = "logger.error_format"; - public static final String PERSISTENCE_UNIT_NAME = "persistence_unit_name"; - public static final String SERVER_BASE = "server.base"; - public static final String TEST_PORT = "test.port"; - public static final String SERVER_NAME = "server.name"; - public static final String SERVER_ID = "server.id"; - private static Properties properties; + private static final String SERVER_ADDRESS = "server_address"; + private static final String DEFAULT_PRETTY_PRINT = "default_pretty_print"; + private static final String MAX_PAGE_SIZE = "max_page_size"; + private static final String DEFAULT_PAGE_SIZE = "default_page_size"; + private static final String LOGGER_NAME = "logger.name"; + private static final String LOGGER_FORMAT = "logger.format"; + private static final String ALLOW_EXTERNAL_REFERENCES = "allow_external_references"; + private static final String ALLOW_MULTIPLE_DELETE = "allow_multiple_delete"; + private static final String DATASOURCE_PASSWORD = "datasource.password"; + private static final String DATASOURCE_USERNAME = "datasource.username"; + private static final String DATASOURCE_URL = "datasource.url"; + private static final String DATASOURCE_DRIVER = "datasource.driver"; + private static final String LOGGER_LOG_EXCEPTIONS = "logger.log_exceptions"; + private static final String LOGGER_ERROR_FORMAT = "logger.error_format"; + private static final String PERSISTENCE_UNIT_NAME = "persistence_unit_name"; + private static final String SERVER_BASE = "server.base"; + private static final String TEST_PORT = "test.port"; + private static final String SERVER_NAME = "server.name"; + private static final String SERVER_ID = "server.id"; + private static final String ALLOW_PLACEHOLDER_REFERENCES = "allow_placeholder_references"; private static final String HAPI_PROPERTIES = "hapi.properties"; private static final String FHIR_VERSION = "fhir_version"; private static final String DEFAULT_ENCODING = "default_encoding"; private static final String ETAG_SUPPORT = "etag_support"; + private static final String SUBSCRIPTION_EMAIL_ENABLED = "subscription.email.enabled"; + private static final String SUBSCRIPTION_RESTHOOK_ENABLED = "subscription.resthook.enabled"; + private static Properties properties; public static Properties getProperties() { if (properties == null) { @@ -207,4 +211,16 @@ public class HapiProperties { public static String getServerId() { return HapiProperties.getProperty(SERVER_ID, "home"); } + + public static Boolean getAllowPlaceholderReferences() { + return HapiProperties.getBooleanProperty(ALLOW_PLACEHOLDER_REFERENCES, true); + } + + public static Boolean getSubscriptionEmailEnabled() { + return HapiProperties.getBooleanProperty(SUBSCRIPTION_EMAIL_ENABLED, true); + } + + public static Boolean getSubscriptionRestHookEnabled() { + return HapiProperties.getBooleanProperty(SUBSCRIPTION_RESTHOOK_ENABLED, true); + } } diff --git a/src/main/resources/hapi.properties b/src/main/resources/hapi.properties index 40a0336..a3c43aa 100644 --- a/src/main/resources/hapi.properties +++ b/src/main/resources/hapi.properties @@ -6,6 +6,7 @@ default_page_size=20 max_page_size=200 allow_multiple_delete=true allow_external_references=true +allow_placeholder_references=true expunge_enabled=true persistence_unit_name=HAPI_PU logger.name=fhirtest.access @@ -20,6 +21,8 @@ server.base=/baseDstu3 server.name=Local Tester server.id=home test.port= +subscription.email.enabled=true +subscription.resthook.enabled=true hibernate.dialect=ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect hibernate.search.model_mapping=ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory hibernate.format_sql=false From 319b203cd009b65d1c6aca3757bb1a316d3f02a7 Mon Sep 17 00:00:00 2001 From: Sean McIlvenna Date: Mon, 11 Feb 2019 11:20:09 -0800 Subject: [PATCH 2/4] Adding config information to README --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 037a28c..ad0eb2b 100644 --- a/README.md +++ b/README.md @@ -50,3 +50,16 @@ The UI is customized using [Thymeleaf](https://www.thymeleaf.org/) template file Several template files that can be customized are found in the following directory: [https://github.com/hapifhir/hapi-fhir-jpaserver-starter/tree/master/src/main/webapp/WEB-INF/templates](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/tree/master/src/main/webapp/WEB-INF/templates) +# 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. + +## 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.MySQL5Dialect + +It is important to use MySQL5Dialect when using MySQL version 5+. \ No newline at end of file From e752a99366526807b76ca8500a2c4707f21fbceb Mon Sep 17 00:00:00 2001 From: Sean McIlvenna Date: Mon, 11 Feb 2019 16:44:43 -0800 Subject: [PATCH 3/4] Using server_address property for tester config because otherwise the UI may use the wrong address --- src/main/java/ca/uhn/fhir/jpa/starter/FhirTesterConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/FhirTesterConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/FhirTesterConfig.java index 8a99968..f7d8a77 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/FhirTesterConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/FhirTesterConfig.java @@ -41,7 +41,7 @@ public class FhirTesterConfig { .addServer() .withId(HapiProperties.getServerId()) .withFhirVersion(HapiProperties.getFhirVersion()) - .withBaseUrl("${serverBase}" + HapiProperties.getServerBase()) + .withBaseUrl(HapiProperties.getServerAddress()) .withName(HapiProperties.getServerName()); return retVal; } From 4aaf6038cd8e31ec45ec09ca720497ee57e10bec Mon Sep 17 00:00:00 2001 From: Sean McIlvenna Date: Mon, 11 Feb 2019 17:21:32 -0800 Subject: [PATCH 4/4] Adding logging for some of the configurable properties --- .../jpa/starter/FhirServerConfigCommon.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java index c88aaaa..e128044 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java @@ -24,22 +24,39 @@ import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; @EnableTransactionManagement() public class FhirServerConfigCommon { + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirServerConfigCommon.class); + /** * Configure FHIR properties around the the JPA server via this bean */ @Bean() public DaoConfig daoConfig() { DaoConfig retVal = new DaoConfig(); - retVal.setAllowMultipleDelete(HapiProperties.getAllowMultipleDelete()); - retVal.setAllowExternalReferences(HapiProperties.getAllowExternalReferences()); - retVal.setExpungeEnabled(HapiProperties.getExpungeEnabled()); - retVal.setAutoCreatePlaceholderReferenceTargets(HapiProperties.getAllowPlaceholderReferences()); + + Boolean allowMultipleDelete = HapiProperties.getAllowMultipleDelete(); + retVal.setAllowMultipleDelete(allowMultipleDelete); + ourLog.info("Server configured to " + (allowMultipleDelete ? "allow" : "deny") + " multiple deletes"); + + Boolean allowExternalReferences = HapiProperties.getAllowExternalReferences(); + retVal.setAllowExternalReferences(allowExternalReferences); + ourLog.info("Server configured to " + (allowExternalReferences ? "allow" : "deny") + " external references"); + + Boolean expungeEnabled = HapiProperties.getExpungeEnabled(); + retVal.setExpungeEnabled(expungeEnabled); + ourLog.info("Server configured to " + (expungeEnabled ? "enable" : "disable") + " expunges"); + + Boolean allowPlaceholderReferences = HapiProperties.getAllowPlaceholderReferences(); + retVal.setAutoCreatePlaceholderReferenceTargets(allowPlaceholderReferences); + ourLog.info("Server configured to " + (allowPlaceholderReferences ? "allow" : "deny") + " placeholder references"); // You can enable these if you want to support Subscriptions from your server if (HapiProperties.getSubscriptionRestHookEnabled()) { + ourLog.info("Enabling REST-hook subscriptions"); retVal.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.RESTHOOK); } + if (HapiProperties.getSubscriptionEmailEnabled()) { + ourLog.info("Enabling email subscriptions"); retVal.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.EMAIL); }