From ef49c11e8e419730bd5ed0cbc872b52d990544e7 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 24 Jul 2019 13:42:12 -0400 Subject: [PATCH] Add config for binary sotrage --- .../uhn/fhir/jpa/starter/FhirServerConfigCommon.java | 11 ++++++++++- .../java/ca/uhn/fhir/jpa/starter/HapiProperties.java | 5 +++++ .../ca/uhn/fhir/jpa/starter/JpaRestfulServer.java | 7 +++++++ src/main/resources/hapi.properties | 5 +++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java index e44faac..7523a0b 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java @@ -1,15 +1,18 @@ 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.model.entity.ModelConfig; 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.JavaMailEmailSender; 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.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.thymeleaf.util.Validate; @@ -149,6 +152,12 @@ public class FhirServerConfigCommon { return retVal; } + @Lazy + @Bean + public IBinaryStorageSvc binaryStorageSvc() { + return new DatabaseBlobBinaryStorageSvcImpl(); + } + @Bean() public IEmailSender emailSender() { if (this.emailEnabled) { diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java index a33ad3c..fe0b2bb 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/HapiProperties.java @@ -51,6 +51,7 @@ public class HapiProperties { 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 EMAIL_FROM = "email.from"; + public static final String BINARY_STORAGE_ENABLED = "binary_storage.enabled"; private static Properties properties; @@ -165,6 +166,10 @@ public class HapiProperties { return FhirVersionEnum.DSTU3; } + public static boolean isBinaryStorageEnabled() { + return HapiProperties.getBooleanProperty(BINARY_STORAGE_ENABLED, true); + } + public static ETagSupportEnum getEtagSupport() { String etagSupportString = HapiProperties.getProperty(ETAG_SUPPORT); diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java b/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java index 2e1b996..ec211bb 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java @@ -4,6 +4,8 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; 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.DaoRegistry; import ca.uhn.fhir.jpa.dao.IFhirSystemDao; @@ -237,6 +239,11 @@ public class JpaRestfulServer extends RestfulServer { getInterceptorService().registerInterceptor(cascadingDeleteInterceptor); } + // Binary Storage + if (HapiProperties.isBinaryStorageEnabled()) { + BinaryStorageInterceptor binaryStorageInterceptor = appCtx.getBean(BinaryStorageInterceptor.class); + getInterceptorService().registerInterceptor(binaryStorageInterceptor); + } } } diff --git a/src/main/resources/hapi.properties b/src/main/resources/hapi.properties index 4499207..8b5a4be 100644 --- a/src/main/resources/hapi.properties +++ b/src/main/resources/hapi.properties @@ -62,6 +62,11 @@ hibernate.search.default.indexBase=target/lucenefiles hibernate.search.lucene_version=LUCENE_CURRENT tester.config.refuse_to_fetch_third_party_urls=false +################################################## +# Binary Storage Operations +################################################## +binary_storage.enabled=true + ################################################## # CORS Settings ##################################################