Skip to content

Commit 133017c

Browse files
committed
Merge branch 'do-20240617-subscription-update' into rel_7_3_tracking
2 parents 422d200 + db238aa commit 133017c

File tree

7 files changed

+48
-62
lines changed

7 files changed

+48
-62
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>ca.uhn.hapi.fhir</groupId>
1616
<artifactId>hapi-fhir</artifactId>
17-
<version>7.3.2-SNAPSHOT</version>
17+
<version>7.3.7-SNAPSHOT</version>
1818
</parent>
1919

2020
<artifactId>hapi-fhir-jpaserver-starter</artifactId>

src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import ca.uhn.fhir.jpa.config.HibernatePropertiesProvider;
77
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
88
import ca.uhn.fhir.jpa.model.config.PartitionSettings.CrossPartitionReferenceMode;
9+
import ca.uhn.fhir.jpa.model.config.SubscriptionSettings;
910
import ca.uhn.fhir.jpa.model.entity.StorageSettings;
1011
import ca.uhn.fhir.jpa.starter.AppProperties;
1112
import ca.uhn.fhir.jpa.starter.util.JpaHibernatePropertiesProvider;
@@ -87,6 +88,40 @@ public FhirServerConfigCommon(AppProperties appProperties) {
8788
}
8889
}
8990

91+
@Bean
92+
public SubscriptionSettings subscriptionSettings(AppProperties appProperties) {
93+
SubscriptionSettings subscriptionSettings = new SubscriptionSettings();
94+
if (appProperties.getSubscription() != null) {
95+
if (appProperties.getSubscription().getEmail() != null)
96+
subscriptionSettings.setEmailFromAddress(
97+
appProperties.getSubscription().getEmail().getFrom());
98+
99+
// Subscriptions are enabled by channel type
100+
if (appProperties.getSubscription().getResthook_enabled()) {
101+
ourLog.info("Enabling REST-hook subscriptions");
102+
subscriptionSettings.addSupportedSubscriptionType(
103+
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.RESTHOOK);
104+
}
105+
if (appProperties.getSubscription().getEmail() != null) {
106+
ourLog.info("Enabling email subscriptions");
107+
subscriptionSettings.addSupportedSubscriptionType(
108+
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.EMAIL);
109+
}
110+
if (appProperties.getSubscription().getWebsocket_enabled()) {
111+
ourLog.info("Enabling websocket subscriptions");
112+
subscriptionSettings.addSupportedSubscriptionType(
113+
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET);
114+
}
115+
116+
}
117+
if (appProperties.getMdm_enabled()) {
118+
// MDM requires the subscription of type message
119+
ourLog.info("Enabling message subscriptions");
120+
subscriptionSettings.addSupportedSubscriptionType(
121+
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.MESSAGE);
122+
}
123+
return subscriptionSettings;
124+
}
90125
/**
91126
* Configure FHIR properties around the JPA server via this bean
92127
*/
@@ -112,10 +147,7 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
112147
jpaStorageSettings.setDeleteExpungeEnabled(appProperties.getDelete_expunge_enabled());
113148
jpaStorageSettings.setExpungeEnabled(appProperties.getExpunge_enabled());
114149
jpaStorageSettings.setLanguageSearchParameterEnabled(appProperties.getLanguage_search_parameter_enabled());
115-
if (appProperties.getSubscription() != null
116-
&& appProperties.getSubscription().getEmail() != null)
117-
jpaStorageSettings.setEmailFromAddress(
118-
appProperties.getSubscription().getEmail().getFrom());
150+
119151

120152
Integer maxFetchSize = appProperties.getMax_page_size();
121153
jpaStorageSettings.setFetchSizeDefaultMaximum(maxFetchSize);
@@ -129,24 +161,7 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
129161
Long retainCachedSearchesMinutes = appProperties.getRetain_cached_searches_mins();
130162
jpaStorageSettings.setExpireSearchResultsAfterMillis(retainCachedSearchesMinutes * 60 * 1000);
131163

132-
if (appProperties.getSubscription() != null) {
133-
// Subscriptions are enabled by channel type
134-
if (appProperties.getSubscription().getResthook_enabled()) {
135-
ourLog.info("Enabling REST-hook subscriptions");
136-
jpaStorageSettings.addSupportedSubscriptionType(
137-
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.RESTHOOK);
138-
}
139-
if (appProperties.getSubscription().getEmail() != null) {
140-
ourLog.info("Enabling email subscriptions");
141-
jpaStorageSettings.addSupportedSubscriptionType(
142-
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.EMAIL);
143-
}
144-
if (appProperties.getSubscription().getWebsocket_enabled()) {
145-
ourLog.info("Enabling websocket subscriptions");
146-
jpaStorageSettings.addSupportedSubscriptionType(
147-
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET);
148-
}
149-
}
164+
150165

151166
jpaStorageSettings.setFilterParameterEnabled(appProperties.getFilter_search_enabled());
152167
jpaStorageSettings.setAdvancedHSearchIndexing(appProperties.getAdvanced_lucene_indexing());
@@ -202,13 +217,6 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
202217
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size());
203218
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size());
204219

