Skip to content

Commit

Permalink
Merge branch 'ehr-cleanup'
Browse files Browse the repository at this point in the history
Locally rebasing and merging PR #56
  • Loading branch information
eedrummer committed Oct 9, 2018
2 parents efa207f + 27bda40 commit 5a046a2
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 75 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hl7.davinci.ehrServer;
package org.hl7.davinci.ehrserver;

import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor;
Expand Down Expand Up @@ -28,8 +28,8 @@ public class ClientAuthorizationInterceptor extends AuthorizationInterceptor {

@Override
public List<IAuthRule> buildRuleList(RequestDetails theRequestDetails) {
String use_oauth = Config.get("use_oauth");
if (!Boolean.parseBoolean(use_oauth)) {
String useOauth = Config.get("use_oauth");
if (!Boolean.parseBoolean(useOauth)) {
return new RuleBuilder()
.allowAll()
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hl7.davinci.ehrServer;
package org.hl7.davinci.ehrserver;

import java.io.File;
import java.io.FileNotFoundException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hl7.davinci.ehrServer;
package org.hl7.davinci.ehrserver;

import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -126,7 +126,7 @@ protected void initialize() throws ServletException {
* with this feature.
*/
//if (fhirVersion == FhirVersionEnum.R4) {
// registerProvider(myAppCtx.getBean(TerminologyUploaderProviderR4.class));
// registerProvider(myAppCtx.getBean(TerminologyUploaderProviderR4.class));
//}
logger.info("EhrServer::initialize() end");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hl7.davinci.ehrServer;
package org.hl7.davinci.ehrserver;

import java.util.Arrays;
import java.util.Properties;
Expand All @@ -10,8 +10,6 @@
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
import ca.uhn.fhir.rest.server.interceptor.CorsInterceptor;
import org.apache.commons.dbcp2.BasicDataSource;
//import org.apache.commons.lang3.time.DateUtils;
//import org.hibernate.jpa.HibernatePersistenceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowire;
Expand All @@ -30,7 +28,7 @@
import org.springframework.web.cors.CorsConfiguration;

/**
* This is the primary configuration file for the example server
* This is the primary configuration file for the example server.
*/
@Configuration
@EnableTransactionManagement()
Expand All @@ -49,10 +47,12 @@ public DaoConfig daoConfig() {
}

/**
* The following bean configures the database connection. The 'url' property value of "jdbc:derby:directory:jpaserver_derby_files;create=true" indicates that the server should save resources in a
* The following bean configures the database connection. The 'url' property value of
* "jdbc:derby:directory:jpaserver_derby_files;create=true" indicates that the server should save resources in a
* directory called "jpaserver_derby_files".
* <p>
* A URL to a remote database could also be placed here, along with login credentials and other properties supported by BasicDataSource.
* 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() {
Expand Down Expand Up @@ -92,7 +92,7 @@ private Properties jpaProperties() {
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");
//extraProperties.put("hibernate.search.default.worker.execution", "async");
return extraProperties;
}

Expand All @@ -104,14 +104,16 @@ 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}]");
"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}");
return retVal;
}

/**
* This interceptor adds some pretty syntax highlighting in responses when a browser is detected
* This interceptor adds some pretty syntax highlighting in responses when a browser is detected.
*/
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
Expand All @@ -132,6 +134,9 @@ public IServerInterceptor authorizationInterceptor() {
return new ClientAuthorizationInterceptor();
}

/**
* This interceptor filters the headers, origin of the data, and the methods.
*/
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor corsInterceptor() {
logger.info("FhirServerConfig::corsInterceptor");
Expand All @@ -153,6 +158,9 @@ public IServerInterceptor corsInterceptor() {
return new CorsInterceptor(config);
}

/**
* Setup a new JPA transaction manager.
*/
@Bean()
public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
logger.info("FhirServerConfig::transactionManager()");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hl7.davinci.ehrServer;
package org.hl7.davinci.ehrserver;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hl7.davinci.ehrServer.requestGenerator;
package org.hl7.davinci.ehrserver.requestgenerator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -10,7 +10,7 @@
public class RequestGeneratorController {
static final Logger logger = LoggerFactory.getLogger(RequestGeneratorController.class);

@RequestMapping(value= {"/", "/reqgen", "/index", "/index.html"}, method=RequestMethod.GET)
@RequestMapping(value = {"/", "/reqgen", "/index", "/index.html"}, method = RequestMethod.GET)
public String index() {
logger.info("RequestGenerator page requested");
return "index";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.hl7.davinci.ehrserver.requestgenerator;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;


@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "org.hl7.davinci.ehrserver.requestgenerator")
public class RequestGeneratorMvcConfig implements WebMvcConfigurer {

@Override
public void addResourceHandlers(ResourceHandlerRegistry theRegistry) {
theRegistry.addResourceHandler("/**").addResourceLocations("/WEB-INF/reqgen/");
theRegistry.addResourceHandler("/static/css/**").addResourceLocations("/WEB-INF/reqgen/static/css/");
theRegistry.addResourceHandler("/static/js/**").addResourceLocations("/WEB-INF/reqgen/static/js/");
theRegistry.addResourceHandler("/static/media/**").addResourceLocations("/WEB-INF/reqgen/static/media/");
}

/**
* Setup the template resolver with the location of the templates.
*/
@Bean
public SpringResourceTemplateResolver templateResolver() {
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
resolver.setPrefix("/WEB-INF/reqgen/");
resolver.setSuffix(".html");
resolver.setTemplateMode(TemplateMode.HTML);
resolver.setCharacterEncoding("UTF-8");
return resolver;
}

/**
* Setup the view resolver.
*/
@Bean
public ThymeleafViewResolver viewResolver() {
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
viewResolver.setTemplateEngine(templateEngine());
viewResolver.setCharacterEncoding("UTF-8");
return viewResolver;
}

/**
* Setup the template engine.
*/
@Bean
public SpringTemplateEngine templateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver());
return templateEngine;
}

}
8 changes: 4 additions & 4 deletions ehr-server/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
org.hl7.davinci.ehrServer.FhirServerConfig
org.hl7.davinci.ehrserver.FhirServerConfig
</param-value>
</context-param>

Expand All @@ -28,14 +28,14 @@
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>org.hl7.davinci.ehrServer.FhirTesterConfig</param-value>
<param-value>org.hl7.davinci.ehrserver.FhirTesterConfig</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet>
<servlet-name>fhirServlet</servlet-name>
<servlet-class>org.hl7.davinci.ehrServer.EhrServer</servlet-class>
<servlet-class>org.hl7.davinci.ehrserver.EhrServer</servlet-class>
<init-param>
<param-name>ImplementationDescription</param-name>
<param-value>FHIR JPA Server</param-value>
Expand All @@ -56,7 +56,7 @@
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>org.hl7.davinci.ehrServer.requestGenerator.RequestGeneratorMvcConfig</param-value>
<param-value>org.hl7.davinci.ehrserver.requestgenerator.RequestGeneratorMvcConfig</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
Expand Down

0 comments on commit 5a046a2

Please sign in to comment.