- fixed issue on ui regarding pagination of results by configuring refuseToFetchThirdPartyUrls

- updated fhir version to R4 and used mysql as datasource with docs updated
- transferred jetty plugin to be viewable on intellij
- disabled oss snapshots
- replaced corsFilter based on new hapi docs
This commit is contained in:
Jessie James Cosare
2019-03-08 13:22:25 +08:00
parent 6907ae34ba
commit c5bfade9ce
7 changed files with 119 additions and 89 deletions

View File

@@ -43,6 +43,7 @@ public class FhirTesterConfig {
.withFhirVersion(HapiProperties.getFhirVersion())
.withBaseUrl(HapiProperties.getServerAddress())
.withName(HapiProperties.getServerName());
retVal.setRefuseToFetchThirdPartyUrls(HapiProperties.getTesterConfigRefustToFetchThirdPartyUrls());
return retVal;
}

View File

@@ -39,6 +39,7 @@ public class HapiProperties {
static final String SUBSCRIPTION_EMAIL_ENABLED = "subscription.email.enabled";
static final String SUBSCRIPTION_RESTHOOK_ENABLED = "subscription.resthook.enabled";
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";
private static Properties properties;
@@ -249,6 +250,10 @@ public class HapiProperties {
return HapiProperties.getIntegerProperty(TEST_PORT, 0);
}
public static Boolean getTesterConfigRefustToFetchThirdPartyUrls() {
return HapiProperties.getBooleanProperty(TESTER_CONFIG_REFUSE_TO_FETCH_THIRD_PARTY_URLS, false);
}
public static String getServerBase() {
return HapiProperties.getProperty(SERVER_BASE, "/fhir");
}

View File

@@ -4,6 +4,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.model.interceptor.executor.InterceptorService;
import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2;
import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2;
import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider;
@@ -14,17 +15,22 @@ import ca.uhn.fhir.jpa.provider.r4.JpaConformanceProviderR4;
import ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4;
import ca.uhn.fhir.jpa.provider.r4.TerminologyUploaderProviderR4;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.subscription.SubscriptionInterceptorLoader;
import ca.uhn.fhir.jpa.subscription.module.interceptor.SubscriptionDebugLogInterceptor;
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.interceptor.CorsInterceptor;
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.Meta;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.cors.CorsConfiguration;
import javax.servlet.ServletException;
import java.util.Arrays;
import java.util.List;
public class JpaRestfulServer extends RestfulServer {
@@ -173,6 +179,33 @@ public class JpaRestfulServer extends RestfulServer {
SubscriptionTriggeringProvider retriggeringProvider = appCtx.getBean(SubscriptionTriggeringProvider.class);
registerProvider(retriggeringProvider);
}
// Define your CORS configuration. This is an example
// showing a typical setup. You should customize this
// to your specific needs
CorsConfiguration config = new CorsConfiguration();
config.addAllowedHeader("x-fhir-starter");
config.addAllowedHeader("Origin");
config.addAllowedHeader("Accept");
config.addAllowedHeader("X-Requested-With");
config.addAllowedHeader("Content-Type");
config.addAllowedOrigin("*");
config.addExposedHeader("Location");
config.addExposedHeader("Content-Location");
config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"));
// Create the interceptor and register it
CorsInterceptor interceptor = new CorsInterceptor(config);
registerInterceptor(interceptor);
// Enable the use of subscriptions
SubscriptionInterceptorLoader subscriptionInterceptorLoader = appCtx.getBean(SubscriptionInterceptorLoader.class);
subscriptionInterceptorLoader.registerInterceptors();
// Subscription debug logging
InterceptorService interceptorService = (InterceptorService) appCtx.getBean("interceptorService");
interceptorService.registerInterceptor(new SubscriptionDebugLogInterceptor());
}
}

View File

@@ -1,7 +1,7 @@
# Adjust this to set the version of FHIR supported by this server. See
# FhirVersionEnum for a list of available constants.
fhir_version=DSTU3
fhir_version=R4
# This is the address that the FHIR server will report as its own address.
# If this server will be deployed (for example) to an internet accessible
@@ -25,16 +25,16 @@ logger.name=fhirtest.access
logger.format=Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]
logger.error_format=ERROR - ${requestVerb} ${requestUrl}
logger.log_exceptions=true
datasource.driver=org.apache.derby.jdbc.EmbeddedDriver
datasource.url=jdbc:derby:directory:target/jpaserver_derby_files;create=true
datasource.username=
datasource.password=
datasource.driver=com.mysql.cj.jdbc.Driver
datasource.url=jdbc:mysql://localhost:3306/fhir_r4
datasource.username=fhirUser
datasource.password=fhirPass
server.name=Local Tester
server.id=home
test.port=
subscription.email.enabled=true
subscription.resthook.enabled=true
hibernate.dialect=ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.search.model_mapping=ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory
hibernate.format_sql=false
hibernate.show_sql=false
@@ -47,3 +47,4 @@ hibernate.cache.use_minimal_puts=false
hibernate.search.default.directory_provider=filesystem
hibernate.search.default.indexBase=target/lucenefiles
hibernate.search.lucene_version=LUCENE_CURRENT
tester.config.refuse_to_fetch_third_party_urls=false

