Fix a couple of broken compile issues

This commit is contained in:
jamesagnew 2018-03-31 06:08:49 -04:00
parent c5b286921e
commit 9013e44ba0
4 changed files with 99 additions and 97 deletions

View File

@ -9,9 +9,9 @@ package ca.uhn.fhir.context.support;
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -8,9 +8,10 @@ import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2;
import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2; import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2;
import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3;
import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3; 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.JpaConformanceProviderR4;
import ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4; 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.composite.MetaDt;
import ca.uhn.fhir.model.dstu2.resource.Bundle; import ca.uhn.fhir.model.dstu2.resource.Bundle;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
@ -78,10 +79,10 @@ public class JpaServerDemo extends RestfulServer {
systemProvider.add(myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class)); systemProvider.add(myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class));
} else if (fhirVersion == FhirVersionEnum.DSTU3) { } else if (fhirVersion == FhirVersionEnum.DSTU3) {
systemProvider.add(myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class)); systemProvider.add(myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class));
systemProvider.add(myAppCtx.getBean(TerminologyUploaderProvider.class)); systemProvider.add(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class));
} else if (fhirVersion == FhirVersionEnum.R4) { } else if (fhirVersion == FhirVersionEnum.R4) {
systemProvider.add(myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class)); systemProvider.add(myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class));
systemProvider.add(myAppCtx.getBean(TerminologyUploaderProvider.class)); systemProvider.add(myAppCtx.getBean(TerminologyUploaderProviderR4.class));
} else { } else {
throw new IllegalStateException(); throw new IllegalStateException();
} }

View File

