From f6601cc347730e57ff8e91c7a04601b5d3fc40af Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 13 Jul 2016 09:40:50 -0400 Subject: [PATCH] Add example for terminology uiploading --- .../uhn/fhir/rest/server/RestfulServer.java | 14 ++++------- .../ca/uhn/fhir/jpa/demo/JpaServerDemo.java | 23 ++++++++++++++----- src/changes/changes.xml | 23 +++++++++++++++++++ 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java index ea41b928831..e598a7d00b8 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java @@ -301,7 +301,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer providerList = new ArrayList(1); providerList.add(provider); @@ -1034,9 +1031,8 @@ public class RestfulServer extends HttpServlet implements IRestfulServer providers) throws Exception { + public void registerProviders(Collection providers) { myProviderRegistrationMutex.lock(); try { if (!myStarted) { @@ -1059,7 +1055,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer providers, boolean inInit) throws Exception { + protected void registerProviders(Collection providers, boolean inInit) { List newResourceProviders = new ArrayList(); List newPlainProviders = new ArrayList(); ProvidedResourceScanner providedResourceScanner = new ProvidedResourceScanner(getFhirContext()); @@ -1074,7 +1070,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer, MetaDt> systemDao = myAppCtx.getBean("mySystemDaoDstu1", - IFhirSystemDao.class); + IFhirSystemDao, MetaDt> systemDao = myAppCtx.getBean("mySystemDaoDstu1", IFhirSystemDao.class); JpaConformanceProviderDstu1 confProvider = new JpaConformanceProviderDstu1(this, systemDao); confProvider.setImplementationDescription("Example Server"); setServerConformanceProvider(confProvider); @@ -105,10 +105,9 @@ public class JpaServerDemo extends RestfulServer { confProvider.setImplementationDescription("Example Server"); setServerConformanceProvider(confProvider); } else if (fhirVersion == FhirVersionEnum.DSTU3) { - IFhirSystemDao systemDao = myAppCtx - .getBean("mySystemDaoDstu3", IFhirSystemDao.class); + IFhirSystemDao systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class); JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, - myAppCtx.getBean(DaoConfig.class)); + myAppCtx.getBean(DaoConfig.class)); confProvider.setImplementationDescription("Example Server"); setServerConformanceProvider(confProvider); } else { @@ -135,7 +134,9 @@ public class JpaServerDemo extends RestfulServer { /* * -- New in HAPI FHIR 1.5 -- * This configures the server to page search results to and from - * the database + * the database, instead of only paging them to memory. This may mean + * a performance hit when performing searches that return lots of results, + * but makes the server much more scalable. */ setPagingProvider(myAppCtx.getBean(DatabaseBackedPagingProvider.class)); @@ -155,6 +156,16 @@ public class JpaServerDemo extends RestfulServer { */ //setServerAddressStrategy(new HardcodedServerAddressStrategy("http://mydomain.com/fhir/baseDstu2")); + /* + * If you are using DSTU3+, you may want to add a terminology uploader, which allows + * uploading of external terminologies such as Snomed CT. Note that this uploader + * does not have any security attached (any anonymous user may use it by default) + * so it is a potential security vulnerability. Consider using an AuthorizationInterceptor + * with this feature. + */ + if (fhirVersion == FhirVersionEnum.DSTU3) { + registerProvider(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class)); + } } } diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 44d83509538..befe646cc1b 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -7,6 +7,29 @@ + + JSON parsing in HAPI FHIR has been switched from using JSR353 (javax.json) to + using Google Gson. For this reason we are bumping the major release number to + 2.0. Theoretically this should not affect projects in any major way, but Gson + does have subtle differences. Two differences which popped up a fair bit in + our own testing: + +
    + A space is placed after the : in keys, e.g. what was previously + encoded as "resourceType":"Patient" is now encoded + as "resourceType": "Patient" (this broke a number of + our unit tests with hardcoded resource definitions) +
+
    + Trailing content after a valid json resource is rejected by + Gson (it was ignored by the Glassfish parser we were previously + using even though it was invalid) +
+ + + ]]> +
Fix issue in DSTU1 Bundle parsing where unexpected elements in the bundle resulted in a failure to parse.