View File

@@ -37,69 +37,65 @@
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>fhirServlet</servlet-name>
<servlet-class>ca.uhn.fhir.jpa.starter.JpaRestfulServer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>fhirServlet</servlet-name>
<url-pattern>/fhir/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- This filters provide support for Cross Origin Resource Sharing (CORS) -->
<filter>
<filter-name>CORS Filter</filter-name>
<filter-class>org.ebaysf.web.cors.CORSFilter</filter-class>
<init-param>
<description>A comma separated list of allowed origins. Note: An '*' cannot be used for an allowed origin when using credentials.</description>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<description>A comma separated list of HTTP verbs, using which a CORS request can be made.</description>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,PUT,DELETE,OPTIONS</param-value>
</init-param>
<init-param>
<description>A comma separated list of allowed headers when making a non simple CORS request.</description>
<param-name>cors.allowed.headers</param-name>
<param-value>Accept,Access-Control-Request-Headers,Access-Control-Request-Method,Cache-Control,Content-Type,Origin,Prefer,X-FHIR-Starter,X-Requested-With</param-value>
</init-param>
<init-param>
<description>A comma separated list non-standard response headers that will be exposed to XHR2 object.</description>
<param-name>cors.exposed.headers</param-name>
<param-value>Location,Content-Location</param-value>
</init-param>
<init-param>
<description>A flag that suggests if CORS is supported with cookies</description>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<description>A flag to control logging</description>
<param-name>cors.logging.enabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<description>Indicates how long (in seconds) the results of a preflight request can be cached in a preflight result cache.</description>
<param-name>cors.preflight.maxage</param-name>
<param-value>300</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CORS Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--<filter>-->
<!--<filter-name>CORS Filter</filter-name>-->
<!--<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>-->
<!--<init-param>-->
<!--<description>A comma separated list of allowed origins. Note: An '*' cannot be used for an allowed origin when using credentials.</description>-->
<!--<param-name>cors.allowed.origins</param-name>-->
<!--<param-value>*</param-value>-->
<!--</init-param>-->
<!--<init-param>-->
<!--<description>A comma separated list of HTTP verbs, using which a CORS request can be made.</description>-->
<!--<param-name>cors.allowed.methods</param-name>-->
<!--<param-value>GET,POST,PUT,DELETE,OPTIONS</param-value>-->
<!--</init-param>-->
<!--<init-param>-->
<!--<description>A comma separated list of allowed headers when making a non simple CORS request.</description>-->
<!--<param-name>cors.allowed.headers</param-name>-->
<!--<param-value>Accept,Access-Control-Request-Headers,Access-Control-Request-Method,Cache-Control,Content-Type,Origin,Prefer,X-FHIR-Starter,X-Requested-With</param-value>-->
<!--</init-param>-->
<!--<init-param>-->
<!--<description>A comma separated list non-standard response headers that will be exposed to XHR2 object.</description>-->
<!--<param-name>cors.exposed.headers</param-name>-->
<!--<param-value>Location,Content-Location</param-value>-->
<!--</init-param>-->
<!--<init-param>-->
<!--<description>A flag that suggests if CORS is supported with cookies</description>-->
<!--<param-name>cors.support.credentials</param-name>-->
<!--<param-value>true</param-value>-->
<!--</init-param>-->
<!--<init-param>-->
<!--<description>A flag to control logging</description>-->
<!--<param-name>cors.logging.enabled</param-name>-->
<!--<param-value>true</param-value>-->
<!--</init-param>-->
<!--<init-param>-->
<!--<description>Indicates how long (in seconds) the results of a preflight request can be cached in a preflight result cache.</description>-->
<!--<param-name>cors.preflight.maxage</param-name>-->
<!--<param-value>300</param-value>-->
<!--</init-param>-->
<!--</filter>-->
<!--<filter-mapping>-->
<!--<filter-name>CORS Filter</filter-name>-->
<!--<url-pattern>/*</url-pattern>-->
<!--</filter-mapping>-->
</web-app>