|
|
|
@@ -14,9 +14,11 @@ import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender;
|
|
|
|
import ca.uhn.fhir.rest.server.mail.IMailSvc;
|
|
|
|
import ca.uhn.fhir.rest.server.mail.IMailSvc;
|
|
|
|
import ca.uhn.fhir.rest.server.mail.MailConfig;
|
|
|
|
import ca.uhn.fhir.rest.server.mail.MailConfig;
|
|
|
|
import ca.uhn.fhir.rest.server.mail.MailSvc;
|
|
|
|
import ca.uhn.fhir.rest.server.mail.MailSvc;
|
|
|
|
|
|
|
|
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
|
|
|
|
|
|
|
|
|
|
|
|
import com.google.common.base.Strings;
|
|
|
|
import com.google.common.base.Strings;
|
|
|
|
import org.hl7.fhir.r4.model.Bundle.BundleType;
|
|
|
|
import org.hl7.fhir.r4.model.Bundle.BundleType;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.FactoryBean;
|
|
|
|
import org.springframework.boot.env.YamlPropertySourceLoader;
|
|
|
|
import org.springframework.boot.env.YamlPropertySourceLoader;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
@@ -38,20 +40,28 @@ public class FhirServerConfigCommon {
|
|
|
|
|
|
|
|
|
|
|
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirServerConfigCommon.class);
|
|
|
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirServerConfigCommon.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public FhirServerConfigCommon(AppProperties appProperties) {
|
|
|
|
public FhirServerConfigCommon(AppProperties appProperties) {
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getAllow_contains_searches() ? "allow" : "deny") + " contains searches");
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getAllow_contains_searches() ? "allow" : "deny")
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getAllow_multiple_delete() ? "allow" : "deny") + " multiple deletes");
|
|
|
|
+ " contains searches");
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getAllow_external_references() ? "allow" : "deny") + " external references");
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getAllow_multiple_delete() ? "allow" : "deny")
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getDao_scheduling_enabled() ? "enable" : "disable") + " DAO scheduling");
|
|
|
|
+ " multiple deletes");
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getDelete_expunge_enabled() ? "enable" : "disable") + " delete expunges");
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getAllow_external_references() ? "allow" : "deny")
|
|
|
|
|
|
|
|
+ " external references");
|
|
|
|
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getDao_scheduling_enabled() ? "enable" : "disable")
|
|
|
|
|
|
|
|
+ " DAO scheduling");
|
|
|
|
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getDelete_expunge_enabled() ? "enable" : "disable")
|
|
|
|
|
|
|
|
+ " delete expunges");
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getExpunge_enabled() ? "enable" : "disable") + " expunges");
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getExpunge_enabled() ? "enable" : "disable") + " expunges");
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getAllow_override_default_search_params() ? "allow" : "deny") + " overriding default search params");
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getAllow_override_default_search_params() ? "allow" : "deny")
|
|
|
|
ourLog.info("Server configured to " + (appProperties.getAuto_create_placeholder_reference_targets() ? "allow" : "disable") + " auto-creating placeholder references");
|
|
|
|
+ " overriding default search params");
|
|
|
|
|
|
|
|
ourLog.info("Server configured to "
|
|
|
|
|
|
|
|
+ (appProperties.getAuto_create_placeholder_reference_targets() ? "allow" : "disable")
|
|
|
|
|
|
|
|
+ " auto-creating placeholder references");
|
|
|
|
|
|
|
|
|
|
|
|
if (appProperties.getSubscription().getEmail() != null) {
|
|
|
|
if (appProperties.getSubscription().getEmail() != null) {
|
|
|
|
AppProperties.Subscription.Email email = appProperties.getSubscription().getEmail();
|
|
|
|
AppProperties.Subscription.Email email = appProperties.getSubscription().getEmail();
|
|
|
|
ourLog.info("Server is configured to enable email with host '" + email.getHost() + "' and port " + email.getPort());
|
|
|
|
ourLog.info(
|
|
|
|
|
|
|
|
"Server is configured to enable email with host '" + email.getHost() + "' and port " + email.getPort());
|
|
|
|
ourLog.info("Server will use '" + email.getFrom() + "' as the from email address");
|
|
|
|
ourLog.info("Server will use '" + email.getFrom() + "' as the from email address");
|
|
|
|
|
|
|
|
|
|
|
|
if (!Strings.isNullOrEmpty(email.getUsername())) {
|
|
|
|
if (!Strings.isNullOrEmpty(email.getUsername())) {
|
|
|
|
@@ -83,44 +93,52 @@ public class FhirServerConfigCommon {
|
|
|
|
public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
|
|
|
|
public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
|
|
|
|
JpaStorageSettings jpaStorageSettings = new JpaStorageSettings();
|
|
|
|
JpaStorageSettings jpaStorageSettings = new JpaStorageSettings();
|
|
|
|
|
|
|
|
|
|
|
|
jpaStorageSettings.setIndexMissingFields(appProperties.getEnable_index_missing_fields() ? JpaStorageSettings.IndexEnabledEnum.ENABLED : JpaStorageSettings.IndexEnabledEnum.DISABLED);
|
|
|
|
jpaStorageSettings.setIndexMissingFields(
|
|
|
|
jpaStorageSettings.setAutoCreatePlaceholderReferenceTargets(appProperties.getAuto_create_placeholder_reference_targets());
|
|
|
|
appProperties.getEnable_index_missing_fields() ? JpaStorageSettings.IndexEnabledEnum.ENABLED
|
|
|
|
jpaStorageSettings.setEnforceReferentialIntegrityOnWrite(appProperties.getEnforce_referential_integrity_on_write());
|
|
|
|
: JpaStorageSettings.IndexEnabledEnum.DISABLED);
|
|
|
|
jpaStorageSettings.setEnforceReferentialIntegrityOnDelete(appProperties.getEnforce_referential_integrity_on_delete());
|
|
|
|
jpaStorageSettings
|
|
|
|
|
|
|
|
.setAutoCreatePlaceholderReferenceTargets(appProperties.getAuto_create_placeholder_reference_targets());
|
|
|
|
|
|
|
|
jpaStorageSettings
|
|
|
|
|
|
|
|
.setEnforceReferentialIntegrityOnWrite(appProperties.getEnforce_referential_integrity_on_write());
|
|
|
|
|
|
|
|
jpaStorageSettings
|
|
|
|
|
|
|
|
.setEnforceReferentialIntegrityOnDelete(appProperties.getEnforce_referential_integrity_on_delete());
|
|
|
|
jpaStorageSettings.setAllowContainsSearches(appProperties.getAllow_contains_searches());
|
|
|
|
jpaStorageSettings.setAllowContainsSearches(appProperties.getAllow_contains_searches());
|
|
|
|
jpaStorageSettings.setAllowMultipleDelete(appProperties.getAllow_multiple_delete());
|
|
|
|
jpaStorageSettings.setAllowMultipleDelete(appProperties.getAllow_multiple_delete());
|
|
|
|
jpaStorageSettings.setAllowExternalReferences(appProperties.getAllow_external_references());
|
|
|
|
jpaStorageSettings.setAllowExternalReferences(appProperties.getAllow_external_references());
|
|
|
|
jpaStorageSettings.setSchedulingDisabled(!appProperties.getDao_scheduling_enabled());
|
|
|
|
jpaStorageSettings.setSchedulingDisabled(!appProperties.getDao_scheduling_enabled());
|
|
|
|
jpaStorageSettings.setDeleteExpungeEnabled(appProperties.getDelete_expunge_enabled());
|
|
|
|
jpaStorageSettings.setDeleteExpungeEnabled(appProperties.getDelete_expunge_enabled());
|
|
|
|
jpaStorageSettings.setExpungeEnabled(appProperties.getExpunge_enabled());
|
|
|
|
jpaStorageSettings.setExpungeEnabled(appProperties.getExpunge_enabled());
|
|
|
|
if(appProperties.getSubscription() != null && appProperties.getSubscription().getEmail() != null)
|
|
|
|
if (appProperties.getSubscription() != null && appProperties.getSubscription().getEmail() != null)
|
|
|
|
jpaStorageSettings.setEmailFromAddress(appProperties.getSubscription().getEmail().getFrom());
|
|
|
|
jpaStorageSettings.setEmailFromAddress(appProperties.getSubscription().getEmail().getFrom());
|
|
|
|
|
|
|
|
|
|
|
|
Integer maxFetchSize = appProperties.getMax_page_size();
|
|
|
|
Integer maxFetchSize = appProperties.getMax_page_size();
|
|
|
|
jpaStorageSettings.setFetchSizeDefaultMaximum(maxFetchSize);
|
|
|
|
jpaStorageSettings.setFetchSizeDefaultMaximum(maxFetchSize);
|
|
|
|
ourLog.info("Server configured to have a maximum fetch size of " + (maxFetchSize == Integer.MAX_VALUE ? "'unlimited'" : maxFetchSize));
|
|
|
|
ourLog.info("Server configured to have a maximum fetch size of "
|
|
|
|
|
|
|
|
+ (maxFetchSize == Integer.MAX_VALUE ? "'unlimited'" : maxFetchSize));
|
|
|
|
|
|
|
|
|
|
|
|
Long reuseCachedSearchResultsMillis = appProperties.getReuse_cached_search_results_millis();
|
|
|
|
Long reuseCachedSearchResultsMillis = appProperties.getReuse_cached_search_results_millis();
|
|
|
|
jpaStorageSettings.setReuseCachedSearchResultsForMillis(reuseCachedSearchResultsMillis);
|
|
|
|
jpaStorageSettings.setReuseCachedSearchResultsForMillis(reuseCachedSearchResultsMillis);
|
|
|
|
ourLog.info("Server configured to cache search results for {} milliseconds", reuseCachedSearchResultsMillis);
|
|
|
|
ourLog.info("Server configured to cache search results for {} milliseconds", reuseCachedSearchResultsMillis);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long retainCachedSearchesMinutes = appProperties.getRetain_cached_searches_mins();
|
|
|
|
Long retainCachedSearchesMinutes = appProperties.getRetain_cached_searches_mins();
|
|
|
|
jpaStorageSettings.setExpireSearchResultsAfterMillis(retainCachedSearchesMinutes * 60 * 1000);
|
|
|
|
jpaStorageSettings.setExpireSearchResultsAfterMillis(retainCachedSearchesMinutes * 60 * 1000);
|
|
|
|
|
|
|
|
|
|
|
|
if(appProperties.getSubscription() != null) {
|
|
|
|
if (appProperties.getSubscription() != null) {
|
|
|
|
// Subscriptions are enabled by channel type
|
|
|
|
// Subscriptions are enabled by channel type
|
|
|
|
if (appProperties.getSubscription().getResthook_enabled()) {
|
|
|
|
if (appProperties.getSubscription().getResthook_enabled()) {
|
|
|
|
ourLog.info("Enabling REST-hook subscriptions");
|
|
|
|
ourLog.info("Enabling REST-hook subscriptions");
|
|
|
|
jpaStorageSettings.addSupportedSubscriptionType(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.RESTHOOK);
|
|
|
|
jpaStorageSettings
|
|
|
|
|
|
|
|
.addSupportedSubscriptionType(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.RESTHOOK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (appProperties.getSubscription().getEmail() != null) {
|
|
|
|
if (appProperties.getSubscription().getEmail() != null) {
|
|
|
|
ourLog.info("Enabling email subscriptions");
|
|
|
|
ourLog.info("Enabling email subscriptions");
|
|
|
|
jpaStorageSettings.addSupportedSubscriptionType(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.EMAIL);
|
|
|
|
jpaStorageSettings
|
|
|
|
|
|
|
|
.addSupportedSubscriptionType(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.EMAIL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (appProperties.getSubscription().getWebsocket_enabled()) {
|
|
|
|
if (appProperties.getSubscription().getWebsocket_enabled()) {
|
|
|
|
ourLog.info("Enabling websocket subscriptions");
|
|
|
|
ourLog.info("Enabling websocket subscriptions");
|
|
|
|
jpaStorageSettings.addSupportedSubscriptionType(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET);
|
|
|
|
jpaStorageSettings.addSupportedSubscriptionType(
|
|
|
|
|
|
|
|
org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -132,7 +150,7 @@ public class FhirServerConfigCommon {
|
|
|
|
jpaStorageSettings.setLastNEnabled(true);
|
|
|
|
jpaStorageSettings.setLastNEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(appProperties.getInline_resource_storage_below_size() != 0){
|
|
|
|
if (appProperties.getInline_resource_storage_below_size() != 0) {
|
|
|
|
jpaStorageSettings.setInlineResourceTextBelowSize(appProperties.getInline_resource_storage_below_size());
|
|
|
|
jpaStorageSettings.setInlineResourceTextBelowSize(appProperties.getInline_resource_storage_below_size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -140,20 +158,19 @@ public class FhirServerConfigCommon {
|
|
|
|
jpaStorageSettings.setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level());
|
|
|
|
jpaStorageSettings.setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level());
|
|
|
|
jpaStorageSettings.setIndexOnContainedResources(appProperties.getEnable_index_contained_resource());
|
|
|
|
jpaStorageSettings.setIndexOnContainedResources(appProperties.getEnable_index_contained_resource());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (appProperties.getAllowed_bundle_types() != null) {
|
|
|
|
if (appProperties.getAllowed_bundle_types() != null) {
|
|
|
|
jpaStorageSettings.setBundleTypesAllowedForStorage(appProperties.getAllowed_bundle_types().stream().map(BundleType::toCode).collect(Collectors.toSet()));
|
|
|
|
jpaStorageSettings.setBundleTypesAllowedForStorage(
|
|
|
|
|
|
|
|
appProperties.getAllowed_bundle_types().stream().map(BundleType::toCode).collect(Collectors.toSet()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
jpaStorageSettings.setDeferIndexingForCodesystemsOfSize(appProperties.getDefer_indexing_for_codesystems_of_size());
|
|
|
|
jpaStorageSettings
|
|
|
|
|
|
|
|
.setDeferIndexingForCodesystemsOfSize(appProperties.getDefer_indexing_for_codesystems_of_size());
|
|
|
|
|
|
|
|
|
|
|
|
if (appProperties.getClient_id_strategy() == JpaStorageSettings.ClientIdStrategyEnum.ANY) {
|
|
|
|
if (appProperties.getClient_id_strategy() == JpaStorageSettings.ClientIdStrategyEnum.ANY) {
|
|
|
|
jpaStorageSettings.setResourceServerIdStrategy(JpaStorageSettings.IdStrategyEnum.UUID);
|
|
|
|
jpaStorageSettings.setResourceServerIdStrategy(JpaStorageSettings.IdStrategyEnum.UUID);
|
|
|
|
jpaStorageSettings.setResourceClientIdStrategy(appProperties.getClient_id_strategy());
|
|
|
|
jpaStorageSettings.setResourceClientIdStrategy(appProperties.getClient_id_strategy());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Parallel Batch GET execution settings
|
|
|
|
// Parallel Batch GET execution settings
|
|
|
|
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size());
|
|
|
|
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size());
|
|
|
|
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size());
|
|
|
|
jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -173,8 +190,9 @@ public class FhirServerConfigCommon {
|
|
|
|
// Partitioning
|
|
|
|
// Partitioning
|
|
|
|
if (appProperties.getPartitioning() != null) {
|
|
|
|
if (appProperties.getPartitioning() != null) {
|
|
|
|
retVal.setPartitioningEnabled(true);
|
|
|
|
retVal.setPartitioningEnabled(true);
|
|
|
|
retVal.setIncludePartitionInSearchHashes(appProperties.getPartitioning().getPartitioning_include_in_search_hashes());
|
|
|
|
retVal.setIncludePartitionInSearchHashes(
|
|
|
|
if(appProperties.getPartitioning().getAllow_references_across_partitions()) {
|
|
|
|
appProperties.getPartitioning().getPartitioning_include_in_search_hashes());
|
|
|
|
|
|
|
|
if (appProperties.getPartitioning().getAllow_references_across_partitions()) {
|
|
|
|
retVal.setAllowReferencesAcrossPartitions(CrossPartitionReferenceMode.ALLOWED_UNQUALIFIED);
|
|
|
|
retVal.setAllowReferencesAcrossPartitions(CrossPartitionReferenceMode.ALLOWED_UNQUALIFIED);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
retVal.setAllowReferencesAcrossPartitions(CrossPartitionReferenceMode.NOT_ALLOWED);
|
|
|
|
retVal.setAllowReferencesAcrossPartitions(CrossPartitionReferenceMode.NOT_ALLOWED);
|
|
|
|
@@ -184,19 +202,18 @@ public class FhirServerConfigCommon {
|
|
|
|
return retVal;
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Primary
|
|
|
|
@Primary
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
public HibernatePropertiesProvider jpaStarterDialectProvider(LocalContainerEntityManagerFactoryBean myEntityManagerFactory) {
|
|
|
|
public HibernatePropertiesProvider jpaStarterDialectProvider(
|
|
|
|
|
|
|
|
LocalContainerEntityManagerFactoryBean myEntityManagerFactory) {
|
|
|
|
return new JpaHibernatePropertiesProvider(myEntityManagerFactory);
|
|
|
|
return new JpaHibernatePropertiesProvider(myEntityManagerFactory);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected StorageSettings storageSettings(AppProperties appProperties, JpaStorageSettings jpaStorageSettings) {
|
|
|
|
protected StorageSettings storageSettings(AppProperties appProperties, JpaStorageSettings jpaStorageSettings) {
|
|
|
|
jpaStorageSettings.setAllowContainsSearches(appProperties.getAllow_contains_searches());
|
|
|
|
jpaStorageSettings.setAllowContainsSearches(appProperties.getAllow_contains_searches());
|
|
|
|
jpaStorageSettings.setAllowExternalReferences(appProperties.getAllow_external_references());
|
|
|
|
jpaStorageSettings.setAllowExternalReferences(appProperties.getAllow_external_references());
|
|
|
|
jpaStorageSettings.setDefaultSearchParamsCanBeOverridden(appProperties.getAllow_override_default_search_params());
|
|
|
|
jpaStorageSettings.setDefaultSearchParamsCanBeOverridden(appProperties.getAllow_override_default_search_params());
|
|
|
|
if(appProperties.getSubscription() != null && appProperties.getSubscription().getEmail() != null)
|
|
|
|
if (appProperties.getSubscription() != null && appProperties.getSubscription().getEmail() != null)
|
|
|
|
jpaStorageSettings.setEmailFromAddress(appProperties.getSubscription().getEmail().getFrom());
|
|
|
|
jpaStorageSettings.setEmailFromAddress(appProperties.getSubscription().getEmail().getFrom());
|
|
|
|
|
|
|
|
|
|
|
|
jpaStorageSettings.setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level());
|
|
|
|
jpaStorageSettings.setNormalizedQuantitySearchLevel(appProperties.getNormalized_quantity_search_level());
|
|
|
|
|