Skip to content

Commit

Permalink
Issue #2609 - Change parameter hash if legacy search params enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Troy Biesterfeld <tbieste@us.ibm.com>
  • Loading branch information
tbieste committed Jul 19, 2021
1 parent 7013dd4 commit 241f06b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -2137,6 +2137,7 @@ private ExtractedSearchParameters extractSearchParameters(Resource fhirResource,
// this visitor is deterministic.
sortExtractedParameterValues(allParameters);
ParameterHashVisitor phv = new ParameterHashVisitor();
phv.setLegacyWholeSystemSearchParamsEnabled(legacyWholeSystemSearchParamsEnabled);
for (ExtractedParameterValue p: allParameters) {
p.accept(phv);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ public ParameterHashVisitor() {
encoder = Base64.getEncoder();
}

/**
* If legacyWholeSystemSearchParamsEnabled is true, then update digest to ensure hash changes
* from when legacyWholeSystemSearchParamsEnabled is false; this can be removed when the
* legacyWholeSystemSearchParamsEnabled config setting is removed.
* @param enabled true or false
*/
public void setLegacyWholeSystemSearchParamsEnabled(boolean enabled) {
if (enabled) {
updateDigestWithString("legacyWholeSystemSearchParamsEnabled");
}
}

@Override
public void visit(StringParmVal param) throws FHIRPersistenceException {
updateDigestWithParmValKey(param);
Expand Down

0 comments on commit 241f06b

Please sign in to comment.