Skip to content

Commit 01a488a

Browse files
Allow all client_id_strategy options and add server_id_strategy (#653)
1 parent 4226648 commit 01a488a

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import ca.uhn.fhir.context.FhirVersionEnum;
55
import ca.uhn.fhir.jpa.api.config.JpaStorageSettings.ClientIdStrategyEnum;
6+
import ca.uhn.fhir.jpa.api.config.JpaStorageSettings.IdStrategyEnum;
67
import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel;
78
import ca.uhn.fhir.jpa.packages.PackageInstallationSpec;
89
import ca.uhn.fhir.rest.api.EncodingEnum;
@@ -65,6 +66,7 @@ public class AppProperties {
6566
private EncodingEnum default_encoding = EncodingEnum.JSON;
6667
private FhirVersionEnum fhir_version = FhirVersionEnum.R4;
6768
private ClientIdStrategyEnum client_id_strategy = ClientIdStrategyEnum.ALPHANUMERIC;
69+
private IdStrategyEnum server_id_strategy = null;
6870
private List<String> supported_resource_types = new ArrayList<>();
6971
private List<Bundle.BundleType> allowed_bundle_types = null;
7072
private Boolean narrative_enabled = true;
@@ -263,7 +265,15 @@ public void setClient_id_strategy(
263265
this.client_id_strategy = client_id_strategy;
264266
}
265267

266-
public boolean getAdvanced_lucene_indexing() {
268+
public IdStrategyEnum getServer_id_strategy() {
269+
return server_id_strategy;
270+
}
271+
272+
public void setServer_id_strategy(IdStrategyEnum server_id_strategy) {
273+
this.server_id_strategy = server_id_strategy;
274+
}
275+
276+
public boolean getAdvanced_lucene_indexing() {
267277
return this.advanced_lucene_indexing;
268278
}
269279

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,27 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
174174
jpaStorageSettings.setDeferIndexingForCodesystemsOfSize(
175175
appProperties.getDefer_indexing_for_codesystems_of_size());
176176

177+
jpaStorageSettings.setResourceClientIdStrategy(appProperties.getClient_id_strategy());
178+
ourLog.info("Server configured to use '" + appProperties.getClient_id_strategy() + "' Client ID Strategy");
179+
180+
// Set and/or recommend default Server ID Strategy of UUID when using the ANY Client ID Strategy
177181
if (appProperties.getClient_id_strategy() == JpaStorageSettings.ClientIdStrategyEnum.ANY) {
178-
jpaStorageSettings.setResourceServerIdStrategy(JpaStorageSettings.IdStrategyEnum.UUID);
179-
jpaStorageSettings.setResourceClientIdStrategy(appProperties.getClient_id_strategy());
182+
if (appProperties.getServer_id_strategy() == null) {
183+
ourLog.info("Defaulting server to use '" + JpaStorageSettings.IdStrategyEnum.UUID
184+
+ "' Server ID Strategy when using the '" + JpaStorageSettings.ClientIdStrategyEnum.ANY
185+
+ "' Client ID Strategy");
186+
appProperties.setServer_id_strategy(JpaStorageSettings.IdStrategyEnum.UUID);
187+
} else if (appProperties.getServer_id_strategy() != JpaStorageSettings.IdStrategyEnum.UUID) {
188+
ourLog.warn("WARNING: '" + JpaStorageSettings.IdStrategyEnum.UUID
189+
+ "' Server ID Strategy is highly recommended when using the '"
190+
+ JpaStorageSettings.ClientIdStrategyEnum.ANY + "' Client ID Strategy");
191+
}
180192
}
193+
if (appProperties.getServer_id_strategy() != null) {
194+
jpaStorageSettings.setResourceServerIdStrategy(appProperties.getServer_id_strategy());
195+
ourLog.info("Server configured to use '" + appProperties.getServer_id_strategy() + "' Server ID Strategy");
196+
}
197+
181198
// Parallel Batch GET execution settings
182199
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size());
183200
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size());

src/main/resources/application.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ hapi:
139139
# etag_support_enabled: true
140140
# expunge_enabled: true
141141
# client_id_strategy: ALPHANUMERIC
142+
# server_id_strategy: SEQUENTIAL_NUMERIC
142143
# fhirpath_interceptor_enabled: false
143144
# filter_search_enabled: true
144145
# graphql_enabled: true

0 commit comments

Comments
 (0)