added support for allowedBundleTypes in properties
This commit is contained in:
@@ -45,6 +45,7 @@ public class HapiProperties {
|
|||||||
static final String SUBSCRIPTION_EMAIL_ENABLED = "subscription.email.enabled";
|
static final String SUBSCRIPTION_EMAIL_ENABLED = "subscription.email.enabled";
|
||||||
static final String SUBSCRIPTION_RESTHOOK_ENABLED = "subscription.resthook.enabled";
|
static final String SUBSCRIPTION_RESTHOOK_ENABLED = "subscription.resthook.enabled";
|
||||||
static final String SUBSCRIPTION_WEBSOCKET_ENABLED = "subscription.websocket.enabled";
|
static final String SUBSCRIPTION_WEBSOCKET_ENABLED = "subscription.websocket.enabled";
|
||||||
|
static final String ALLOWED_BUNDLE_TYPES = "allowedBundleTypes";
|
||||||
static final String TEST_PORT = "test.port";
|
static final String TEST_PORT = "test.port";
|
||||||
static final String TESTER_CONFIG_REFUSE_TO_FETCH_THIRD_PARTY_URLS = "tester.config.refuse_to_fetch_third_party_urls";
|
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_ENABLED = "cors.enabled";
|
||||||
@@ -286,6 +287,10 @@ public class HapiProperties {
|
|||||||
return HapiProperties.getProperty(CORS_ALLOWED_ORIGIN, "*");
|
return HapiProperties.getProperty(CORS_ALLOWED_ORIGIN, "*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getAllowedBundleTypes() {
|
||||||
|
return HapiProperties.getProperty(ALLOWED_BUNDLE_TYPES, "");
|
||||||
|
}
|
||||||
|
|
||||||
public static Set<String> getSupportedResourceTypes() {
|
public static Set<String> getSupportedResourceTypes() {
|
||||||
String[] types = defaultString(getProperty("supported_resource_types")).split(",");
|
String[] types = defaultString(getProperty("supported_resource_types")).split(",");
|
||||||
return Arrays.stream(types)
|
return Arrays.stream(types)
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ import ca.uhn.fhir.rest.server.RestfulServer;
|
|||||||
import ca.uhn.fhir.rest.server.interceptor.*;
|
import ca.uhn.fhir.rest.server.interceptor.*;
|
||||||
import ca.uhn.fhir.validation.IValidatorModule;
|
import ca.uhn.fhir.validation.IValidatorModule;
|
||||||
import ca.uhn.fhir.validation.ResultSeverityEnum;
|
import ca.uhn.fhir.validation.ResultSeverityEnum;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
import org.hl7.fhir.dstu3.model.Bundle;
|
import org.hl7.fhir.dstu3.model.Bundle;
|
||||||
|
import org.hl7.fhir.r4.model.Bundle.BundleType;
|
||||||
import org.hl7.fhir.dstu3.model.Meta;
|
import org.hl7.fhir.dstu3.model.Meta;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
@@ -51,7 +54,8 @@ public class JpaRestfulServer extends RestfulServer {
|
|||||||
* Create a FhirContext object that uses the version of FHIR
|
* Create a FhirContext object that uses the version of FHIR
|
||||||
* specified in the properties file.
|
* specified in the properties file.
|
||||||
*/
|
*/
|
||||||
ApplicationContext appCtx = (ApplicationContext) getServletContext().getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
|
ApplicationContext appCtx = (ApplicationContext) getServletContext()
|
||||||
|
.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
|
||||||
// Customize supported resource types
|
// Customize supported resource types
|
||||||
Set<String> supportedResourceTypes = HapiProperties.getSupportedResourceTypes();
|
Set<String> supportedResourceTypes = HapiProperties.getSupportedResourceTypes();
|
||||||
if (!supportedResourceTypes.isEmpty()) {
|
if (!supportedResourceTypes.isEmpty()) {
|
||||||
@@ -95,23 +99,31 @@ public class JpaRestfulServer extends RestfulServer {
|
|||||||
* provide further customization of your server's CapabilityStatement
|
* provide further customization of your server's CapabilityStatement
|
||||||
*/
|
*/
|
||||||
if (fhirVersion == FhirVersionEnum.DSTU2) {
|
if (fhirVersion == FhirVersionEnum.DSTU2) {
|
||||||
IFhirSystemDao<ca.uhn.fhir.model.dstu2.resource.Bundle, MetaDt> systemDao = appCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class);
|
IFhirSystemDao<ca.uhn.fhir.model.dstu2.resource.Bundle, MetaDt> systemDao = appCtx
|
||||||
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, appCtx.getBean(DaoConfig.class));
|
.getBean("mySystemDaoDstu2", IFhirSystemDao.class);
|
||||||
|
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao,
|
||||||
|
appCtx.getBean(DaoConfig.class));
|
||||||
confProvider.setImplementationDescription("HAPI FHIR DSTU2 Server");
|
confProvider.setImplementationDescription("HAPI FHIR DSTU2 Server");
|
||||||
setServerConformanceProvider(confProvider);
|
setServerConformanceProvider(confProvider);
|
||||||
} else if (fhirVersion == FhirVersionEnum.DSTU3) {
|
} else if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||||
IFhirSystemDao<Bundle, Meta> systemDao = appCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class);
|
IFhirSystemDao<Bundle, Meta> systemDao = appCtx
|
||||||
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, appCtx.getBean(DaoConfig.class));
|
.getBean("mySystemDaoDstu3", IFhirSystemDao.class);
|
||||||
|
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao,
|
||||||
|
appCtx.getBean(DaoConfig.class));
|
||||||
confProvider.setImplementationDescription("HAPI FHIR DSTU3 Server");
|
confProvider.setImplementationDescription("HAPI FHIR DSTU3 Server");
|
||||||
setServerConformanceProvider(confProvider);
|
setServerConformanceProvider(confProvider);
|
||||||
} else if (fhirVersion == FhirVersionEnum.R4) {
|
} else if (fhirVersion == FhirVersionEnum.R4) {
|
||||||
IFhirSystemDao<org.hl7.fhir.r4.model.Bundle, org.hl7.fhir.r4.model.Meta> systemDao = appCtx.getBean("mySystemDaoR4", IFhirSystemDao.class);
|
IFhirSystemDao<org.hl7.fhir.r4.model.Bundle, org.hl7.fhir.r4.model.Meta> systemDao = appCtx
|
||||||
JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(this, systemDao, appCtx.getBean(DaoConfig.class));
|
.getBean("mySystemDaoR4", IFhirSystemDao.class);
|
||||||
|
JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(this, systemDao,
|
||||||
|
appCtx.getBean(DaoConfig.class));
|
||||||
confProvider.setImplementationDescription("HAPI FHIR R4 Server");
|
confProvider.setImplementationDescription("HAPI FHIR R4 Server");
|
||||||
setServerConformanceProvider(confProvider);
|
setServerConformanceProvider(confProvider);
|
||||||
} else if (fhirVersion == FhirVersionEnum.R5) {
|
} else if (fhirVersion == FhirVersionEnum.R5) {
|
||||||
IFhirSystemDao<org.hl7.fhir.r5.model.Bundle, org.hl7.fhir.r5.model.Meta> systemDao = appCtx.getBean("mySystemDaoR5", IFhirSystemDao.class);
|
IFhirSystemDao<org.hl7.fhir.r5.model.Bundle, org.hl7.fhir.r5.model.Meta> systemDao = appCtx
|
||||||
JpaConformanceProviderR5 confProvider = new JpaConformanceProviderR5(this, systemDao, appCtx.getBean(DaoConfig.class));
|
.getBean("mySystemDaoR5", IFhirSystemDao.class);
|
||||||
|
JpaConformanceProviderR5 confProvider = new JpaConformanceProviderR5(this, systemDao,
|
||||||
|
appCtx.getBean(DaoConfig.class));
|
||||||
confProvider.setImplementationDescription("HAPI FHIR R5 Server");
|
confProvider.setImplementationDescription("HAPI FHIR R5 Server");
|
||||||
setServerConformanceProvider(confProvider);
|
setServerConformanceProvider(confProvider);
|
||||||
} else {
|
} else {
|
||||||
@@ -191,7 +203,8 @@ public class JpaRestfulServer extends RestfulServer {
|
|||||||
// If you want to enable the $trigger-subscription operation to allow
|
// If you want to enable the $trigger-subscription operation to allow
|
||||||
// manual triggering of a subscription delivery, enable this provider
|
// manual triggering of a subscription delivery, enable this provider
|
||||||
if (false) { // <-- DISABLED RIGHT NOW
|
if (false) { // <-- DISABLED RIGHT NOW
|
||||||
SubscriptionTriggeringProvider retriggeringProvider = appCtx.getBean(SubscriptionTriggeringProvider.class);
|
SubscriptionTriggeringProvider retriggeringProvider = appCtx
|
||||||
|
.getBean(SubscriptionTriggeringProvider.class);
|
||||||
registerProvider(retriggeringProvider);
|
registerProvider(retriggeringProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +245,8 @@ public class JpaRestfulServer extends RestfulServer {
|
|||||||
HapiProperties.getSubscriptionRestHookEnabled()) {
|
HapiProperties.getSubscriptionRestHookEnabled()) {
|
||||||
// Loads subscription interceptors (SubscriptionActivatingInterceptor, SubscriptionMatcherInterceptor)
|
// Loads subscription interceptors (SubscriptionActivatingInterceptor, SubscriptionMatcherInterceptor)
|
||||||
// with activation of scheduled subscription
|
// with activation of scheduled subscription
|
||||||
SubscriptionInterceptorLoader subscriptionInterceptorLoader = appCtx.getBean(SubscriptionInterceptorLoader.class);
|
SubscriptionInterceptorLoader subscriptionInterceptorLoader = appCtx
|
||||||
|
.getBean(SubscriptionInterceptorLoader.class);
|
||||||
subscriptionInterceptorLoader.registerInterceptors();
|
subscriptionInterceptorLoader.registerInterceptors();
|
||||||
|
|
||||||
// Subscription debug logging
|
// Subscription debug logging
|
||||||
@@ -244,13 +258,15 @@ public class JpaRestfulServer extends RestfulServer {
|
|||||||
DaoRegistry daoRegistry = appCtx.getBean(DaoRegistry.class);
|
DaoRegistry daoRegistry = appCtx.getBean(DaoRegistry.class);
|
||||||
IInterceptorBroadcaster interceptorBroadcaster = appCtx.getBean(IInterceptorBroadcaster.class);
|
IInterceptorBroadcaster interceptorBroadcaster = appCtx.getBean(IInterceptorBroadcaster.class);
|
||||||
if (HapiProperties.getAllowCascadingDeletes()) {
|
if (HapiProperties.getAllowCascadingDeletes()) {
|
||||||
CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(daoRegistry, interceptorBroadcaster);
|
CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(
|
||||||
|
daoRegistry, interceptorBroadcaster);
|
||||||
getInterceptorService().registerInterceptor(cascadingDeleteInterceptor);
|
getInterceptorService().registerInterceptor(cascadingDeleteInterceptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binary Storage
|
// Binary Storage
|
||||||
if (HapiProperties.isBinaryStorageEnabled()) {
|
if (HapiProperties.isBinaryStorageEnabled()) {
|
||||||
BinaryStorageInterceptor binaryStorageInterceptor = appCtx.getBean(BinaryStorageInterceptor.class);
|
BinaryStorageInterceptor binaryStorageInterceptor = appCtx
|
||||||
|
.getBean(BinaryStorageInterceptor.class);
|
||||||
getInterceptorService().registerInterceptor(binaryStorageInterceptor);
|
getInterceptorService().registerInterceptor(binaryStorageInterceptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,6 +308,16 @@ public class JpaRestfulServer extends RestfulServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!HapiProperties.getAllowedBundleTypes().isEmpty()) {
|
||||||
|
String allowedBundleTypesString = HapiProperties.getAllowedBundleTypes();
|
||||||
|
Set<String> allowedBundleTypes = new HashSet<>();
|
||||||
|
Arrays.stream(allowedBundleTypesString.split(",")).forEach(o -> {
|
||||||
|
BundleType type = BundleType.valueOf(o);
|
||||||
|
allowedBundleTypes.add(type.toCode());
|
||||||
|
});
|
||||||
|
DaoConfig config = appCtx.getBean(DaoConfig.class);
|
||||||
|
config.setBundleTypesAllowedForStorage(
|
||||||
|
Collections.unmodifiableSet(new TreeSet<>(allowedBundleTypes)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,11 @@ cors.allowCredentials=true
|
|||||||
# cors.allowed_origin=http://localhost:8080,https://localhost:8080,https://fhirtest.uhn.ca
|
# cors.allowed_origin=http://localhost:8080,https://localhost:8080,https://fhirtest.uhn.ca
|
||||||
cors.allow_origin=*
|
cors.allow_origin=*
|
||||||
|
|
||||||
|
##################################################
|
||||||
|
# Allowed Bundle Types for persistence (defaults are: COLLECTION,DOCUMENT,MESSAGE)
|
||||||
|
##################################################
|
||||||
|
#allowedBundleTypes=COLLECTION,DOCUMENT,MESSAGE,TRANSACTION,TRANSACTIONRESPONSE,BATCH,BATCHRESPONSE,HISTORY,SEARCHSET
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
# Subscriptions
|
# Subscriptions
|
||||||
##################################################
|
##################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user