Merge pull request #51 from hapifhir/allowedBundleTypes

Allowed bundle types
This commit is contained in:
Patrick Werner
2019-09-12 15:07:09 -04:00
committed by GitHub
5 changed files with 426 additions and 253 deletions

5
.editorconfig Normal file
View File

@@ -0,0 +1,5 @@
[*.java]
charset = utf-8
indent_style = space
indent_size = 2

138
.gitignore vendored
View File

@@ -1,7 +1,6 @@
target/
.idea/
*.iml
*.orig *.orig
target/
*.iml
# Compiled class file # Compiled class file
*.class *.class
@@ -26,3 +25,136 @@ target/
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*
### Windows template
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
.idea/
# CMake
cmake-build-*/
# File-based project format
*.iws
# IntelliJ
out/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Eclipse template
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

View File

@@ -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 = "allowed_bundle_types";
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)

View File

@@ -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)));
}
} }
} }

View File

@@ -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)
##################################################
#allowed_bundle_types=COLLECTION,DOCUMENT,MESSAGE,TRANSACTION,TRANSACTIONRESPONSE,BATCH,BATCHRESPONSE,HISTORY,SEARCHSET
################################################## ##################################################
# Subscriptions # Subscriptions
################################################## ##################################################