diff --git a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/impl/FHIRPersistenceJDBCImpl.java b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/impl/FHIRPersistenceJDBCImpl.java index cb889e27bf1..41cbbe3524b 100644 --- a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/impl/FHIRPersistenceJDBCImpl.java +++ b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/impl/FHIRPersistenceJDBCImpl.java @@ -9,8 +9,8 @@ import static com.ibm.fhir.config.FHIRConfiguration.PROPERTY_JDBC_ENABLE_CODE_SYSTEMS_CACHE; import static com.ibm.fhir.config.FHIRConfiguration.PROPERTY_JDBC_ENABLE_PARAMETER_NAMES_CACHE; import static com.ibm.fhir.config.FHIRConfiguration.PROPERTY_JDBC_ENABLE_RESOURCE_TYPES_CACHE; -import static com.ibm.fhir.config.FHIRConfiguration.PROPERTY_SEARCH_ENABLE_OPT_QUERY_BUILDER; import static com.ibm.fhir.config.FHIRConfiguration.PROPERTY_SEARCH_ENABLE_LEGACY_WHOLE_SYSTEM_SEARCH_PARAMS; +import static com.ibm.fhir.config.FHIRConfiguration.PROPERTY_SEARCH_ENABLE_OPT_QUERY_BUILDER; import static com.ibm.fhir.config.FHIRConfiguration.PROPERTY_UPDATE_CREATE_ENABLED; import static com.ibm.fhir.model.type.String.string; import static com.ibm.fhir.model.util.ModelSupport.getResourceType; @@ -266,7 +266,7 @@ public FHIRPersistenceJDBCImpl(FHIRPersistenceJDBCCache cache) throws Exception this.connectionStrategy = new FHIRDbTenantDatasourceConnectionStrategy(trxSynchRegistry, buildActionChain(), enableReadOnlyReplicas); this.transactionAdapter = new FHIRUserTransactionAdapter(userTransaction, trxSynchRegistry, cache, TXN_DATA_KEY); - + // Use of legacy whole-system search parameters disabled by default this.legacyWholeSystemSearchParamsEnabled = fhirConfig.getBooleanProperty(PROPERTY_SEARCH_ENABLE_LEGACY_WHOLE_SYSTEM_SEARCH_PARAMS, false); @@ -2136,7 +2136,7 @@ private ExtractedSearchParameters extractSearchParameters(Resource fhirResource, // Sort extracted parameter values in natural order first, to ensure the hash generated by // this visitor is deterministic. sortExtractedParameterValues(allParameters); - ParameterHashVisitor phv = new ParameterHashVisitor(); + ParameterHashVisitor phv = new ParameterHashVisitor(legacyWholeSystemSearchParamsEnabled); for (ExtractedParameterValue p: allParameters) { p.accept(phv); } diff --git a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/util/ParameterHashVisitor.java b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/util/ParameterHashVisitor.java index f2cb740f6ba..103de636abd 100644 --- a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/util/ParameterHashVisitor.java +++ b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/util/ParameterHashVisitor.java @@ -47,10 +47,25 @@ public class ParameterHashVisitor implements ExtractedParameterValueVisitor { * Public constructor. */ public ParameterHashVisitor() { + this(false); + } + + /** + * Public constructor. + * @param legacyWholeSystemSearchParamsEnabled if true, then update digest to ensure hash changes + * from when it is false; this can be removed when the legacyWholeSystemSearchParamsEnabled config + * setting is removed. + */ + public ParameterHashVisitor(boolean legacyWholeSystemSearchParamsEnabled) { try { digest = MessageDigest.getInstance(SHA_256); // Start digest with latest FHIR schema version (with parameter storage update) digest.update(FhirSchemaVersion.getLatestParameterStorageUpdate().toString().getBytes(StandardCharsets.UTF_8)); + // If legacyWholeSystemSearchParamsEnabled is true, then update digest to ensure hash changes from when + // it is false; this can be removed when the legacyWholeSystemSearchParamsEnabled config setting is removed + if (legacyWholeSystemSearchParamsEnabled) { + updateDigestWithString("legacyWholeSystemSearchParamsEnabled"); + } } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("MessageDigest not found: " + SHA_256, e); }