Skip to content

Commit

Permalink
Fix a couple of broken compile issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesagnew committed Mar 31, 2018
1 parent c5b2869 commit 9013e44
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
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;
Expand Down Expand Up @@ -78,10 +79,10 @@ protected void initialize() throws ServletException {
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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
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;
Expand Down Expand Up @@ -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 {
Expand All @@ -74,79 +82,79 @@ protected void initialize() throws ServletException {
ETagSupportEnum etagSupport;
String baseUrlProperty;
List<Object> plainProviders = new ArrayList<Object>();

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(TerminologyUploaderProvider.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(TerminologyUploaderProviderR4.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);

Expand All @@ -155,9 +163,9 @@ protected void initialize() throws ServletException {
*/
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.
*/
Expand Down Expand Up @@ -187,17 +195,17 @@ protected void initialize() throws ServletException {
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.
*/
Expand All @@ -210,12 +218,12 @@ protected void initialize() throws ServletException {
}
}
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
*/
Expand All @@ -226,13 +234,6 @@ protected void initialize() throws ServletException {

}

@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,
Expand All @@ -248,7 +249,7 @@ public MyHardcodedServerAddressStrategy(String theBaseUrl) {
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);
Expand All @@ -257,8 +258,8 @@ public String determineServerBase(ServletContext theServletContext, HttpServletR
}
return retVal;
}

}


}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,8 +16,8 @@

public class PublicSecurityInterceptor extends AuthorizationInterceptor {

private HashSet<String> myTokens;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(PublicSecurityInterceptor.class);
private HashSet<String> myTokens;

public PublicSecurityInterceptor() {
String passwordsString = System.getProperty("fhir.tdlpass");
Expand All @@ -34,7 +34,7 @@ public List<IAuthRule> buildRuleList(RequestDetails theRequestDetails) {
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();
}
Expand Down

0 comments on commit 9013e44

Please sign in to comment.