Using a configurable properties file for settings that might change between environments
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package ca.uhn.fhir.jpa.demo;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.Driver;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
@@ -9,8 +11,6 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
|
||||
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowire;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -38,7 +38,9 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
||||
@Bean()
|
||||
public DaoConfig daoConfig() {
|
||||
DaoConfig retVal = new DaoConfig();
|
||||
retVal.setAllowMultipleDelete(true);
|
||||
retVal.setAllowMultipleDelete(HapiProperties.getAllowMultipleDelete());
|
||||
retVal.setAllowExternalReferences(HapiProperties.getAllowExternalReferences());
|
||||
retVal.setExpungeEnabled(HapiProperties.getExpungeEnabled());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -50,8 +52,8 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
||||
@Override
|
||||
public DatabaseBackedPagingProvider databaseBackedPagingProvider() {
|
||||
DatabaseBackedPagingProvider pagingProvider = super.databaseBackedPagingProvider();
|
||||
pagingProvider.setDefaultPageSize(20);
|
||||
pagingProvider.setMaximumPageSize(200);
|
||||
pagingProvider.setDefaultPageSize(HapiProperties.getDefaultPageSize());
|
||||
pagingProvider.setMaximumPageSize(HapiProperties.getMaximumPageSize());
|
||||
return pagingProvider;
|
||||
}
|
||||
|
||||
@@ -62,12 +64,13 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
||||
* A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource.
|
||||
*/
|
||||
@Bean(destroyMethod = "close")
|
||||
public DataSource dataSource() {
|
||||
public DataSource dataSource() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||
BasicDataSource retVal = new BasicDataSource();
|
||||
retVal.setDriver(new org.apache.derby.jdbc.EmbeddedDriver());
|
||||
retVal.setUrl("jdbc:derby:directory:target/jpaserver_derby_files;create=true");
|
||||
retVal.setUsername("");
|
||||
retVal.setPassword("");
|
||||
Driver driver = (Driver) Class.forName(HapiProperties.getDataSourceDriver()).getConstructor().newInstance();
|
||||
retVal.setDriver(driver);
|
||||
retVal.setUrl(HapiProperties.getDataSourceUrl());
|
||||
retVal.setUsername(HapiProperties.getDataSourceUsername());
|
||||
retVal.setPassword(HapiProperties.getDataSourcePassword());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -75,28 +78,33 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
||||
@Bean()
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
||||
retVal.setPersistenceUnitName("HAPI_PU");
|
||||
retVal.setDataSource(dataSource());
|
||||
retVal.setPersistenceUnitName(HapiProperties.getPersistenceUnitName());
|
||||
|
||||
try {
|
||||
retVal.setDataSource(dataSource());
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
retVal.setJpaProperties(jpaProperties());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private Properties jpaProperties() {
|
||||
Properties extraProperties = new Properties();
|
||||
extraProperties.put("hibernate.dialect", DerbyTenSevenHapiFhirDialect.class.getName());
|
||||
extraProperties.put("hibernate.format_sql", "false");
|
||||
extraProperties.put("hibernate.show_sql", "false");
|
||||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||
extraProperties.put("hibernate.jdbc.batch_size", "20");
|
||||
extraProperties.put("hibernate.cache.use_query_cache", "false");
|
||||
extraProperties.put("hibernate.cache.use_second_level_cache", "false");
|
||||
extraProperties.put("hibernate.cache.use_structured_entries", "false");
|
||||
extraProperties.put("hibernate.cache.use_minimal_puts", "false");
|
||||
extraProperties.put("hibernate.search.model_mapping", LuceneSearchMappingFactory.class.getName());
|
||||
extraProperties.put("hibernate.search.default.directory_provider", "filesystem");
|
||||
extraProperties.put("hibernate.search.default.indexBase", "target/lucenefiles");
|
||||
extraProperties.put("hibernate.search.lucene_version", "LUCENE_CURRENT");
|
||||
// extraProperties.put("hibernate.search.default.worker.execution", "async");
|
||||
Properties extraProperties = HapiProperties.getProperties();
|
||||
|
||||
if (extraProperties == null) {
|
||||
extraProperties = new Properties();
|
||||
}
|
||||
|
||||
return extraProperties;
|
||||
}
|
||||
|
||||
@@ -105,11 +113,10 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
||||
*/
|
||||
public IServerInterceptor loggingInterceptor() {
|
||||
LoggingInterceptor retVal = new LoggingInterceptor();
|
||||
retVal.setLoggerName("fhirtest.access");
|
||||
retVal.setMessageFormat(
|
||||
"Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]");
|
||||
retVal.setLogExceptions(true);
|
||||
retVal.setErrorMessageFormat("ERROR - ${requestVerb} ${requestUrl}");
|
||||
retVal.setLoggerName(HapiProperties.getLoggerName());
|
||||
retVal.setMessageFormat(HapiProperties.getLoggerFormat());
|
||||
retVal.setErrorMessageFormat(HapiProperties.getLoggerErrorFormat());
|
||||
retVal.setLogExceptions(HapiProperties.getLoggerLogExceptions());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -134,5 +141,4 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
||||
retVal.setEntityManagerFactory(entityManagerFactory);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.to.FhirTesterMvcConfig;
|
||||
import ca.uhn.fhir.to.TesterConfig;
|
||||
|
||||
@@ -40,10 +39,10 @@ public class FhirTesterConfig {
|
||||
TesterConfig retVal = new TesterConfig();
|
||||
retVal
|
||||
.addServer()
|
||||
.withId("home")
|
||||
.withFhirVersion(FhirVersionEnum.DSTU3)
|
||||
.withBaseUrl("${serverBase}/baseDstu3")
|
||||
.withName("Local Tester");
|
||||
.withId(HapiProperties.getServerId())
|
||||
.withFhirVersion(HapiProperties.getFhirVersion())
|
||||
.withBaseUrl("${serverBase}" + HapiProperties.getServerBase())
|
||||
.withName(HapiProperties.getServerName());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
211
src/main/java/ca/uhn/fhir/jpa/demo/HapiProperties.java
Normal file
211
src/main/java/ca/uhn/fhir/jpa/demo/HapiProperties.java
Normal file
@@ -0,0 +1,211 @@
|
||||
package ca.uhn.fhir.jpa.demo;
|
||||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.ETagSupportEnum;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class HapiProperties {
|
||||
public static final String SERVER_ADDRESS = "server_address";
|
||||
public static final String DEFAULT_PRETTY_PRINT = "default_pretty_print";
|
||||
public static final String MAX_PAGE_SIZE = "max_page_size";
|
||||
public static final String DEFAULT_PAGE_SIZE = "default_page_size";
|
||||
public static final String LOGGER_NAME = "logger.name";
|
||||
public static final String LOGGER_FORMAT = "logger.format";
|
||||
public static final String ALLOW_EXTERNAL_REFERENCES = "allow_external_references";
|
||||
public static final String ALLOW_MULTIPLE_DELETE = "allow_multiple_delete";
|
||||
public static final String DATASOURCE_PASSWORD = "datasource.password";
|
||||
public static final String DATASOURCE_USERNAME = "datasource.username";
|
||||
public static final String DATASOURCE_URL = "datasource.url";
|
||||
public static final String DATASOURCE_DRIVER = "datasource.driver";
|
||||
public static final String LOGGER_LOG_EXCEPTIONS = "logger.log_exceptions";
|
||||
public static final String LOGGER_ERROR_FORMAT = "logger.error_format";
|
||||
public static final String PERSISTENCE_UNIT_NAME = "persistence_unit_name";
|
||||
public static final String SERVER_BASE = "server.base";
|
||||
public static final String TEST_PORT = "test.port";
|
||||
public static final String SERVER_NAME = "server.name";
|
||||
public static final String SERVER_ID = "server.id";
|
||||
private static Properties properties;
|
||||
private static final String HAPI_PROPERTIES = "hapi.properties";
|
||||
private static final String FHIR_VERSION = "fhir_version";
|
||||
private static final String DEFAULT_ENCODING = "default_encoding";
|
||||
private static final String ETAG_SUPPORT = "etag_support";
|
||||
|
||||
public static Properties getProperties() {
|
||||
if (properties == null) {
|
||||
// Load the configurable properties file
|
||||
InputStream in = null;
|
||||
|
||||
try {
|
||||
in = HapiProperties.class.getClassLoader().getResourceAsStream(HAPI_PROPERTIES);
|
||||
HapiProperties.properties = new Properties();
|
||||
HapiProperties.properties.load(in);
|
||||
in.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
private static String getProperty(String propertyName) {
|
||||
Properties properties = HapiProperties.getProperties();
|
||||
|
||||
if (properties != null) {
|
||||
return properties.getProperty(propertyName);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getProperty(String propertyName, String defaultValue) {
|
||||
Properties properties = HapiProperties.getProperties();
|
||||
|
||||
if (properties != null) {
|
||||
String value = properties.getProperty(propertyName);
|
||||
|
||||
if (value != null && value.length() > 0) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private static Boolean getBooleanProperty(String propertyName, Boolean defaultValue) {
|
||||
String value = HapiProperties.getProperty(propertyName);
|
||||
|
||||
if (value == null || value.length() == 0) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return Boolean.parseBoolean(value);
|
||||
}
|
||||
|
||||
private static Integer getIntegerProperty(String propertyName, Integer defaultValue) {
|
||||
String value = HapiProperties.getProperty(propertyName);
|
||||
|
||||
if (value == null || value.length() == 0) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return Integer.parseInt(value);
|
||||
}
|
||||
|
||||
public static FhirVersionEnum getFhirVersion() {
|
||||
String fhirVersionString = HapiProperties.getProperty(FHIR_VERSION);
|
||||
|
||||
if (fhirVersionString != null && fhirVersionString.length() > 0) {
|
||||
return FhirVersionEnum.valueOf(fhirVersionString);
|
||||
}
|
||||
|
||||
return FhirVersionEnum.DSTU3;
|
||||
}
|
||||
|
||||
public static ETagSupportEnum getEtagSupport() {
|
||||
String etagSupportString = HapiProperties.getProperty(ETAG_SUPPORT);
|
||||
|
||||
if (etagSupportString != null && etagSupportString.length() > 0) {
|
||||
return ETagSupportEnum.valueOf(etagSupportString);
|
||||
}
|
||||
|
||||
return ETagSupportEnum.ENABLED;
|
||||
}
|
||||
|
||||
public static EncodingEnum getDefaultEncoding() {
|
||||
String defaultEncodingString = HapiProperties.getProperty(DEFAULT_ENCODING);
|
||||
|
||||
if (defaultEncodingString != null && defaultEncodingString.length() > 0) {
|
||||
return EncodingEnum.valueOf(defaultEncodingString);
|
||||
}
|
||||
|
||||
return EncodingEnum.JSON;
|
||||
}
|
||||
|
||||
public static Boolean getDefaultPrettyPrint() {
|
||||
return HapiProperties.getBooleanProperty(DEFAULT_PRETTY_PRINT, true);
|
||||
}
|
||||
|
||||
public static String getServerAddress() {
|
||||
return HapiProperties.getProperty(SERVER_ADDRESS);
|
||||
}
|
||||
|
||||
public static Integer getDefaultPageSize() {
|
||||
return HapiProperties.getIntegerProperty(DEFAULT_PAGE_SIZE, 20);
|
||||
}
|
||||
|
||||
public static Integer getMaximumPageSize() {
|
||||
return HapiProperties.getIntegerProperty(MAX_PAGE_SIZE, 200);
|
||||
}
|
||||
|
||||
public static String getPersistenceUnitName() {
|
||||
return HapiProperties.getProperty(PERSISTENCE_UNIT_NAME, "HAPI_PU");
|
||||
}
|
||||
|
||||
public static String getLoggerName() {
|
||||
return HapiProperties.getProperty(LOGGER_NAME, "fhirtest.access");
|
||||
}
|
||||
|
||||
public static String getLoggerFormat() {
|
||||
return HapiProperties.getProperty(LOGGER_FORMAT, "Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]");
|
||||
}
|
||||
|
||||
public static String getLoggerErrorFormat() {
|
||||
return HapiProperties.getProperty(LOGGER_ERROR_FORMAT, "ERROR - ${requestVerb} ${requestUrl}");
|
||||
}
|
||||
|
||||
public static Boolean getLoggerLogExceptions() {
|
||||
return HapiProperties.getBooleanProperty(LOGGER_LOG_EXCEPTIONS, true);
|
||||
}
|
||||
|
||||
public static String getDataSourceDriver() {
|
||||
return HapiProperties.getProperty(DATASOURCE_DRIVER, "org.apache.derby.jdbc.EmbeddedDriver");
|
||||
}
|
||||
|
||||
public static String getDataSourceUrl() {
|
||||
return HapiProperties.getProperty(DATASOURCE_URL, "jdbc:derby:directory:target/jpaserver_derby_files;create=true");
|
||||
}
|
||||
|
||||
public static String getDataSourceUsername() {
|
||||
return HapiProperties.getProperty(DATASOURCE_USERNAME);
|
||||
}
|
||||
|
||||
public static String getDataSourcePassword() {
|
||||
return HapiProperties.getProperty(DATASOURCE_PASSWORD);
|
||||
}
|
||||
|
||||
public static Boolean getAllowMultipleDelete() {
|
||||
return HapiProperties.getBooleanProperty(ALLOW_MULTIPLE_DELETE, true);
|
||||
}
|
||||
|
||||
public static Boolean getAllowExternalReferences() {
|
||||
return HapiProperties.getBooleanProperty(ALLOW_EXTERNAL_REFERENCES, true);
|
||||
}
|
||||
|
||||
public static Boolean getExpungeEnabled() {
|
||||
return HapiProperties.getBooleanProperty("expunge_enabled", true);
|
||||
}
|
||||
|
||||
public static Integer getTestPort() {
|
||||
return HapiProperties.getIntegerProperty(TEST_PORT, 0);
|
||||
}
|
||||
|
||||
public static String getServerBase() {
|
||||
return HapiProperties.getProperty(SERVER_BASE, "/baseDstu3");
|
||||
}
|
||||
|
||||
public static String getServerName() {
|
||||
return HapiProperties.getProperty(SERVER_NAME, "Local Tester");
|
||||
}
|
||||
|
||||
public static String getServerId() {
|
||||
return HapiProperties.getProperty(SERVER_ID, "home");
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,12 @@ import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider;
|
||||
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.JpaSystemProviderR4;
|
||||
import ca.uhn.fhir.jpa.provider.r4.TerminologyUploaderProviderR4;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import ca.uhn.fhir.jpa.subscription.resthook.SubscriptionRestHookInterceptor;
|
||||
//import ca.uhn.fhir.jpa.subscription.resthook.SubscriptionRestHookInterceptor;
|
||||
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
|
||||
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.ETagSupportEnum;
|
||||
import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
@@ -48,7 +48,7 @@ public class JpaServerDemo extends RestfulServer {
|
||||
*
|
||||
* If you want to use DSTU1 instead, change the following line, and change the 2 occurrences of dstu2 in web.xml to dstu1
|
||||
*/
|
||||
FhirVersionEnum fhirVersion = FhirVersionEnum.DSTU3;
|
||||
FhirVersionEnum fhirVersion = HapiProperties.getFhirVersion();
|
||||
setFhirContext(new FhirContext(fhirVersion));
|
||||
|
||||
// Get the spring context from the web container (it's declared in web.xml)
|
||||
@@ -64,6 +64,8 @@ public class JpaServerDemo extends RestfulServer {
|
||||
resourceProviderBeanName = "myResourceProvidersDstu2";
|
||||
} else if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||
resourceProviderBeanName = "myResourceProvidersDstu3";
|
||||
} else if (fhirVersion == FhirVersionEnum.R4) {
|
||||
resourceProviderBeanName = "myResourceProviderR4";
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@@ -79,6 +81,8 @@ public class JpaServerDemo extends RestfulServer {
|
||||
systemProvider = myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class);
|
||||
} else if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||
systemProvider = myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class);
|
||||
} else if (fhirVersion == FhirVersionEnum.R4) {
|
||||
systemProvider = myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class);
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@@ -91,24 +95,27 @@ public class JpaServerDemo extends RestfulServer {
|
||||
*/
|
||||
if (fhirVersion == FhirVersionEnum.DSTU2) {
|
||||
IFhirSystemDao<ca.uhn.fhir.model.dstu2.resource.Bundle, MetaDt> systemDao = myAppCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class);
|
||||
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao,
|
||||
myAppCtx.getBean(DaoConfig.class));
|
||||
confProvider.setImplementationDescription("Example Server");
|
||||
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, myAppCtx.getBean(DaoConfig.class));
|
||||
confProvider.setImplementationDescription("HAPI FHIR DSTU2 Server");
|
||||
setServerConformanceProvider(confProvider);
|
||||
} else if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||
IFhirSystemDao<Bundle, Meta> systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class);
|
||||
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao,
|
||||
myAppCtx.getBean(DaoConfig.class));
|
||||
confProvider.setImplementationDescription("Example Server");
|
||||
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class));
|
||||
confProvider.setImplementationDescription("HAPI FHIR DSTU3 Server");
|
||||
setServerConformanceProvider(confProvider);
|
||||
} else if (fhirVersion == FhirVersionEnum.R4) {
|
||||
IFhirSystemDao<Bundle, Meta> systemDao = myAppCtx.getBean("mySystemDaoR4", IFhirSystemDao.class);
|
||||
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class));
|
||||
confProvider.setImplementationDescription("HAPI FHIR R4 Server");
|
||||
setServerConformanceProvider(confProvider);
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable ETag Support (this is already the default)
|
||||
* ETag Support
|
||||
*/
|
||||
setETagSupport(ETagSupportEnum.ENABLED);
|
||||
setETagSupport(HapiProperties.getEtagSupport());
|
||||
|
||||
/*
|
||||
* This server tries to dynamically generate narratives
|
||||
@@ -119,8 +126,12 @@ public class JpaServerDemo extends RestfulServer {
|
||||
/*
|
||||
* Default to JSON and pretty printing
|
||||
*/
|
||||
setDefaultPrettyPrint(true);
|
||||
setDefaultResponseEncoding(EncodingEnum.JSON);
|
||||
setDefaultPrettyPrint(HapiProperties.getDefaultPrettyPrint());
|
||||
|
||||
/*
|
||||
* Default encoding
|
||||
*/
|
||||
setDefaultResponseEncoding(HapiProperties.getDefaultEncoding());
|
||||
|
||||
/*
|
||||
* -- New in HAPI FHIR 1.5 --
|
||||
@@ -145,8 +156,9 @@ public class JpaServerDemo extends RestfulServer {
|
||||
* this doesn't always work. If you are setting links in your search bundles that
|
||||
* just refer to "localhost", you might want to use a server address strategy:
|
||||
*/
|
||||
if (false) { // <-- DISABLED RIGHT NOW
|
||||
setServerAddressStrategy(new HardcodedServerAddressStrategy("http://mydomain.com/fhir/baseDstu3"));
|
||||
String serverAddress = HapiProperties.getServerAddress();
|
||||
if (serverAddress != null && serverAddress.length() > 0) {
|
||||
setServerAddressStrategy(new HardcodedServerAddressStrategy(serverAddress));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -159,6 +171,8 @@ public class JpaServerDemo extends RestfulServer {
|
||||
if (false) { // <-- DISABLED RIGHT NOW
|
||||
if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||
registerProvider(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class));
|
||||
} else if (fhirVersion == FhirVersionEnum.R4) {
|
||||
registerProvider(myAppCtx.getBean(TerminologyUploaderProviderR4.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,8 +182,8 @@ public class JpaServerDemo extends RestfulServer {
|
||||
*/
|
||||
boolean subscriptionsEnabled = false;
|
||||
if (subscriptionsEnabled) { // <-- DISABLED RIGHT NOW
|
||||
SubscriptionRestHookInterceptor restHookInterceptor = myAppCtx.getBean(SubscriptionRestHookInterceptor.class);
|
||||
registerInterceptor(restHookInterceptor);
|
||||
//SubscriptionRestHookInterceptor restHookInterceptor = myAppCtx.getBean(SubscriptionRestHookInterceptor.class);
|
||||
//registerInterceptor(restHookInterceptor);
|
||||
|
||||
// You might alo want to enable other subscription interceptors too
|
||||
// eg...
|
||||
|
||||
35
src/main/resources/hapi.properties
Normal file
35
src/main/resources/hapi.properties
Normal file
@@ -0,0 +1,35 @@
|
||||
fhir_version=DSTU3
|
||||
default_encoding=JSON
|
||||
etag_support=ENABLED
|
||||
server_address=http://mydomain.com/fhir/baseDstu3
|
||||
default_page_size=20
|
||||
max_page_size=200
|
||||
allow_multiple_delete=true
|
||||
allow_external_references=true
|
||||
expunge_enabled=true
|
||||
persistence_unit_name=HAPI_PU
|
||||
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=
|
||||
server.base=/baseDstu3
|
||||
server.name=Local Tester
|
||||
server.id=home
|
||||
test.port=
|
||||
hibernate.dialect=ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect
|
||||
hibernate.search.model_mapping=ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory
|
||||
hibernate.format_sql=false
|
||||
hibernate.show_sql=false
|
||||
hibernate.hbm2ddl.auto=update
|
||||
hibernate.jdbc.batch_size=20
|
||||
hibernate.cache.use_query_cache=false
|
||||
hibernate.cache.use_second_level_cache=false
|
||||
hibernate.cache.use_structured_entries=false
|
||||
hibernate.cache.use_minimal_puts=false
|
||||
hibernate.search.default.directory_provider=filesystem
|
||||
hibernate.search.default.indexBase=target/lucenefiles
|
||||
hibernate.search.lucene_version=LUCENE_CURRENT
|
||||
Reference in New Issue
Block a user