Merge branch 'master' into master
This commit is contained in:
@@ -4,6 +4,8 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.Driver;
|
||||
|
||||
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
|
||||
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.springframework.beans.factory.annotation.Autowire;
|
||||
@@ -12,7 +14,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptorDstu3;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
||||
@@ -26,6 +27,51 @@ public class FhirServerConfigCommon {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirServerConfigCommon.class);
|
||||
|
||||
private Boolean allowContainsSearches = HapiProperties.getAllowContainsSearches();
|
||||
private Boolean allowMultipleDelete = HapiProperties.getAllowMultipleDelete();
|
||||
private Boolean allowExternalReferences = HapiProperties.getAllowExternalReferences();
|
||||
private Boolean expungeEnabled = HapiProperties.getExpungeEnabled();
|
||||
private Boolean allowPlaceholderReferences = HapiProperties.getAllowPlaceholderReferences();
|
||||
private Boolean subscriptionRestHookEnabled = HapiProperties.getSubscriptionRestHookEnabled();
|
||||
private Boolean subscriptionEmailEnabled = HapiProperties.getSubscriptionEmailEnabled();
|
||||
private Boolean allowOverrideDefaultSearchParams = HapiProperties.getAllowOverrideDefaultSearchParams();
|
||||
private String emailFrom = HapiProperties.getEmailFrom();
|
||||
private Boolean emailEnabled = HapiProperties.getEmailEnabled();
|
||||
private String emailHost = HapiProperties.getEmailHost();
|
||||
private Integer emailPort = HapiProperties.getEmailPort();
|
||||
private String emailUsername = HapiProperties.getEmailUsername();
|
||||
private String emailPassword = HapiProperties.getEmailPassword();
|
||||
|
||||
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");
|
||||
|
||||
if (this.emailEnabled) {
|
||||
ourLog.info("Server is configured to enable email with host '" + this.emailHost + "' and port " + this.emailPort.toString());
|
||||
ourLog.info("Server will use '" + this.emailFrom + "' as the from email address");
|
||||
|
||||
if (this.emailUsername != null && this.emailUsername.length() > 0) {
|
||||
ourLog.info("Server is configured to use username '" + this.emailUsername + "' for email");
|
||||
}
|
||||
|
||||
if (this.emailPassword != null && this.emailPassword.length() > 0) {
|
||||
ourLog.info("Server is configured to use a password for email");
|
||||
}
|
||||
}
|
||||
|
||||
if (this.subscriptionRestHookEnabled) {
|
||||
ourLog.info("REST-hook subscriptions enabled");
|
||||
}
|
||||
|
||||
if (this.subscriptionEmailEnabled) {
|
||||
ourLog.info("Email subscriptions enabled");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure FHIR properties around the the JPA server via this bean
|
||||
*/
|
||||
@@ -33,21 +79,12 @@ public class FhirServerConfigCommon {
|
||||
public DaoConfig daoConfig() {
|
||||
DaoConfig retVal = new DaoConfig();
|
||||
|
||||
Boolean allowMultipleDelete = HapiProperties.getAllowMultipleDelete();
|
||||
retVal.setAllowMultipleDelete(allowMultipleDelete);
|
||||
ourLog.info("Server configured to " + (allowMultipleDelete ? "allow" : "deny") + " multiple deletes");
|
||||
|
||||
Boolean allowExternalReferences = HapiProperties.getAllowExternalReferences();
|
||||
retVal.setAllowExternalReferences(allowExternalReferences);
|
||||
ourLog.info("Server configured to " + (allowExternalReferences ? "allow" : "deny") + " external references");
|
||||
|
||||
Boolean expungeEnabled = HapiProperties.getExpungeEnabled();
|
||||
retVal.setExpungeEnabled(expungeEnabled);
|
||||
ourLog.info("Server configured to " + (expungeEnabled ? "enable" : "disable") + " expunges");
|
||||
|
||||
Boolean allowPlaceholderReferences = HapiProperties.getAllowPlaceholderReferences();
|
||||
retVal.setAutoCreatePlaceholderReferenceTargets(allowPlaceholderReferences);
|
||||
ourLog.info("Server configured to " + (allowPlaceholderReferences ? "allow" : "deny") + " placeholder references");
|
||||
retVal.setAllowContainsSearches(this.allowContainsSearches);
|
||||
retVal.setAllowMultipleDelete(this.allowMultipleDelete);
|
||||
retVal.setAllowExternalReferences(this.allowExternalReferences);
|
||||
retVal.setExpungeEnabled(this.expungeEnabled);
|
||||
retVal.setAutoCreatePlaceholderReferenceTargets(this.allowPlaceholderReferences);
|
||||
retVal.setEmailFromAddress(this.emailFrom);
|
||||
|
||||
Integer maxFetchSize = HapiProperties.getMaximumFetchSize();
|
||||
retVal.setFetchSizeDefaultMaximum(maxFetchSize);
|
||||
@@ -72,7 +109,22 @@ public class FhirServerConfigCommon {
|
||||
|
||||
@Bean
|
||||
public ModelConfig modelConfig() {
|
||||
return new ModelConfig();
|
||||
ModelConfig modelConfig = new ModelConfig();
|
||||
modelConfig.setAllowContainsSearches(this.allowContainsSearches);
|
||||
modelConfig.setAllowExternalReferences(this.allowExternalReferences);
|
||||
modelConfig.setDefaultSearchParamsCanBeOverridden(this.allowOverrideDefaultSearchParams);
|
||||
modelConfig.setEmailFromAddress(this.emailFrom);
|
||||
|
||||
// You can enable these if you want to support Subscriptions from your server
|
||||
if (this.subscriptionRestHookEnabled) {
|
||||
modelConfig.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.RESTHOOK);
|
||||
}
|
||||
|
||||
if (this.subscriptionEmailEnabled) {
|
||||
modelConfig.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.EMAIL);
|
||||
}
|
||||
|
||||
return modelConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,4 +167,19 @@ public class FhirServerConfigCommon {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Bean()
|
||||
public IEmailSender emailSender() {
|
||||
if (this.emailEnabled) {
|
||||
JavaMailEmailSender retVal = new JavaMailEmailSender();
|
||||
|
||||
retVal.setSmtpServerHostname(this.emailHost);
|
||||
retVal.setSmtpServerPort(this.emailPort);
|
||||
retVal.setSmtpServerUsername(this.emailUsername);
|
||||
retVal.setSmtpServerPassword(this.emailPassword);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ public class HapiProperties {
|
||||
static final String TESTER_CONFIG_REFUSE_TO_FETCH_THIRD_PARTY_URLS = "tester.config.refuse_to_fetch_third_party_urls";
|
||||
static final String CORS_ENABLED = "cors.enabled";
|
||||
static final String CORS_ALLOWED_ORIGIN = "cors.allowed_origin";
|
||||
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";
|
||||
|
||||
private static Properties properties;
|
||||
|
||||
@@ -292,4 +295,36 @@ public class HapiProperties {
|
||||
public static Boolean getSubscriptionWebsocketEnabled() {
|
||||
return HapiProperties.getBooleanProperty(SUBSCRIPTION_WEBSOCKET_ENABLED, false);
|
||||
}
|
||||
|
||||
public static Boolean getAllowContainsSearches() {
|
||||
return HapiProperties.getBooleanProperty(ALLOW_CONTAINS_SEARCHES, true);
|
||||
}
|
||||
|
||||
public static Boolean getAllowOverrideDefaultSearchParams() {
|
||||
return HapiProperties.getBooleanProperty(ALLOW_OVERRIDE_DEFAULT_SEARCH_PARAMS, true);
|
||||
}
|
||||
|
||||
public static String getEmailFrom() {
|
||||
return HapiProperties.getProperty(EMAIL_FROM, "some@test.com");
|
||||
}
|
||||
|
||||
public static Boolean getEmailEnabled() {
|
||||
return HapiProperties.getBooleanProperty("email.enabled", false);
|
||||
}
|
||||
|
||||
public static String getEmailHost() {
|
||||
return HapiProperties.getProperty("email.host");
|
||||
}
|
||||
|
||||
public static Integer getEmailPort() {
|
||||
return HapiProperties.getIntegerProperty("email.port", 0);
|
||||
}
|
||||
|
||||
public static String getEmailUsername() {
|
||||
return HapiProperties.getProperty("email.username");
|
||||
}
|
||||
|
||||
public static String getEmailPassword() {
|
||||
return HapiProperties.getProperty("email.password");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,10 +62,16 @@ cors.allowed_origin=*
|
||||
##################################################
|
||||
|
||||
# Enable REST Hook Subscription Channel
|
||||
subscription.resthook.enabled=true
|
||||
subscription.resthook.enabled=false
|
||||
|
||||
# Enable Email Subscription Channel
|
||||
subscription.email.enabled=false
|
||||
email.enabled=false
|
||||
email.from=some@test.com
|
||||
email.host=
|
||||
email.port=0
|
||||
email.username=
|
||||
email.password=
|
||||
|
||||
# Enable Websocket Subscription Channel
|
||||
subscription.websocket.enabled=false
|
||||
|
||||
Reference in New Issue
Block a user