From 31f9f0b00ba9a88d5cd17b6c24fe8f7ab6bc4c38 Mon Sep 17 00:00:00 2001 From: dotasek Date: Mon, 4 Dec 2023 15:04:08 -0500 Subject: [PATCH 1/4] Bump github actions used in docker build workflow (#619) --- .github/workflows/build-images.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index 2a413b5..0d4930d 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -21,7 +21,7 @@ jobs: steps: - name: Container meta for default (distroless) image id: docker_meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: ${{ env.IMAGES }} tags: | @@ -30,7 +30,7 @@ jobs: - name: Container meta for tomcat image id: docker_tomcat_meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: ${{ env.IMAGES }} tags: | @@ -39,20 +39,20 @@ jobs: suffix=-tomcat,onlatest=true - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 if: github.event_name != 'pull_request' with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Cache Docker layers - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} @@ -61,7 +61,7 @@ jobs: - name: Build and push default (distroless) image id: docker_build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache @@ -73,7 +73,7 @@ jobs: - name: Build and push tomcat image id: docker_build_tomcat - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache From 41a537efb206e3ff2ffb7588fc6376ac1e6c6da6 Mon Sep 17 00:00:00 2001 From: Levi <78334846+muhammad-levi@users.noreply.github.com> Date: Tue, 5 Dec 2023 03:07:51 +0700 Subject: [PATCH 2/4] Affected Issue(s): #611 (#617) * Affected Issue(s): #611 What this commit has achieved: 1. MDM requires an implementation of `INicknameSvc`, it was instantiated in `NicknameServiceConfig` The error message regarding this was: ``` APPLICATION FAILED TO START Description: Parameter 2 of method matcherFactory in ca.uhn.fhir.jpa.mdm.config.MdmCommonConfig required a bean of type 'ca.uhn.fhir.jpa.nickname.INicknameSvc' that could not be found. Action: Consider defining a bean of type 'ca.uhn.fhir.jpa.nickname.INicknameSvc' in your configuration. ``` 2. MDM requires the subscription of type message The error message regarding this was: ``` 2023-12-01 11:34:03 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mdmSubmitterInterceptorLoader': Invocation of init method failed; nested exception is ca.uhn.fhir.context.ConfigurationException: HAPI-2421: MDM requires Message Subscriptions to be enabled in the Storage Settings ``` * Affected Issue(s): #611 What this commit has achieved: 1. Added Integration Test for future-proof --- .../common/FhirServerConfigCommon.java | 7 +++++ .../uhn/fhir/jpa/starter/mdm/MdmConfig.java | 3 +- .../java/ca/uhn/fhir/jpa/starter/MdmTest.java | 29 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/test/java/ca/uhn/fhir/jpa/starter/MdmTest.java diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java index b0267d4..b9dabbb 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java @@ -180,6 +180,13 @@ public class FhirServerConfigCommon { jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size()); jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size()); + if (appProperties.getMdm_enabled()) { + // MDM requires the subscription of type message + ourLog.info("Enabling message subscriptions"); + jpaStorageSettings.addSupportedSubscriptionType( + org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.MESSAGE); + } + storageSettings(appProperties, jpaStorageSettings); return jpaStorageSettings; } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java index 33bb749..48e8480 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java @@ -2,6 +2,7 @@ package ca.uhn.fhir.jpa.starter.mdm; import ca.uhn.fhir.jpa.mdm.config.MdmConsumerConfig; import ca.uhn.fhir.jpa.mdm.config.MdmSubmitterConfig; +import ca.uhn.fhir.jpa.searchparam.config.NicknameServiceConfig; import ca.uhn.fhir.jpa.starter.AppProperties; import ca.uhn.fhir.mdm.api.IMdmSettings; import ca.uhn.fhir.mdm.rules.config.MdmRuleValidator; @@ -20,7 +21,7 @@ import java.nio.charset.StandardCharsets; @Configuration @Conditional(MdmConfigCondition.class) -@Import({MdmConsumerConfig.class, MdmSubmitterConfig.class}) +@Import({MdmConsumerConfig.class, MdmSubmitterConfig.class, NicknameServiceConfig.class}) public class MdmConfig { @Bean diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/MdmTest.java b/src/test/java/ca/uhn/fhir/jpa/starter/MdmTest.java new file mode 100644 index 0000000..4fc0801 --- /dev/null +++ b/src/test/java/ca/uhn/fhir/jpa/starter/MdmTest.java @@ -0,0 +1,29 @@ +package ca.uhn.fhir.jpa.starter; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; +import ca.uhn.fhir.jpa.nickname.INicknameSvc; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class}, properties = { + "hapi.fhir.fhir_version=r4", + "hapi.fhir.mdm_enabled=true" +}) +class MdmTest { + @Autowired + INicknameSvc nicknameService; + + @Autowired + JpaStorageSettings jpaStorageSettings; + + @Test + void testApplicationStartedSuccessfully() { + assertThat(nicknameService).isNotNull(); + assertThat(jpaStorageSettings.getSupportedSubscriptionTypes()).contains(SubscriptionChannelType.MESSAGE); + } +} From 0be636c169344523b44587ebc94645523edf1823 Mon Sep 17 00:00:00 2001 From: Levi <78334846+muhammad-levi@users.noreply.github.com> Date: Tue, 5 Dec 2023 03:10:21 +0700 Subject: [PATCH 3/4] Affected Issue(s): #606 (#612) What this commit has achieved: 1. Externalized location of "mdm-rules.json" in the `AppProperties` 2. More info about the `ResourceLoader` interface is available at https://docs.spring.io/spring-framework/reference/core/resources.html#resources-resourceloader --- .../java/ca/uhn/fhir/jpa/starter/AppProperties.java | 11 ++++++++++- .../java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java | 2 +- src/main/resources/application.yaml | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java index a724ef2..afd25e1 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -27,6 +27,7 @@ public class AppProperties { private Boolean ips_enabled = false; private Boolean openapi_enabled = false; private Boolean mdm_enabled = false; + private String mdm_rules_json_location = "mdm-rules.json"; private boolean advanced_lucene_indexing = false; private boolean enable_index_of_type = false; private Boolean allow_cascading_deletes = false; @@ -191,7 +192,15 @@ public class AppProperties { this.mdm_enabled = mdm_enabled; } - public Cors getCors() { + public String getMdm_rules_json_location() { + return mdm_rules_json_location; +} + +public void setMdm_rules_json_location(String mdm_rules_json_location) { + this.mdm_rules_json_location = mdm_rules_json_location; +} + +public Cors getCors() { return cors; } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java index 48e8480..2e8a1f1 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/mdm/MdmConfig.java @@ -28,7 +28,7 @@ public class MdmConfig { IMdmSettings mdmSettings(@Autowired MdmRuleValidator theMdmRuleValidator, AppProperties appProperties) throws IOException { DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); - Resource resource = resourceLoader.getResource("mdm-rules.json"); + Resource resource = resourceLoader.getResource(appProperties.getMdm_rules_json_location()); String json = IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8); return new MdmSettings(theMdmRuleValidator) .setEnabled(appProperties.getMdm_enabled()) diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 49d12c8..469b701 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -137,6 +137,7 @@ hapi: # graphql_enabled: true narrative_enabled: false mdm_enabled: false + mdm_rules_json_location: "mdm-rules.json" # local_base_urls: # - https://hapi.fhir.org/baseR4 # partitioning: From 9c557e2c80e597b92b5fb855e611ec39e021bb14 Mon Sep 17 00:00:00 2001 From: Jens Kristian Villadsen Date: Tue, 5 Dec 2023 19:56:31 +0100 Subject: [PATCH 4/4] Cleaned up for running boot as default (#620) --- README.md | 4 +-- pom.xml | 3 +++ .../ca/uhn/fhir/jpa/starter/Application.java | 26 ------------------- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 6bc5789..94fee83 100644 --- a/README.md +++ b/README.md @@ -193,14 +193,14 @@ The easiest way to run this server entirely depends on your environment requirem ### Using jetty ```bash -mvn jetty:run +mvn -Pjetty jetty:run ``` If you need to run this server on a different port (using Maven), you can change the port in the run command as follows: ```bash -mvn -Djetty.port=8888 jetty:run +mvn -Pjetty -Djetty.port=8888 jetty:run ``` Server will then be accessible at http://localhost:8888/ and eg. http://localhost:8888/fhir/metadata. Remember to adjust you overlay configuration in the application.yaml to eg. diff --git a/pom.xml b/pom.xml index f750d54..1b8fee4 100644 --- a/pom.xml +++ b/pom.xml @@ -601,6 +601,9 @@ boot + + true + org.springframework.boot diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/Application.java b/src/main/java/ca/uhn/fhir/jpa/starter/Application.java index 9131f8d..4f72c4a 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/Application.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/Application.java @@ -53,10 +53,6 @@ public class Application extends SpringBootServletInitializer { // UI is now accessible at http://localhost:8080/ } - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { - return builder.sources(Application.class); - } @Autowired AutowireCapableBeanFactory beanFactory; @@ -73,26 +69,4 @@ public class Application extends SpringBootServletInitializer { return servletRegistrationBean; } - @Bean - public ServletRegistrationBean overlayRegistrationBean() { - - AnnotationConfigWebApplicationContext annotationConfigWebApplicationContext = - new AnnotationConfigWebApplicationContext(); - annotationConfigWebApplicationContext.register(FhirTesterConfig.class); - - DispatcherServlet dispatcherServlet = new DispatcherServlet(annotationConfigWebApplicationContext); - dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class); - dispatcherServlet.setContextConfigLocation(FhirTesterConfig.class.getName()); - - ServletRegistrationBean registrationBean = new ServletRegistrationBean(); - registrationBean.setServlet(dispatcherServlet); - registrationBean.addUrlMappings("/*"); - registrationBean.setLoadOnStartup(1); - return registrationBean; - } - - // @Bean - // IRepositoryFactory repositoryFactory(DaoRegistry theDaoRegistry, RestfulServer theRestfulServer) { - // return rd -> new HapiFhirRepository(theDaoRegistry, rd, theRestfulServer); - // } }