@ -8,9 +8,10 @@ import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2;
import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2; import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2;
import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3;
import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3; 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.JpaConformanceProviderR4;
import ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4; 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.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.api.EncodingEnum;
@ -50,6 +51,13 @@ public class TestRestfulServer extends RestfulServer {
private AnnotationConfigWebApplicationContext myAppCtx; private AnnotationConfigWebApplicationContext myAppCtx;
@Override
public void destroy() {
super.destroy();
ourLog.info("Server is shutting down");
myAppCtx.destroy();
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected void initialize() throws ServletException { protected void initialize() throws ServletException {
@ -74,79 +82,79 @@ public class TestRestfulServer extends RestfulServer {
ETagSupportEnum etagSupport; ETagSupportEnum etagSupport;
String baseUrlProperty; String baseUrlProperty;
List<Object> plainProviders = new ArrayList<Object>(); List<Object> plainProviders = new ArrayList<Object>();
switch (fhirVersionParam.trim().toUpperCase()) { switch (fhirVersionParam.trim().toUpperCase()) {
case "TDL2": case "TDL2":
case "DSTU2": { case "DSTU2": {
myAppCtx = new AnnotationConfigWebApplicationContext(); myAppCtx = new AnnotationConfigWebApplicationContext();
myAppCtx.setServletConfig(getServletConfig()); myAppCtx.setServletConfig(getServletConfig());
myAppCtx.setParent(parentAppCtx); myAppCtx.setParent(parentAppCtx);
if ("TDL2".equals(fhirVersionParam.trim().toUpperCase())) { if ("TDL2".equals(fhirVersionParam.trim().toUpperCase())) {
myAppCtx.register(TdlDstu2Config.class); myAppCtx.register(TdlDstu2Config.class);
baseUrlProperty = FHIR_BASEURL_TDL2; baseUrlProperty = FHIR_BASEURL_TDL2;
} else { } else {
myAppCtx.register(TestDstu2Config.class, WebsocketDispatcherConfig.class); myAppCtx.register(TestDstu2Config.class, WebsocketDispatcherConfig.class);
baseUrlProperty = FHIR_BASEURL_DSTU2; 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(); case "TDL3":
setFhirContext(FhirContext.forDstu2()); case "DSTU3": {
beans = myAppCtx.getBean("myResourceProvidersDstu2", List.class); myAppCtx = new AnnotationConfigWebApplicationContext();
plainProviders.add(myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class)); myAppCtx.setServletConfig(getServletConfig());
systemDao = myAppCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class); myAppCtx.setParent(parentAppCtx);
etagSupport = ETagSupportEnum.ENABLED; if ("TDL3".equals(fhirVersionParam.trim().toUpperCase())) {
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, myAppCtx.getBean(DaoConfig.class)); myAppCtx.register(TdlDstu3Config.class);
confProvider.setImplementationDescription(implDesc); baseUrlProperty = FHIR_BASEURL_TDL3;
setServerConformanceProvider(confProvider); } else {
break; myAppCtx.register(TestDstu3Config.class, WebsocketDispatcherConfig.class);
} baseUrlProperty = FHIR_BASEURL_DSTU3;
case "TDL3": }
case "DSTU3": { myAppCtx.refresh();
myAppCtx = new AnnotationConfigWebApplicationContext(); setFhirContext(FhirContext.forDstu3());
myAppCtx.setServletConfig(getServletConfig()); beans = myAppCtx.getBean("myResourceProvidersDstu3", List.class);
myAppCtx.setParent(parentAppCtx); plainProviders.add(myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class));
if ("TDL3".equals(fhirVersionParam.trim().toUpperCase())) { systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class);
myAppCtx.register(TdlDstu3Config.class); etagSupport = ETagSupportEnum.ENABLED;
baseUrlProperty = FHIR_BASEURL_TDL3; JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class));
} else { confProvider.setImplementationDescription(implDesc);
myAppCtx.register(TestDstu3Config.class, WebsocketDispatcherConfig.class); setServerConformanceProvider(confProvider);
baseUrlProperty = FHIR_BASEURL_DSTU3; plainProviders.add(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class));
break;
} }
myAppCtx.refresh(); case "R4": {
setFhirContext(FhirContext.forDstu3()); myAppCtx = new AnnotationConfigWebApplicationContext();
beans = myAppCtx.getBean("myResourceProvidersDstu3", List.class); myAppCtx.setServletConfig(getServletConfig());
plainProviders.add(myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class)); myAppCtx.setParent(parentAppCtx);
systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class); myAppCtx.register(TestR4Config.class, WebsocketDispatcherConfig.class);
etagSupport = ETagSupportEnum.ENABLED; baseUrlProperty = FHIR_BASEURL_R4;
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class)); myAppCtx.refresh();
confProvider.setImplementationDescription(implDesc); setFhirContext(FhirContext.forR4());
setServerConformanceProvider(confProvider); beans = myAppCtx.getBean("myResourceProvidersR4", List.class);
plainProviders.add(myAppCtx.getBean(TerminologyUploaderProvider.class)); plainProviders.add(myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class));
break; 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); setETagSupport(etagSupport);
@ -155,9 +163,9 @@ public class TestRestfulServer extends RestfulServer {
*/ */
FhirContext ctx = getFhirContext(); FhirContext ctx = getFhirContext();
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator()); 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 * operations in this server) are all retrieved from the spring context above
* and are provided to the server here. * and are provided to the server here.
*/ */
@ -187,17 +195,17 @@ public class TestRestfulServer extends RestfulServer {
responseHighlighterInterceptor.setShowRequestHeaders(false); responseHighlighterInterceptor.setShowRequestHeaders(false);
responseHighlighterInterceptor.setShowResponseHeaders(true); responseHighlighterInterceptor.setShowResponseHeaders(true);
registerInterceptor(responseHighlighterInterceptor); registerInterceptor(responseHighlighterInterceptor);
registerInterceptor(new BanUnsupportedHttpMethodsInterceptor()); registerInterceptor(new BanUnsupportedHttpMethodsInterceptor());
/* /*
* Default to JSON with pretty printing * Default to JSON with pretty printing
*/ */
setDefaultPrettyPrint(true); setDefaultPrettyPrint(true);
setDefaultResponseEncoding(EncodingEnum.JSON); 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 * pulled from a system property, which is helpful if you want to try
* hosting your own copy of this server. * hosting your own copy of this server.
*/ */
@ -210,12 +218,12 @@ public class TestRestfulServer extends RestfulServer {
} }
} }
setServerAddressStrategy(new MyHardcodedServerAddressStrategy(baseUrl)); setServerAddressStrategy(new MyHardcodedServerAddressStrategy(baseUrl));
/* /*
* Spool results to the database * Spool results to the database
*/ */
setPagingProvider(myAppCtx.getBean(DatabaseBackedPagingProvider.class)); setPagingProvider(myAppCtx.getBean(DatabaseBackedPagingProvider.class));
/* /*
* Load interceptors for the server from Spring * 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 * 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, * 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) { public String determineServerBase(ServletContext theServletContext, HttpServletRequest theRequest) {
/* /*
* This is a bit of a hack, but we want to support both HTTP and HTTPS seamlessly * 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. * port 28080 for http and 28081 for https.
*/ */
String retVal = super.determineServerBase(theServletContext, theRequest); String retVal = super.determineServerBase(theServletContext, theRequest);
@ -257,8 +258,8 @@ public class TestRestfulServer extends RestfulServer {
} }
return retVal; return retVal;
} }
} }
} }

View File

@ -1,7 +1,7 @@
package ca.uhn.fhirtest.interceptor; package ca.uhn.fhirtest.interceptor;
import ca.uhn.fhir.jpa.provider.BaseJpaSystemProvider; 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.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException; import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException;
import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor; 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 { public class PublicSecurityInterceptor extends AuthorizationInterceptor {
private HashSet<String> myTokens;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(PublicSecurityInterceptor.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(PublicSecurityInterceptor.class);
private HashSet<String> myTokens;
public PublicSecurityInterceptor() { public PublicSecurityInterceptor() {
String passwordsString = System.getProperty("fhir.tdlpass"); String passwordsString = System.getProperty("fhir.tdlpass");
@ -34,7 +34,7 @@ public class PublicSecurityInterceptor extends AuthorizationInterceptor {
if (isBlank(authHeader)) { if (isBlank(authHeader)) {
return new RuleBuilder() return new RuleBuilder()
.deny().operation().named(BaseJpaSystemProvider.MARK_ALL_RESOURCES_FOR_REINDEXING).onServer().andThen() .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() .allowAll()
.build(); .build();
} }