diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IContextValidationSupport.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IContextValidationSupport.java index bcebc8bbbda..19a79b37b82 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IContextValidationSupport.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IContextValidationSupport.java @@ -9,9 +9,9 @@ package ca.uhn.fhir.context.support; * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/JpaServerDemo.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/JpaServerDemo.java index 7511f23fd20..b4972e3e99d 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/JpaServerDemo.java +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/JpaServerDemo.java @@ -8,9 +8,10 @@ import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2; import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3; +import ca.uhn.fhir.jpa.provider.dstu3.TerminologyUploaderProviderDstu3; import ca.uhn.fhir.jpa.provider.r4.JpaConformanceProviderR4; import ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4; -import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; +import ca.uhn.fhir.jpa.provider.r4.TerminologyUploaderProviderR4; import ca.uhn.fhir.model.dstu2.composite.MetaDt; import ca.uhn.fhir.model.dstu2.resource.Bundle; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; @@ -78,10 +79,10 @@ public class JpaServerDemo extends RestfulServer { systemProvider.add(myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class)); } else if (fhirVersion == FhirVersionEnum.DSTU3) { systemProvider.add(myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class)); - systemProvider.add(myAppCtx.getBean(TerminologyUploaderProvider.class)); + systemProvider.add(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class)); } else if (fhirVersion == FhirVersionEnum.R4) { systemProvider.add(myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class)); - systemProvider.add(myAppCtx.getBean(TerminologyUploaderProvider.class)); + systemProvider.add(myAppCtx.getBean(TerminologyUploaderProviderR4.class)); } else { throw new IllegalStateException(); } diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java index 184ae74ac78..a70c9399b8b 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java @@ -8,9 +8,10 @@ import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2; import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3; +import ca.uhn.fhir.jpa.provider.dstu3.TerminologyUploaderProviderDstu3; import ca.uhn.fhir.jpa.provider.r4.JpaConformanceProviderR4; import ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4; -import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; +import ca.uhn.fhir.jpa.provider.r4.TerminologyUploaderProviderR4; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; import ca.uhn.fhir.rest.api.EncodingEnum; @@ -50,6 +51,13 @@ public class TestRestfulServer extends RestfulServer { private AnnotationConfigWebApplicationContext myAppCtx; + @Override + public void destroy() { + super.destroy(); + ourLog.info("Server is shutting down"); + myAppCtx.destroy(); + } + @SuppressWarnings("unchecked") @Override protected void initialize() throws ServletException { @@ -74,79 +82,79 @@ public class TestRestfulServer extends RestfulServer { ETagSupportEnum etagSupport; String baseUrlProperty; List plainProviders = new ArrayList(); - + switch (fhirVersionParam.trim().toUpperCase()) { - case "TDL2": - case "DSTU2": { - myAppCtx = new AnnotationConfigWebApplicationContext(); - myAppCtx.setServletConfig(getServletConfig()); - myAppCtx.setParent(parentAppCtx); - if ("TDL2".equals(fhirVersionParam.trim().toUpperCase())) { - myAppCtx.register(TdlDstu2Config.class); - baseUrlProperty = FHIR_BASEURL_TDL2; - } else { - myAppCtx.register(TestDstu2Config.class, WebsocketDispatcherConfig.class); - baseUrlProperty = FHIR_BASEURL_DSTU2; + case "TDL2": + case "DSTU2": { + myAppCtx = new AnnotationConfigWebApplicationContext(); + myAppCtx.setServletConfig(getServletConfig()); + myAppCtx.setParent(parentAppCtx); + if ("TDL2".equals(fhirVersionParam.trim().toUpperCase())) { + myAppCtx.register(TdlDstu2Config.class); + baseUrlProperty = FHIR_BASEURL_TDL2; + } else { + myAppCtx.register(TestDstu2Config.class, WebsocketDispatcherConfig.class); + baseUrlProperty = FHIR_BASEURL_DSTU2; + } + myAppCtx.refresh(); + setFhirContext(FhirContext.forDstu2()); + beans = myAppCtx.getBean("myResourceProvidersDstu2", List.class); + plainProviders.add(myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class)); + systemDao = myAppCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class); + etagSupport = ETagSupportEnum.ENABLED; + JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, myAppCtx.getBean(DaoConfig.class)); + confProvider.setImplementationDescription(implDesc); + setServerConformanceProvider(confProvider); + break; } - myAppCtx.refresh(); - setFhirContext(FhirContext.forDstu2()); - beans = myAppCtx.getBean("myResourceProvidersDstu2", List.class); - plainProviders.add(myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class)); - systemDao = myAppCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class); - etagSupport = ETagSupportEnum.ENABLED; - JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, myAppCtx.getBean(DaoConfig.class)); - confProvider.setImplementationDescription(implDesc); - setServerConformanceProvider(confProvider); - break; - } - case "TDL3": - case "DSTU3": { - myAppCtx = new AnnotationConfigWebApplicationContext(); - myAppCtx.setServletConfig(getServletConfig()); - myAppCtx.setParent(parentAppCtx); - if ("TDL3".equals(fhirVersionParam.trim().toUpperCase())) { - myAppCtx.register(TdlDstu3Config.class); - baseUrlProperty = FHIR_BASEURL_TDL3; - } else { - myAppCtx.register(TestDstu3Config.class, WebsocketDispatcherConfig.class); - baseUrlProperty = FHIR_BASEURL_DSTU3; + case "TDL3": + case "DSTU3": { + myAppCtx = new AnnotationConfigWebApplicationContext(); + myAppCtx.setServletConfig(getServletConfig()); + myAppCtx.setParent(parentAppCtx); + if ("TDL3".equals(fhirVersionParam.trim().toUpperCase())) { + myAppCtx.register(TdlDstu3Config.class); + baseUrlProperty = FHIR_BASEURL_TDL3; + } else { + myAppCtx.register(TestDstu3Config.class, WebsocketDispatcherConfig.class); + baseUrlProperty = FHIR_BASEURL_DSTU3; + } + myAppCtx.refresh(); + setFhirContext(FhirContext.forDstu3()); + beans = myAppCtx.getBean("myResourceProvidersDstu3", List.class); + plainProviders.add(myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class)); + systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class); + etagSupport = ETagSupportEnum.ENABLED; + JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class)); + confProvider.setImplementationDescription(implDesc); + setServerConformanceProvider(confProvider); + plainProviders.add(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class)); + break; } - myAppCtx.refresh(); - setFhirContext(FhirContext.forDstu3()); - beans = myAppCtx.getBean("myResourceProvidersDstu3", List.class); - plainProviders.add(myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class)); - systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class); - etagSupport = ETagSupportEnum.ENABLED; - JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class)); - confProvider.setImplementationDescription(implDesc); - setServerConformanceProvider(confProvider); - plainProviders.add(myAppCtx.getBean(TerminologyUploaderProvider.class)); - break; + case "R4": { + myAppCtx = new AnnotationConfigWebApplicationContext(); + myAppCtx.setServletConfig(getServletConfig()); + myAppCtx.setParent(parentAppCtx); + myAppCtx.register(TestR4Config.class, WebsocketDispatcherConfig.class); + baseUrlProperty = FHIR_BASEURL_R4; + myAppCtx.refresh(); + setFhirContext(FhirContext.forR4()); + beans = myAppCtx.getBean("myResourceProvidersR4", List.class); + plainProviders.add(myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class)); + systemDao = myAppCtx.getBean("mySystemDaoR4", IFhirSystemDao.class); + etagSupport = ETagSupportEnum.ENABLED; + JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(this, systemDao, myAppCtx.getBean(DaoConfig.class)); + confProvider.setImplementationDescription(implDesc); + setServerConformanceProvider(confProvider); + plainProviders.add(myAppCtx.getBean(TerminologyUploaderProviderR4.class)); + break; + } + default: + throw new ServletException("Unknown FHIR version specified in init-param[FhirVersion]: " + fhirVersionParam); } - case "R4": { - myAppCtx = new AnnotationConfigWebApplicationContext(); - myAppCtx.setServletConfig(getServletConfig()); - myAppCtx.setParent(parentAppCtx); - myAppCtx.register(TestR4Config.class, WebsocketDispatcherConfig.class); - baseUrlProperty = FHIR_BASEURL_R4; - myAppCtx.refresh(); - setFhirContext(FhirContext.forR4()); - beans = myAppCtx.getBean("myResourceProvidersR4", List.class); - plainProviders.add(myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class)); - systemDao = myAppCtx.getBean("mySystemDaoR4", IFhirSystemDao.class); - etagSupport = ETagSupportEnum.ENABLED; - JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(this, systemDao, myAppCtx.getBean(DaoConfig.class)); - confProvider.setImplementationDescription(implDesc); - setServerConformanceProvider(confProvider); - plainProviders.add(myAppCtx.getBean(TerminologyUploaderProvider.class)); - break; - } - default: - throw new ServletException("Unknown FHIR version specified in init-param[FhirVersion]: " + fhirVersionParam); - } - + /* - * On the DSTU2 endpoint, we want to enable ETag support + * On the DSTU2 endpoint, we want to enable ETag support */ setETagSupport(etagSupport); @@ -155,9 +163,9 @@ public class TestRestfulServer extends RestfulServer { */ FhirContext ctx = getFhirContext(); ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator()); - + /* - * The resource and system providers (which actually implement the various FHIR + * The resource and system providers (which actually implement the various FHIR * operations in this server) are all retrieved from the spring context above * and are provided to the server here. */ @@ -187,17 +195,17 @@ public class TestRestfulServer extends RestfulServer { responseHighlighterInterceptor.setShowRequestHeaders(false); responseHighlighterInterceptor.setShowResponseHeaders(true); registerInterceptor(responseHighlighterInterceptor); - + registerInterceptor(new BanUnsupportedHttpMethodsInterceptor()); - + /* * Default to JSON with pretty printing */ setDefaultPrettyPrint(true); setDefaultResponseEncoding(EncodingEnum.JSON); - + /* - * The server's base URL (e.g. http://fhirtest.uhn.ca/baseDstu2) is + * The server's base URL (e.g. http://fhirtest.uhn.ca/baseDstu2) is * pulled from a system property, which is helpful if you want to try * hosting your own copy of this server. */ @@ -210,12 +218,12 @@ public class TestRestfulServer extends RestfulServer { } } setServerAddressStrategy(new MyHardcodedServerAddressStrategy(baseUrl)); - + /* - * Spool results to the database + * Spool results to the database */ setPagingProvider(myAppCtx.getBean(DatabaseBackedPagingProvider.class)); - + /* * Load interceptors for the server from Spring */ @@ -226,13 +234,6 @@ public class TestRestfulServer extends RestfulServer { } - @Override - public void destroy() { - super.destroy(); - ourLog.info("Server is shutting down"); - myAppCtx.destroy(); - } - /** * The public server is deployed to http://fhirtest.uhn.ca and the JEE webserver * where this FHIR server is deployed is actually fronted by an Apache HTTPd instance, @@ -248,7 +249,7 @@ public class TestRestfulServer extends RestfulServer { public String determineServerBase(ServletContext theServletContext, HttpServletRequest theRequest) { /* * This is a bit of a hack, but we want to support both HTTP and HTTPS seamlessly - * so we have the outer httpd proxy relay requests to the Java container on + * so we have the outer httpd proxy relay requests to the Java container on * port 28080 for http and 28081 for https. */ String retVal = super.determineServerBase(theServletContext, theRequest); @@ -257,8 +258,8 @@ public class TestRestfulServer extends RestfulServer { } return retVal; } - + } - - + + } diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/interceptor/PublicSecurityInterceptor.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/interceptor/PublicSecurityInterceptor.java index 9e7ec5170de..f3acbc931ea 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/interceptor/PublicSecurityInterceptor.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/interceptor/PublicSecurityInterceptor.java @@ -1,7 +1,7 @@ package ca.uhn.fhirtest.interceptor; import ca.uhn.fhir.jpa.provider.BaseJpaSystemProvider; -import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; +import ca.uhn.fhir.jpa.provider.BaseTerminologyUploaderProvider; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException; import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor; @@ -16,8 +16,8 @@ import static org.apache.commons.lang3.StringUtils.isBlank; public class PublicSecurityInterceptor extends AuthorizationInterceptor { - private HashSet myTokens; private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(PublicSecurityInterceptor.class); + private HashSet myTokens; public PublicSecurityInterceptor() { String passwordsString = System.getProperty("fhir.tdlpass"); @@ -34,7 +34,7 @@ public class PublicSecurityInterceptor extends AuthorizationInterceptor { if (isBlank(authHeader)) { return new RuleBuilder() .deny().operation().named(BaseJpaSystemProvider.MARK_ALL_RESOURCES_FOR_REINDEXING).onServer().andThen() - .deny().operation().named(TerminologyUploaderProvider.UPLOAD_EXTERNAL_CODE_SYSTEM).onServer().andThen() + .deny().operation().named(BaseTerminologyUploaderProvider.UPLOAD_EXTERNAL_CODE_SYSTEM).onServer().andThen() .allowAll() .build(); }