Further adaption of new config class

This commit is contained in:
jkv
2020-09-06 07:29:32 +02:00
parent 5981456e54
commit d5c6abece9
6 changed files with 55 additions and 57 deletions

View File

@@ -32,18 +32,17 @@ public class AppProperties {
private Boolean graphql_enabled = true;
private Boolean binary_storage_enabled = true;
private Boolean bulk_export_enabled = true;
private Integer max_binary_size = 104857600;
private Integer max_page_size = Integer.MAX_VALUE;
private Integer retain_cached_searches_mins = 60;
private Long reuse_cached_search_results_millis = 60000L;
private EncodingEnum default_encoding = EncodingEnum.JSON;
private FhirVersionEnum fhir_version = FhirVersionEnum.R4;
private Integer max_binary_size = 104857600;
private Integer max_page_size = 200;
private Integer retain_cached_searches_mins = 60;
private Integer reuse_cached_search_results_millis = 60000;
private ClientIdStrategyEnum client_id_strategy = ClientIdStrategyEnum.ALPHANUMERIC;
private Validation validation;
private Server server;
private Logger logger;
private Validation validation = new Validation();
private Tester tester = new Tester();
private Logger logger = new Logger();
public Validation getValidation() {
return validation;
@@ -53,12 +52,12 @@ public class AppProperties {
this.validation = validation;
}
public Server getServer() {
return server;
public Tester getTester() {
return tester;
}
public void setServer(Server server) {
this.server = server;
public void setTester(Tester tester) {
this.tester = tester;
}
public Logger getLogger() {
@@ -266,11 +265,11 @@ public class AppProperties {
this.retain_cached_searches_mins = retain_cached_searches_mins;
}
public Integer getReuse_cached_search_results_millis() {
public Long getReuse_cached_search_results_millis() {
return reuse_cached_search_results_millis;
}
public void setReuse_cached_search_results_millis(Integer reuse_cached_search_results_millis) {
public void setReuse_cached_search_results_millis(Long reuse_cached_search_results_millis) {
this.reuse_cached_search_results_millis = reuse_cached_search_results_millis;
}
@@ -315,7 +314,7 @@ public class AppProperties {
}
public static class Server {
public static class Tester {
private String id = "home";
private String name = "Local Tester";

View File

@@ -1,7 +1,6 @@
package ca.uhn.fhir.jpa.starter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -13,8 +12,6 @@ import org.springframework.web.servlet.DispatcherServlet;
@ServletComponentScan(basePackageClasses = {JpaRestfulServer.class}, basePackages = "ca.uhn.fhir.jpa.starter")
@SpringBootApplication(exclude = ElasticsearchRestClientAutoConfiguration.class)
@EnableConfigurationProperties
@EnableAutoConfiguration
public class Application {
public static void main(String[] args) {

View File

@@ -30,6 +30,7 @@ public class FhirServerConfigCommon {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirServerConfigCommon.class);
private Boolean enableIndexMissingFields = HapiProperties.getEnableIndexMissingFields();
private Boolean autoCreatePlaceholderReferenceTargets = HapiProperties.getAutoCreatePlaceholderReferenceTargets();
private Boolean enforceReferentialIntegrityOnWrite = HapiProperties.getEnforceReferentialIntegrityOnWrite();
@@ -57,13 +58,13 @@ public class FhirServerConfigCommon {
@Autowired
private ApplicationContext appContext;
public FhirServerConfigCommon() {
ourLog.info("Server configured to " + (this.allowContainsSearches ? "allow" : "deny") + " contains searches");
ourLog.info("Server configured to " + (this.allowMultipleDelete ? "allow" : "deny") + " multiple deletes");
ourLog.info("Server configured to " + (this.allowExternalReferences ? "allow" : "deny") + " external references");
ourLog.info("Server configured to " + (this.expungeEnabled ? "enable" : "disable") + " expunges");
ourLog.info("Server configured to " + (this.allowPlaceholderReferences ? "allow" : "deny") + " placeholder references");
ourLog.info("Server configured to " + (this.allowOverrideDefaultSearchParams ? "allow" : "deny") + " overriding default search params");
public FhirServerConfigCommon(AppProperties appProperties) {
ourLog.info("Server configured to " + (appProperties.getAllow_contains_searches() ? "allow" : "deny") + " contains searches");
ourLog.info("Server configured to " + (appProperties.getAllow_multiple_delete() ? "allow" : "deny") + " multiple deletes");
ourLog.info("Server configured to " + (appProperties.getAllow_external_references() ? "allow" : "deny") + " external references");
ourLog.info("Server configured to " + (appProperties.getExpunge_enabled() ? "enable" : "disable") + " expunges");
ourLog.info("Server configured to " + (appProperties.getAllow_placeholder_references() ? "allow" : "deny") + " placeholder references");
ourLog.info("Server configured to " + (appProperties.getAllow_override_default_search_params() ? "allow" : "deny") + " overriding default search params");
if (this.emailEnabled) {
ourLog.info("Server is configured to enable email with host '" + this.emailHost + "' and port " + this.emailPort.toString());
@@ -91,25 +92,25 @@ public class FhirServerConfigCommon {
* Configure FHIR properties around the the JPA server via this bean
*/
@Bean()
public DaoConfig daoConfig() {
public DaoConfig daoConfig(AppProperties appProperties) {
DaoConfig retVal = new DaoConfig();
retVal.setIndexMissingFields(this.enableIndexMissingFields ? DaoConfig.IndexEnabledEnum.ENABLED : DaoConfig.IndexEnabledEnum.DISABLED);
retVal.setAutoCreatePlaceholderReferenceTargets(this.autoCreatePlaceholderReferenceTargets);
retVal.setEnforceReferentialIntegrityOnWrite(this.enforceReferentialIntegrityOnWrite);
retVal.setEnforceReferentialIntegrityOnDelete(this.enforceReferentialIntegrityOnDelete);
retVal.setAllowContainsSearches(this.allowContainsSearches);
retVal.setAllowMultipleDelete(this.allowMultipleDelete);
retVal.setAllowExternalReferences(this.allowExternalReferences);
retVal.setExpungeEnabled(this.expungeEnabled);
retVal.setAutoCreatePlaceholderReferenceTargets(this.allowPlaceholderReferences);
retVal.setIndexMissingFields(appProperties.getEnable_index_missing_fields() ? DaoConfig.IndexEnabledEnum.ENABLED : DaoConfig.IndexEnabledEnum.DISABLED);
retVal.setAutoCreatePlaceholderReferenceTargets(appProperties.getAuto_create_placeholder_reference_targets());
retVal.setEnforceReferentialIntegrityOnWrite(appProperties.getEnforce_referential_integrity_on_write());
retVal.setEnforceReferentialIntegrityOnDelete(appProperties.getEnforce_referential_integrity_on_delete());
retVal.setAllowContainsSearches(appProperties.getAllow_contains_searches());
retVal.setAllowMultipleDelete(appProperties.getAllow_multiple_delete());
retVal.setAllowExternalReferences(appProperties.getAllow_external_references());
retVal.setExpungeEnabled(appProperties.getExpunge_enabled());
retVal.setAutoCreatePlaceholderReferenceTargets(appProperties.getAllow_placeholder_references());
retVal.setEmailFromAddress(this.emailFrom);
Integer maxFetchSize = HapiProperties.getMaximumFetchSize();
Integer maxFetchSize = appProperties.getMax_page_size();
retVal.setFetchSizeDefaultMaximum(maxFetchSize);
ourLog.info("Server configured to have a maximum fetch size of " + (maxFetchSize == Integer.MAX_VALUE ? "'unlimited'" : maxFetchSize));
Long reuseCachedSearchResultsMillis = HapiProperties.getReuseCachedSearchResultsMillis();
Long reuseCachedSearchResultsMillis = appProperties.getReuse_cached_search_results_millis();
retVal.setReuseCachedSearchResultsForMillis(reuseCachedSearchResultsMillis);
ourLog.info("Server configured to cache search results for {} milliseconds", reuseCachedSearchResultsMillis);
@@ -149,11 +150,11 @@ public class FhirServerConfigCommon {
@Bean
public ModelConfig modelConfig() {
public ModelConfig modelConfig(AppProperties appProperties) {
ModelConfig modelConfig = new ModelConfig();
modelConfig.setAllowContainsSearches(this.allowContainsSearches);
modelConfig.setAllowExternalReferences(this.allowExternalReferences);
modelConfig.setDefaultSearchParamsCanBeOverridden(this.allowOverrideDefaultSearchParams);
modelConfig.setAllowContainsSearches(appProperties.getAllow_contains_searches());
modelConfig.setAllowExternalReferences(appProperties.getAllow_external_references());
modelConfig.setDefaultSearchParamsCanBeOverridden(appProperties.getAllow_override_default_search_params());
modelConfig.setEmailFromAddress(this.emailFrom);
// You can enable these if you want to support Subscriptions from your server
@@ -174,7 +175,7 @@ public class FhirServerConfigCommon {
* <p>
* A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource.
*/
@Bean(destroyMethod = "close")
/*@Bean(destroyMethod = "close")
public BasicDataSource dataSource() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
BasicDataSource retVal = new BasicDataSource();
Driver driver = (Driver) Class.forName(HapiProperties.getDataSourceDriver()).getConstructor().newInstance();
@@ -184,7 +185,7 @@ public class FhirServerConfigCommon {
retVal.setPassword(HapiProperties.getDataSourcePassword());
retVal.setMaxTotal(HapiProperties.getDataSourceMaxPoolSize());
return retVal;
}
}*/
@Lazy
@Bean

View File

@@ -4,6 +4,7 @@ import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.jpa.config.BaseJavaConfigR4;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
@@ -16,6 +17,7 @@ import javax.sql.DataSource;
@Configuration
@Profile("r4")
@ConditionalOnClass(DataSource.class)
public class FhirServerConfigR4 extends BaseJavaConfigR4 {
@Autowired

View File

@@ -1,11 +1,10 @@
package ca.uhn.fhir.jpa.starter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import ca.uhn.fhir.to.FhirTesterMvcConfig;
import ca.uhn.fhir.to.TesterConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
//@formatter:off
/**
@@ -35,15 +34,15 @@ public class FhirTesterConfig {
* you might want to use that instead of using the variable.
*/
@Bean
public TesterConfig testerConfig() {
public TesterConfig testerConfig(AppProperties appProperties) {
TesterConfig retVal = new TesterConfig();
retVal
.addServer()
.withId(HapiProperties.getServerId())
.withFhirVersion(HapiProperties.getFhirVersion())
.withBaseUrl(HapiProperties.getServerAddress())
.withName(HapiProperties.getServerName());
retVal.setRefuseToFetchThirdPartyUrls(HapiProperties.getTesterConfigRefustToFetchThirdPartyUrls());
.withId(appProperties.getTester().getId())
.withFhirVersion(appProperties.getFhir_version())
.withBaseUrl(appProperties.getTester().getAddress())
.withName(appProperties.getTester().getName());
retVal.setRefuseToFetchThirdPartyUrls(appProperties.getTester().getRefuse_to_fetch_third_party_urls());
return retVal;
}