205-
if (appProperties.getMdm_enabled()) {
206-
// MDM requires the subscription of type message
207-
ourLog.info("Enabling message subscriptions");
208-
jpaStorageSettings.addSupportedSubscriptionType(
209-
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.MESSAGE);
210-
}
211-
212220
storageSettings(appProperties, jpaStorageSettings);
213221
return jpaStorageSettings;
214222
}
@@ -249,10 +257,6 @@ protected StorageSettings storageSettings(AppProperties appProperties, JpaStorag
249257
jpaStorageSettings.setAllowExternalReferences(appProperties.getAllow_external_references());
250258
jpaStorageSettings.setDefaultSearchParamsCanBeOverridden(
251259
appProperties.getAllow_override_default_search_params());
252-
if (appProperties.getSubscription() != null
253-
&& appProperties.getSubscription().getEmail() != null)
254-
jpaStorageSettings.setEmailFromAddress(
255-
appProperties.getSubscription().getEmail().getFrom());
256260

257261
jpaStorageSettings.setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level());
258262

src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
3131
import ca.uhn.fhir.jpa.interceptor.validation.RepositoryValidatingInterceptor;
3232
import ca.uhn.fhir.jpa.ips.provider.IpsOperationProvider;
33+
import ca.uhn.fhir.jpa.model.config.SubscriptionSettings;
3334
import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc;
3435
import ca.uhn.fhir.jpa.packages.PackageInstallationSpec;
3536
import ca.uhn.fhir.jpa.partition.PartitionManagementProvider;
@@ -252,6 +253,7 @@ public RestfulServer restfulServer(
252253
IJpaSystemProvider jpaSystemProvider,
253254
ResourceProviderFactory resourceProviderFactory,
254255
JpaStorageSettings jpaStorageSettings,
256+
SubscriptionSettings subscriptionSettings,
255257
ISearchParamRegistry searchParamRegistry,
256258
IValidationSupport theValidationSupport,
257259
DatabaseBackedPagingProvider databaseBackedPagingProvider,
@@ -378,7 +380,7 @@ public RestfulServer restfulServer(
378380

379381
corsInterceptor.ifPresent(fhirServer::registerInterceptor);
380382

381-
if (jpaStorageSettings.getSupportedSubscriptionTypes().size() > 0) {
383+
if (!subscriptionSettings.getSupportedSubscriptionTypes().isEmpty()) {
382384
// Subscription debug logging
383385
fhirServer.registerInterceptor(new SubscriptionDebugLogInterceptor());
384386
}

src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
RepositoryConfig.class
4444
}, properties =
4545
{
46-
"spring.profiles.include=storageSettingsTest",
4746
"spring.datasource.url=jdbc:h2:mem:dbr3",
4847
"hapi.fhir.fhir_version=dstu3",
4948
"hapi.fhir.cr_enabled=true",

src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@
5555
NicknameServiceConfig.class,
5656
RepositoryConfig.class
5757
}, properties = {
58-
"spring.profiles.include=storageSettingsTest",
5958
"spring.datasource.url=jdbc:h2:mem:dbr4",
6059
"hapi.fhir.enable_repository_validating_interceptor=true",
6160
"hapi.fhir.fhir_version=r4",
62-
//"hapi.fhir.subscription.websocket_enabled=true",
61+
"hapi.fhir.subscription.websocket_enabled=true",
6362
//"hapi.fhir.mdm_enabled=true",
6463
"hapi.fhir.cr.enabled=true",
6564
"hapi.fhir.cr.caregaps_section_author=Organization/alphora-author",
@@ -237,7 +236,7 @@ void testWebsocketSubscription() throws Exception {
237236
IIdType mySubscriptionId = methodOutcome.getId();
238237

239238
// Wait for the subscription to be activated
240-
await().atMost(1, TimeUnit.MINUTES).until(()->activeSubscriptionCount(), equalTo(initialActiveSubscriptionCount + 1));
239+
await().atMost(1, TimeUnit.MINUTES).until(this::activeSubscriptionCount, equalTo(initialActiveSubscriptionCount + 1));
241240

242241
/*
243242
* Attach websocket

src/test/java/ca/uhn/fhir/jpa/starter/JpaStorageSettingsConfig.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/test/java/ca/uhn/fhir/jpa/starter/MdmTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.assertj.core.api.Assertions.assertThat;
44

5+
import ca.uhn.fhir.jpa.model.config.SubscriptionSettings;
56
import org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType;
67
import org.junit.jupiter.api.Test;
78
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,9 +22,12 @@ class MdmTest {
2122
@Autowired
2223
JpaStorageSettings jpaStorageSettings;
2324

25+
@Autowired
26+
SubscriptionSettings subscriptionSettings;
27+
2428
@Test
2529
void testApplicationStartedSuccessfully() {
2630
assertThat(nicknameService).isNotNull();
27-
assertThat(jpaStorageSettings.getSupportedSubscriptionTypes()).contains(SubscriptionChannelType.MESSAGE);
31+
assertThat(subscriptionSettings.getSupportedSubscriptionTypes()).contains(SubscriptionChannelType.MESSAGE);
2832
}
2933
}

0 commit comments

Comments
 (0)