Add config for binary sotrage

This commit is contained in:
James Agnew
2019-07-24 13:42:12 -04:00
parent 76aafe0fa7
commit ef49c11e8e
4 changed files with 27 additions and 1 deletions

View File

@@ -1,15 +1,18 @@
package ca.uhn.fhir.jpa.starter; package ca.uhn.fhir.jpa.starter;
import ca.uhn.fhir.jpa.binstore.DatabaseBlobBinaryStorageSvcImpl;
import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc;
import ca.uhn.fhir.jpa.dao.DaoConfig; import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionDeliveryHandlerFactory; import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionDeliveryHandlerFactory;
import ca.uhn.fhir.jpa.subscription.module.subscriber.email.IEmailSender; import ca.uhn.fhir.jpa.subscription.module.subscriber.email.IEmailSender;
import ca.uhn.fhir.jpa.subscription.module.subscriber.email.JavaMailEmailSender; import ca.uhn.fhir.jpa.subscription.module.subscriber.email.JavaMailEmailSender;
import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.dbcp2.BasicDataSource;
import org.hl7.fhir.instance.model.Subscription; import org.hl7.fhir.dstu2.model.Subscription;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.thymeleaf.util.Validate; import org.thymeleaf.util.Validate;
@@ -149,6 +152,12 @@ public class FhirServerConfigCommon {
return retVal; return retVal;
} }
@Lazy
@Bean
public IBinaryStorageSvc binaryStorageSvc() {
return new DatabaseBlobBinaryStorageSvcImpl();
}
@Bean() @Bean()
public IEmailSender emailSender() { public IEmailSender emailSender() {
if (this.emailEnabled) { if (this.emailEnabled) {

View File

@@ -51,6 +51,7 @@ public class HapiProperties {
static final String ALLOW_CONTAINS_SEARCHES = "allow_contains_searches"; static final String ALLOW_CONTAINS_SEARCHES = "allow_contains_searches";
static final String ALLOW_OVERRIDE_DEFAULT_SEARCH_PARAMS = "allow_override_default_search_params"; static final String ALLOW_OVERRIDE_DEFAULT_SEARCH_PARAMS = "allow_override_default_search_params";
static final String EMAIL_FROM = "email.from"; static final String EMAIL_FROM = "email.from";
public static final String BINARY_STORAGE_ENABLED = "binary_storage.enabled";
private static Properties properties; private static Properties properties;
@@ -165,6 +166,10 @@ public class HapiProperties {
return FhirVersionEnum.DSTU3; return FhirVersionEnum.DSTU3;
} }
public static boolean isBinaryStorageEnabled() {
return HapiProperties.getBooleanProperty(BINARY_STORAGE_ENABLED, true);
}
public static ETagSupportEnum getEtagSupport() { public static ETagSupportEnum getEtagSupport() {
String etagSupportString = HapiProperties.getProperty(ETAG_SUPPORT); String etagSupportString = HapiProperties.getProperty(ETAG_SUPPORT);

View File

@@ -4,6 +4,8 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.interceptor.api.IInterceptorService;
import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor;
import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc;
import ca.uhn.fhir.jpa.dao.DaoConfig; import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.DaoRegistry; import ca.uhn.fhir.jpa.dao.DaoRegistry;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
@@ -237,6 +239,11 @@ public class JpaRestfulServer extends RestfulServer {
getInterceptorService().registerInterceptor(cascadingDeleteInterceptor); getInterceptorService().registerInterceptor(cascadingDeleteInterceptor);
} }
// Binary Storage
if (HapiProperties.isBinaryStorageEnabled()) {
BinaryStorageInterceptor binaryStorageInterceptor = appCtx.getBean(BinaryStorageInterceptor.class);
getInterceptorService().registerInterceptor(binaryStorageInterceptor);
}
} }
} }

View File

@@ -62,6 +62,11 @@ hibernate.search.default.indexBase=target/lucenefiles
hibernate.search.lucene_version=LUCENE_CURRENT hibernate.search.lucene_version=LUCENE_CURRENT
tester.config.refuse_to_fetch_third_party_urls=false tester.config.refuse_to_fetch_third_party_urls=false
##################################################
# Binary Storage Operations
##################################################
binary_storage.enabled=true
################################################## ##################################################
# CORS Settings # CORS Settings
################################################## ##################################################