From 027c2dadc07baefca92d0e2e67add46a9d745ba8 Mon Sep 17 00:00:00 2001 From: "artiom.darie" Date: Wed, 18 Sep 2024 15:01:34 +0300 Subject: [PATCH] Merge from remote-master --- .github/workflows/build-images.yaml | 84 +++++++++++++++++++ .github/workflows/chart-test.yaml | 4 +- Dockerfile | 5 +- README.md | 7 ++ charts/hapi-fhir-jpaserver/Chart.lock | 6 +- charts/hapi-fhir-jpaserver/Chart.yaml | 10 +-- charts/hapi-fhir-jpaserver/README.md | 8 +- .../templates/deployment.yaml | 2 +- .../templates/tests/test-endpoints.yaml | 1 + charts/hapi-fhir-jpaserver/values.yaml | 7 +- docker-compose.yml | 2 +- pom.xml | 9 +- .../common/FhirServerConfigCommon.java | 70 ++++++++-------- .../jpa/starter/common/StarterJpaConfig.java | 4 +- src/main/resources/application.yaml | 7 +- .../jpa/starter/ExampleServerDstu3IT.java | 1 - .../fhir/jpa/starter/ExampleServerR4IT.java | 5 +- .../jpa/starter/JpaStorageSettingsConfig.java | 22 ----- .../java/ca/uhn/fhir/jpa/starter/MdmTest.java | 6 +- src/test/smoketest/plain_server.http | 2 +- 20 files changed, 170 insertions(+), 92 deletions(-) create mode 100644 .github/workflows/build-images.yaml delete mode 100644 src/test/java/ca/uhn/fhir/jpa/starter/JpaStorageSettingsConfig.java diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml new file mode 100644 index 00000000000..542bd647d70 --- /dev/null +++ b/.github/workflows/build-images.yaml @@ -0,0 +1,84 @@ +name: Build Container Images + +on: + push: + tags: + - "image/v*" + paths-ignore: + - "charts/**" + pull_request: + branches: [master] + paths-ignore: + - "charts/**" +env: + IMAGES: docker.io/hapiproject/hapi + PLATFORMS: linux/amd64,linux/arm64/v8 + +jobs: + build: + name: Build + runs-on: ubuntu-22.04 + steps: + - name: Container meta for default (distroless) image + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGES }} + tags: | + type=match,pattern=image/(.*),group=1,enable=${{github.event_name != 'pull_request'}} + + + - name: Container meta for tomcat image + id: docker_tomcat_meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGES }} + tags: | + type=match,pattern=image/(.*),group=1,enable=${{github.event_name != 'pull_request'}} + flavor: | + suffix=-tomcat,onlatest=true + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + 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@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build and push default (distroless) image + id: docker_build + uses: docker/build-push-action@v5 + with: + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} + platforms: ${{ env.PLATFORMS }} + target: default + + - name: Build and push tomcat image + id: docker_build_tomcat + uses: docker/build-push-action@v5 + with: + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_tomcat_meta.outputs.tags }} + labels: ${{ steps.docker_tomcat_meta.outputs.labels }} + platforms: ${{ env.PLATFORMS }} + target: tomcat diff --git a/.github/workflows/chart-test.yaml b/.github/workflows/chart-test.yaml index a6daf0ec303..fd97356ee2e 100644 --- a/.github/workflows/chart-test.yaml +++ b/.github/workflows/chart-test.yaml @@ -15,7 +15,7 @@ jobs: - name: Install helm-docs working-directory: /tmp env: - HELM_DOCS_URL: https://github.com/norwoodj/helm-docs/releases/download/v1.13.0/helm-docs_1.13.0_Linux_x86_64.tar.gz + HELM_DOCS_URL: https://github.com/norwoodj/helm-docs/releases/download/v1.14.2/helm-docs_1.14.2_Linux_x86_64.tar.gz run: | curl -LSs $HELM_DOCS_URL | tar xz && \ mv ./helm-docs /usr/local/bin/helm-docs && \ @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - k8s-version: [1.25.11, 1.26.6, 1.27.3, 1.28.0, 1.29.0] + k8s-version: [1.29.8, 1.30.4, 1.31.0] needs: - lint steps: diff --git a/Dockerfile b/Dockerfile index e3a6dc89dcf..806c542288a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/library/maven:3.9.7-eclipse-temurin-17 AS build-hapi +FROM docker.io/library/maven:3.9.9-eclipse-temurin-17 AS build-hapi WORKDIR /tmp/hapi-fhir-jpaserver-starter ARG OPENTELEMETRY_JAVA_AGENT_VERSION=1.33.3 @@ -20,11 +20,12 @@ RUN mkdir /app && cp /tmp/hapi-fhir-jpaserver-starter/target/ROOT.war /app/main. ########### it can be built using eg. `docker build --target tomcat .` FROM bitnami/tomcat:10.1 AS tomcat +USER root RUN rm -rf /opt/bitnami/tomcat/webapps/ROOT && \ mkdir -p /opt/bitnami/hapi/data/hapi/lucenefiles && \ + chown -R 1001:1001 /opt/bitnami/hapi/data/hapi/lucenefiles && \ chmod 775 /opt/bitnami/hapi/data/hapi/lucenefiles -USER root RUN mkdir -p /target && chown -R 1001:1001 target USER 1001 diff --git a/README.md b/README.md index 6fbfccdc94d..ebca0d8ab4b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,13 @@ This project is a complete starter project you can use to deploy a FHIR server u Note that this project is specifically intended for end users of the HAPI FHIR JPA server module (in other words, it helps you implement HAPI FHIR, it is not the source of the library itself). If you are looking for the main HAPI FHIR project, see here: https://github.com/hapifhir/hapi-fhir +While this project shows how you can use many parts of the HAPI FHIR framework there are a set of features which you should be aware of are missing or something you need to supply yourself or get professional support ahead of using it directly in production: + +1) The service comes with no security implementation. See how it can be done [here](https://hapifhir.io/hapi-fhir/docs/security/introduction.html) +2) The service comes with no enterprise logging. See how it can be done [here](https://hapifhir.io/hapi-fhir/docs/security/balp_interceptor.html) +3) The internal topic cache used by subscriptions in HAPI FHIR are not shared across multiple instances as the [default supplied implementation is in-mem](https://github.com/hapifhir/hapi-fhir/blob/master/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/ActiveSubscriptionTopicCache.java) +4) The internal message broker channel in HAPI FHIR is not shared across multiple instances as the [default supplied implementation is in-mem](https://github.com/hapifhir/hapi-fhir/blob/master/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/subscription/channel/api/IChannelFactory.java). This impacts the use of modules listed [here](https://smilecdr.com/docs/installation/message_broker.html#modules-dependent-on-message-brokers) + Need Help? Please see: https://github.com/hapifhir/hapi-fhir/wiki/Getting-Help ## Prerequisites diff --git a/charts/hapi-fhir-jpaserver/Chart.lock b/charts/hapi-fhir-jpaserver/Chart.lock index ff1845eb15a..a0b19f13071 100644 --- a/charts/hapi-fhir-jpaserver/Chart.lock +++ b/charts/hapi-fhir-jpaserver/Chart.lock @@ -1,6 +1,6 @@ dependencies: - name: postgresql repository: oci://registry-1.docker.io/bitnamicharts - version: 14.3.1 -digest: sha256:fb1d56a00b544bb2ad5691553cadf6384f499652acb9ff5ad625ef36a1b8979e -generated: "2024-03-10T14:43:22.395381351+01:00" + version: 15.5.22 +digest: sha256:513750151f1497acfe6ba07fb1833b8d945ca19094f83018d34b339b666a2d56 +generated: "2024-08-18T18:30:23.392457144+02:00" diff --git a/charts/hapi-fhir-jpaserver/Chart.yaml b/charts/hapi-fhir-jpaserver/Chart.yaml index e9909832e37..6c974dc8766 100644 --- a/charts/hapi-fhir-jpaserver/Chart.yaml +++ b/charts/hapi-fhir-jpaserver/Chart.yaml @@ -7,11 +7,11 @@ sources: - https://github.com/hapifhir/hapi-fhir-jpaserver-starter dependencies: - name: postgresql - version: 14.3.1 + version: 15.5.22 repository: oci://registry-1.docker.io/bitnamicharts condition: postgresql.enabled appVersion: 7.2.0 -version: 0.17.0 +version: 0.17.1 annotations: artifacthub.io/license: Apache-2.0 artifacthub.io/containsSecurityUpdates: "false" @@ -24,8 +24,6 @@ annotations: # When using the list of objects option the valid supported kinds are # added, changed, deprecated, removed, fixed, and security. - kind: changed - description: updated starter image to v7.2.0 + description: updated curlimages/curl to 8.9.1 - kind: changed - description: updated curlimages/curl to 8.6.0 - - kind: changed - description: "updated postgresql sub-chart to 14.3.1." + description: "updated postgresql sub-chart to 15.5.22." diff --git a/charts/hapi-fhir-jpaserver/README.md b/charts/hapi-fhir-jpaserver/README.md index 0f9558567f3..439def9d87a 100644 --- a/charts/hapi-fhir-jpaserver/README.md +++ b/charts/hapi-fhir-jpaserver/README.md @@ -1,6 +1,6 @@ # HAPI FHIR JPA Server Starter Helm Chart -![Version: 0.17.0](https://img.shields.io/badge/Version-0.17.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 7.2.0](https://img.shields.io/badge/AppVersion-7.2.0-informational?style=flat-square) +![Version: 0.17.1](https://img.shields.io/badge/Version-0.17.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 7.2.0](https://img.shields.io/badge/AppVersion-7.2.0-informational?style=flat-square) This helm chart will help you install the HAPI FHIR JPA Server in a Kubernetes environment. @@ -15,7 +15,7 @@ helm install hapi-fhir-jpaserver hapifhir/hapi-fhir-jpaserver | Repository | Name | Version | |------------|------|---------| -| oci://registry-1.docker.io/bitnamicharts | postgresql | 14.3.1 | +| oci://registry-1.docker.io/bitnamicharts | postgresql | 15.5.22 | ## Values @@ -57,7 +57,6 @@ helm install hapi-fhir-jpaserver hapifhir/hapi-fhir-jpaserver | postgresql.auth.database | string | `"fhir"` | name for a custom database to create | | postgresql.auth.existingSecret | string | `""` | Name of existing secret to use for PostgreSQL credentials `auth.postgresPassword`, `auth.password`, and `auth.replicationPassword` will be ignored and picked up from this secret The secret must contain the keys `postgres-password` (which is the password for "postgres" admin user), `password` (which is the password for the custom user to create when `auth.username` is set), and `replication-password` (which is the password for replication user). The secret might also contains the key `ldap-password` if LDAP is enabled. `ldap.bind_password` will be ignored and picked from this secret in this case. The value is evaluated as a template. | | postgresql.enabled | bool | `true` | enable an included PostgreSQL DB. see for details if set to `false`, the values under `externalDatabase` are used | -| postgresql.primary.containerSecurityContext.readOnlyRootFilesystem | bool | `true` | | | replicaCount | int | `1` | number of replicas to deploy | | resources | object | `{}` | configure the FHIR server's resource requests and limits | | securityContext.allowPrivilegeEscalation | bool | `false` | | @@ -74,6 +73,7 @@ helm install hapi-fhir-jpaserver hapifhir/hapi-fhir-jpaserver | serviceAccount.automount | bool | `true` | Automatically mount a ServiceAccount's API credentials? | | serviceAccount.create | bool | `false` | Specifies whether a service account should be created. | | serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | +| tests.automountServiceAccountToken | bool | `false` | whether the service account token should be auto-mounted for the test pods | | tests.resources | object | `{}` | configure the test pods resource requests and limits | | tolerations | list | `[]` | pod tolerations | | topologySpreadConstraints | list | `[]` | pod topology spread configuration see: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#api | @@ -140,4 +140,4 @@ kubectl port-forward -n observability service/simplest-query 16686:16686 and opening in your browser. ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.13.0](https://github.com/norwoodj/helm-docs/releases/v1.13.0) +Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2) diff --git a/charts/hapi-fhir-jpaserver/templates/deployment.yaml b/charts/hapi-fhir-jpaserver/templates/deployment.yaml index fac0f603163..c91ce03d131 100644 --- a/charts/hapi-fhir-jpaserver/templates/deployment.yaml +++ b/charts/hapi-fhir-jpaserver/templates/deployment.yaml @@ -31,7 +31,7 @@ spec: {{- toYaml .Values.podSecurityContext | nindent 8 }} initContainers: - name: wait-for-db-to-be-ready - image: docker.io/bitnami/postgresql:16.2.0-debian-12-r6@sha256:ea55532b6f75afbc97f617d91ec5efae17609c8eb825a31845fa9cb9e4aa13e1 + image: docker.io/bitnami/postgresql:16.4.0-debian-12-r1@sha256:fb3d0a34e7b9f3e59442aa1fa2e6377857147c09ae754ddd5d4bb3fc0dd137da imagePullPolicy: IfNotPresent {{- with .Values.restrictedContainerSecurityContext }} securityContext: diff --git a/charts/hapi-fhir-jpaserver/templates/tests/test-endpoints.yaml b/charts/hapi-fhir-jpaserver/templates/tests/test-endpoints.yaml index bd81c4aa450..d2e46303a57 100644 --- a/charts/hapi-fhir-jpaserver/templates/tests/test-endpoints.yaml +++ b/charts/hapi-fhir-jpaserver/templates/tests/test-endpoints.yaml @@ -9,6 +9,7 @@ metadata: "helm.sh/hook": test spec: restartPolicy: Never + automountServiceAccountToken: {{ .Values.tests.automountServiceAccountToken }} containers: - name: test-metadata-endpoint image: "{{ .Values.curl.image.registry }}/{{ .Values.curl.image.repository }}:{{ .Values.curl.image.tag }}" diff --git a/charts/hapi-fhir-jpaserver/values.yaml b/charts/hapi-fhir-jpaserver/values.yaml index 98f6f143330..0e2d8823c81 100644 --- a/charts/hapi-fhir-jpaserver/values.yaml +++ b/charts/hapi-fhir-jpaserver/values.yaml @@ -109,9 +109,6 @@ postgresql: # see for details # if set to `false`, the values under `externalDatabase` are used enabled: true - primary: - containerSecurityContext: - readOnlyRootFilesystem: true auth: # -- name for a custom database to create database: "fhir" @@ -234,9 +231,11 @@ curl: image: registry: docker.io repository: curlimages/curl - tag: 8.6.0@sha256:c3b8bee303c6c6beed656cfc921218c529d65aa61114eb9e27c62047a1271b9b + tag: 8.9.1@sha256:8addc281f0ea517409209f76832b6ddc2cabc3264feb1ebbec2a2521ffad24e4 tests: + # -- whether the service account token should be auto-mounted for the test pods + automountServiceAccountToken: false # -- configure the test pods resource requests and limits resources: {} # limits: diff --git a/docker-compose.yml b/docker-compose.yml index ab4f15ce68f..9c970b41b09 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: ports: - "8080:8080" hapi-fhir-postgres: - image: postgres:14-alpine + image: postgres:15-alpine container_name: hapi-fhir-postgres restart: always environment: diff --git a/pom.xml b/pom.xml index 3b7b90cea64..df0b9133653 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.2.1 + 7.4.0 hapi-fhir-jpaserver-starter @@ -360,14 +360,14 @@ io.micrometer micrometer-core - 1.11.3 + 1.13.3 io.micrometer micrometer-registry-prometheus - 1.11.3 + 1.13.3 @@ -408,7 +408,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.5 + 3.4.0 @@ -475,6 +475,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.4.0 true 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 0f15abff8e7..a312360723c 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 @@ -6,6 +6,7 @@ import ca.uhn.fhir.jpa.config.HibernatePropertiesProvider; import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.config.PartitionSettings.CrossPartitionReferenceMode; +import ca.uhn.fhir.jpa.model.config.SubscriptionSettings; import ca.uhn.fhir.jpa.model.entity.StorageSettings; import ca.uhn.fhir.jpa.starter.AppProperties; import ca.uhn.fhir.jpa.starter.util.JpaHibernatePropertiesProvider; @@ -87,6 +88,40 @@ public FhirServerConfigCommon(AppProperties appProperties) { } } + @Bean + public SubscriptionSettings subscriptionSettings(AppProperties appProperties) { + SubscriptionSettings subscriptionSettings = new SubscriptionSettings(); + if (appProperties.getSubscription() != null) { + if (appProperties.getSubscription().getEmail() != null) + subscriptionSettings.setEmailFromAddress( + appProperties.getSubscription().getEmail().getFrom()); + + // Subscriptions are enabled by channel type + if (appProperties.getSubscription().getResthook_enabled()) { + ourLog.info("Enabling REST-hook subscriptions"); + subscriptionSettings.addSupportedSubscriptionType( + org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.RESTHOOK); + } + if (appProperties.getSubscription().getEmail() != null) { + ourLog.info("Enabling email subscriptions"); + subscriptionSettings.addSupportedSubscriptionType( + org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.EMAIL); + } + if (appProperties.getSubscription().getWebsocket_enabled()) { + ourLog.info("Enabling websocket subscriptions"); + subscriptionSettings.addSupportedSubscriptionType( + org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET); + } + + } + if (appProperties.getMdm_enabled()) { + // MDM requires the subscription of type message + ourLog.info("Enabling message subscriptions"); + subscriptionSettings.addSupportedSubscriptionType( + org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.MESSAGE); + } + return subscriptionSettings; + } /** * Configure FHIR properties around the JPA server via this bean */ @@ -114,10 +149,7 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) { jpaStorageSettings.setDeleteExpungeEnabled(appProperties.getDelete_expunge_enabled()); jpaStorageSettings.setExpungeEnabled(appProperties.getExpunge_enabled()); jpaStorageSettings.setLanguageSearchParameterEnabled(appProperties.getLanguage_search_parameter_enabled()); - if (appProperties.getSubscription() != null - && appProperties.getSubscription().getEmail() != null) - jpaStorageSettings.setEmailFromAddress( - appProperties.getSubscription().getEmail().getFrom()); + Integer maxFetchSize = appProperties.getMax_page_size(); jpaStorageSettings.setFetchSizeDefaultMaximum(maxFetchSize); @@ -131,24 +163,7 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) { Long retainCachedSearchesMinutes = appProperties.getRetain_cached_searches_mins(); jpaStorageSettings.setExpireSearchResultsAfterMillis(retainCachedSearchesMinutes * 60 * 1000); - if (appProperties.getSubscription() != null) { - // Subscriptions are enabled by channel type - if (appProperties.getSubscription().getResthook_enabled()) { - ourLog.info("Enabling REST-hook subscriptions"); - jpaStorageSettings.addSupportedSubscriptionType( - org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.RESTHOOK); - } - if (appProperties.getSubscription().getEmail() != null) { - ourLog.info("Enabling email subscriptions"); - jpaStorageSettings.addSupportedSubscriptionType( - org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.EMAIL); - } - if (appProperties.getSubscription().getWebsocket_enabled()) { - ourLog.info("Enabling websocket subscriptions"); - jpaStorageSettings.addSupportedSubscriptionType( - org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET); - } - } + jpaStorageSettings.setFilterParameterEnabled(appProperties.getFilter_search_enabled()); jpaStorageSettings.setAdvancedHSearchIndexing(appProperties.getAdvanced_lucene_indexing()); @@ -204,13 +219,6 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) { 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; } @@ -251,10 +259,6 @@ protected StorageSettings storageSettings(AppProperties appProperties, JpaStorag jpaStorageSettings.setAllowExternalReferences(appProperties.getAllow_external_references()); jpaStorageSettings.setDefaultSearchParamsCanBeOverridden( appProperties.getAllow_override_default_search_params()); - if (appProperties.getSubscription() != null - && appProperties.getSubscription().getEmail() != null) - jpaStorageSettings.setEmailFromAddress( - appProperties.getSubscription().getEmail().getFrom()); jpaStorageSettings.setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level()); diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java index 6ff4c5e1262..31662888f76 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java @@ -30,6 +30,7 @@ import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor; import ca.uhn.fhir.jpa.interceptor.validation.RepositoryValidatingInterceptor; import ca.uhn.fhir.jpa.ips.provider.IpsOperationProvider; +import ca.uhn.fhir.jpa.model.config.SubscriptionSettings; import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc; import ca.uhn.fhir.jpa.packages.PackageInstallationSpec; import ca.uhn.fhir.jpa.partition.PartitionManagementProvider; @@ -252,6 +253,7 @@ public RestfulServer restfulServer( IJpaSystemProvider jpaSystemProvider, ResourceProviderFactory resourceProviderFactory, JpaStorageSettings jpaStorageSettings, + SubscriptionSettings subscriptionSettings, ISearchParamRegistry searchParamRegistry, IValidationSupport theValidationSupport, DatabaseBackedPagingProvider databaseBackedPagingProvider, @@ -378,7 +380,7 @@ public RestfulServer restfulServer( corsInterceptor.ifPresent(fhirServer::registerInterceptor); - if (jpaStorageSettings.getSupportedSubscriptionTypes().size() > 0) { + if (!subscriptionSettings.getSupportedSubscriptionTypes().isEmpty()) { // Subscription debug logging fhirServer.registerInterceptor(new SubscriptionDebugLogInterceptor()); } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 394c97b0382..8c8e18d7315 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -126,7 +126,7 @@ hapi: ### This enables the swagger-ui at /fhir/swagger-ui/index.html as well as the /fhir/api-docs (see https://hapifhir.io/hapi-fhir/docs/server_plain/openapi.html) openapi_enabled: true ### This is the FHIR version. Choose between, DSTU2, DSTU3, R4 or R5 - fhir_version: R4 + fhir_version: R5 ### Flag is false by default. This flag enables runtime installation of IG's. ig_runtime_upload_enabled: false ### This flag when enabled to true, will avail evaluate measure operations from CR Module. @@ -277,9 +277,9 @@ hapi: # binary_storage_enabled: true inline_resource_storage_below_size: 4000 # bulk_export_enabled: true -# subscription: + subscription: # resthook_enabled: true -# websocket_enabled: false + websocket_enabled: true # email: # from: some@test.com # host: google.com @@ -308,3 +308,4 @@ hapi: # protocol: 'http' # schema_management_strategy: CREATE # username: SomeUsername + diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java index 3d706b6a392..32fabbce76c 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java @@ -43,7 +43,6 @@ RepositoryConfig.class }, properties = { - "spring.profiles.include=storageSettingsTest", "spring.datasource.url=jdbc:h2:mem:dbr3", "hapi.fhir.fhir_version=dstu3", "hapi.fhir.cr_enabled=true", diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java index 59e06b82190..d7b46315dbd 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java @@ -55,11 +55,10 @@ NicknameServiceConfig.class, RepositoryConfig.class }, properties = { - "spring.profiles.include=storageSettingsTest", "spring.datasource.url=jdbc:h2:mem:dbr4", "hapi.fhir.enable_repository_validating_interceptor=true", "hapi.fhir.fhir_version=r4", - //"hapi.fhir.subscription.websocket_enabled=true", + "hapi.fhir.subscription.websocket_enabled=true", //"hapi.fhir.mdm_enabled=true", "hapi.fhir.cr.enabled=true", "hapi.fhir.cr.caregaps.section_author=Organization/alphora-author", @@ -230,7 +229,7 @@ void testWebsocketSubscription() throws Exception { IIdType mySubscriptionId = methodOutcome.getId(); // Wait for the subscription to be activated - await().atMost(1, TimeUnit.MINUTES).until(()->activeSubscriptionCount(), equalTo(initialActiveSubscriptionCount + 1)); + await().atMost(1, TimeUnit.MINUTES).until(this::activeSubscriptionCount, equalTo(initialActiveSubscriptionCount + 1)); /* * Attach websocket diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/JpaStorageSettingsConfig.java b/src/test/java/ca/uhn/fhir/jpa/starter/JpaStorageSettingsConfig.java deleted file mode 100644 index 8ed4bce0cbd..00000000000 --- a/src/test/java/ca/uhn/fhir/jpa/starter/JpaStorageSettingsConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package ca.uhn.fhir.jpa.starter; - -import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; -import org.hl7.fhir.dstu2.model.Subscription; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.Profile; - -@Profile("storageSettingsTest") -@Configuration -public class JpaStorageSettingsConfig { - @Primary - @Bean - public JpaStorageSettings storageSettings() { - JpaStorageSettings retVal = new JpaStorageSettings(); - - retVal.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.WEBSOCKET); - retVal.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.MESSAGE); - return retVal; - } -} diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/MdmTest.java b/src/test/java/ca/uhn/fhir/jpa/starter/MdmTest.java index 4fc080195be..bd1f58db633 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/MdmTest.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/MdmTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; +import ca.uhn.fhir.jpa.model.config.SubscriptionSettings; import org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -21,9 +22,12 @@ class MdmTest { @Autowired JpaStorageSettings jpaStorageSettings; + @Autowired + SubscriptionSettings subscriptionSettings; + @Test void testApplicationStartedSuccessfully() { assertThat(nicknameService).isNotNull(); - assertThat(jpaStorageSettings.getSupportedSubscriptionTypes()).contains(SubscriptionChannelType.MESSAGE); + assertThat(subscriptionSettings.getSupportedSubscriptionTypes()).contains(SubscriptionChannelType.MESSAGE); } } diff --git a/src/test/smoketest/plain_server.http b/src/test/smoketest/plain_server.http index ff159a46a17..572a48f4e1c 100644 --- a/src/test/smoketest/plain_server.http +++ b/src/test/smoketest/plain_server.http @@ -87,7 +87,7 @@ Content-Type: application/json }); const batch_patient_location = response.body.entry[0].response.location; const indexOfHistory = batch_patient_location.lastIndexOf("/_history"); - trimmed_location = batch_patient_location.substring(0, indexOfHistory); + var trimmed_location = batch_patient_location.substring(0, indexOfHistory); trimmed_location = trimmed_location.replace("Patient/", "") client.global.set("batch_patient_id", trimmed_location); %}