Added partition interceptor
This commit is contained in:
@@ -6,7 +6,9 @@ import ca.uhn.fhir.empi.rules.config.EmpiSettings;
|
|||||||
import ca.uhn.fhir.jpa.starter.AppProperties;
|
import ca.uhn.fhir.jpa.starter.AppProperties;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Conditional;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.io.DefaultResourceLoader;
|
import org.springframework.core.io.DefaultResourceLoader;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
@@ -18,10 +20,11 @@ import java.io.IOException;
|
|||||||
* in 5.1.0 picks this up even if EMPI is disabled currently.
|
* in 5.1.0 picks this up even if EMPI is disabled currently.
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@Conditional(EmpiConfigCondition.class)
|
||||||
public class EmpiConfig {
|
public class EmpiConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
IEmpiSettings empiSettings(EmpiRuleValidator theEmpiRuleValidator, AppProperties appProperties) throws IOException {
|
IEmpiSettings empiSettings(@Autowired EmpiRuleValidator theEmpiRuleValidator, AppProperties appProperties) throws IOException {
|
||||||
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
|
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||||
Resource resource = resourceLoader.getResource("empi-rules.json");
|
Resource resource = resourceLoader.getResource("empi-rules.json");
|
||||||
String json = IOUtils.toString(resource.getInputStream(), Charsets.UTF_8);
|
String json = IOUtils.toString(resource.getInputStream(), Charsets.UTF_8);
|
||||||
|
|||||||
13
src/main/java/ca/uhn/fhir/jpa/empi/EmpiConfigCondition.java
Normal file
13
src/main/java/ca/uhn/fhir/jpa/empi/EmpiConfigCondition.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package ca.uhn.fhir.jpa.empi;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Condition;
|
||||||
|
import org.springframework.context.annotation.ConditionContext;
|
||||||
|
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||||
|
|
||||||
|
public class EmpiConfigCondition implements Condition {
|
||||||
|
@Override
|
||||||
|
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
|
||||||
|
String property = conditionContext.getEnvironment().getProperty("hapi.fhir.empi_enabled");
|
||||||
|
return Boolean.parseBoolean(property);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,9 +36,9 @@ public class AppProperties {
|
|||||||
private Boolean expunge_enabled = true;
|
private Boolean expunge_enabled = true;
|
||||||
private Boolean fhirpath_interceptor_enabled = false;
|
private Boolean fhirpath_interceptor_enabled = false;
|
||||||
private Boolean filter_search_enabled = true;
|
private Boolean filter_search_enabled = true;
|
||||||
private Boolean graphql_enabled = true;
|
private Boolean graphql_enabled = false;
|
||||||
private Boolean binary_storage_enabled = true;
|
private Boolean binary_storage_enabled = false;
|
||||||
private Boolean bulk_export_enabled = true;
|
private Boolean bulk_export_enabled = false;
|
||||||
private Boolean default_pretty_print = true;
|
private Boolean default_pretty_print = true;
|
||||||
private Integer default_page_size = 20;
|
private Integer default_page_size = 20;
|
||||||
private Integer max_binary_size = null;
|
private Integer max_binary_size = null;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package ca.uhn.fhir.jpa.starter;
|
package ca.uhn.fhir.jpa.starter;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.jpa.empi.EmpiConfig;
|
||||||
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
|
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
|
||||||
import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig;
|
import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig;
|
||||||
import ca.uhn.fhir.jpa.subscription.match.config.WebsocketDispatcherConfig;
|
import ca.uhn.fhir.jpa.subscription.match.config.WebsocketDispatcherConfig;
|
||||||
@@ -21,7 +22,7 @@ import org.springframework.web.servlet.DispatcherServlet;
|
|||||||
@ServletComponentScan(basePackageClasses = {
|
@ServletComponentScan(basePackageClasses = {
|
||||||
JpaRestfulServer.class}, basePackages = "ca.uhn.fhir.jpa.starter")
|
JpaRestfulServer.class}, basePackages = "ca.uhn.fhir.jpa.starter")
|
||||||
@SpringBootApplication(exclude = ElasticsearchRestClientAutoConfiguration.class)
|
@SpringBootApplication(exclude = ElasticsearchRestClientAutoConfiguration.class)
|
||||||
@Import({SubscriptionSubmitterConfig.class, SubscriptionProcessorConfig.class, SubscriptionChannelConfig.class,WebsocketDispatcherConfig.class })
|
@Import({SubscriptionSubmitterConfig.class, SubscriptionProcessorConfig.class, SubscriptionChannelConfig.class, WebsocketDispatcherConfig.class, EmpiConfig.class})
|
||||||
public class Application extends SpringBootServletInitializer {
|
public class Application extends SpringBootServletInitializer {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -102,5 +102,6 @@ public class MultitenantServerR4IT {
|
|||||||
String ourServerBase = "http://localhost:" + port + "/hapi-fhir-jpaserver/fhir/";
|
String ourServerBase = "http://localhost:" + port + "/hapi-fhir-jpaserver/fhir/";
|
||||||
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
|
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
|
||||||
ourClient.registerInterceptor(new LoggingInterceptor(true));
|
ourClient.registerInterceptor(new LoggingInterceptor(true));
|
||||||
|
ourClient.registerInterceptor(ourClientTenantInterceptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user