Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jamesagnew/hapi-fhir into…
Browse files Browse the repository at this point in the history
… jaxrs-sever-evolution
  • Loading branch information
SRiviere committed Feb 6, 2017
2 parents dabb3ea + d4dda1d commit 3bf6555
Show file tree
Hide file tree
Showing 368 changed files with 3,813 additions and 6,166 deletions.
5 changes: 0 additions & 5 deletions .classpath

This file was deleted.

8 changes: 5 additions & 3 deletions .gitignore
Expand Up @@ -137,9 +137,11 @@ local.properties
.cproject

# JDT-specific (Eclipse Java Development Tools)
#.project
#.settings/
#.classpath
**/.settings
**/.target
**/.project
**/.classpath


# PDT-specific
.buildpath
Expand Down
28 changes: 0 additions & 28 deletions .project

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -20,4 +20,4 @@ before_script:

script:
# - mvn -e -B clean install && cd hapi-fhir-ra && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID clean test jacoco:report coveralls:report
- mvn -Dci=true -e -B -P ALLMODULES,NOPARALLEL clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report
- mvn -Dci=true -e -B -P ALLMODULES,NOPARALLEL,ERRORPRONE clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report
8 changes: 8 additions & 0 deletions HELPWANTED.md
@@ -0,0 +1,8 @@
# Help Wanted

This page is a work in progress!

It serves as a place to list potential help a new volunteer could offer.

* Investigate adding support for FHIR's RDF (Turtle) encoding to HAPI

Expand Up @@ -5,6 +5,7 @@
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.3-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

<packaging>jar</packaging>
Expand All @@ -26,25 +27,40 @@
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>3.0</version>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-guice</artifactId>
<version>1.18.1</version>
<version>1.19.1</version>
</dependency>
<dependency>
<groupId>org.ebaysf.web</groupId>
<artifactId>cors-filter</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>1.2</version>
<version>2.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.7.21</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand All @@ -56,5 +72,5 @@
</plugin>
</plugins>
</build>
</project>

</project>
@@ -0,0 +1,27 @@
package embedded;

import javax.inject.Singleton;

import org.ebaysf.web.cors.CORSFilter;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceServletContextListener;
import com.sun.jersey.guice.JerseyServletModule;

public class ContextListener extends GuiceServletContextListener {

@Override
protected Injector getInjector() {

return Guice.createInjector(new JerseyServletModule() {

@Override
protected void configureServlets() {
bind(CORSFilter.class).in(Singleton.class);
filter("/*").through(CORSFilter.class);
serve("/model/*").with(FhirRestfulServlet.class);
}
});
}
}
Expand Up @@ -6,8 +6,6 @@
import javax.inject.Singleton;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.narrative.INarrativeGenerator;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
Expand All @@ -29,29 +27,10 @@ public FhirRestfulServlet() {
*/
@Override
public void initialize() {
/*
* Two resource providers are defined. Each one handles a specific type
* of resource.
*/
final List<IResourceProvider> providers = new ArrayList<IResourceProvider>();
providers.add(new SomeResourceProvider());
setResourceProviders(providers);

/*
* Use a narrative generator. This is a completely optional step, but
* can be useful as it causes HAPI to generate narratives for resources
* which don't otherwise have one.
*/
final INarrativeGenerator narrativeGen = new DefaultThymeleafNarrativeGenerator();
getFhirContext().setNarrativeGenerator(narrativeGen);

/*
* Tells HAPI to use content types which are not technically FHIR
* compliant when a browser is detected as the requesting client. This
* prevents browsers from trying to download resource responses instead
* of displaying them inline which can be handy for troubleshooting.
*/
setUseBrowserFriendlyContentTypes(true);

registerInterceptor(new ResponseHighlighterInterceptor());

Expand Down
@@ -1,25 +1,32 @@
package embedded;

import java.util.EnumSet;

import javax.servlet.DispatcherType;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.slf4j.bridge.SLF4JBridgeHandler;

import com.google.inject.servlet.GuiceFilter;

public class ServerStartup {

public static void main(final String[] args) throws Exception {

SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();

final Server server = new Server(9090);
final ServletContextHandler sch = new ServletContextHandler(server, "/");
sch.addEventListener(new ContextListener());
sch.addFilter(GuiceFilter.class, "/*",
EnumSet.of(DispatcherType.REQUEST));
sch.addFilter(GuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
sch.addServlet(DefaultServlet.class, "/");
server.start();
server.start();

// Service is now accessible through
// http://localhost:9090/model/Practitioner
}

}
Expand Up @@ -4,6 +4,8 @@

import org.hl7.fhir.instance.model.api.IBaseResource;

import com.google.common.collect.Lists;

import ca.uhn.fhir.model.dstu2.resource.Practitioner;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.rest.annotation.RequiredParam;
Expand All @@ -21,8 +23,9 @@ public Class<? extends IBaseResource> getResourceType() {
@Search()
public List<Practitioner> findPractitionersByName(
@RequiredParam(name = Practitioner.SP_NAME) final StringDt theName) {
throw new UnprocessableEntityException(
"Please provide more than 4 characters for the name");
// throw new UnprocessableEntityException(
// "Please provide more than 4 characters for the name");
return Lists.newArrayList();
}

}
@@ -1,5 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
81 changes: 81 additions & 0 deletions example-projects/hapi-fhir-standalone-overlay-example/pom.xml
@@ -0,0 +1,81 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.3-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
<artifactId>hapi-fhir-standalone-overlay-example</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
</overlay>
</overlays>
<warName>fhirtester</warName>
<failOnMissingWebXml>true</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.3-SNAPSHOT</version>
<type>war</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.3-SNAPSHOT</version>
<classifier>classes</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-guice</artifactId>
<version>1.19.1</version>
</dependency>
<dependency>
<groupId>org.ebaysf.web</groupId>
<artifactId>cors-filter</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>

</project>
@@ -0,0 +1,51 @@
package embedded.example;

import javax.inject.Singleton;
import javax.servlet.ServletContextEvent;

import org.ebaysf.web.cors.CORSFilter;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceServletContextListener;
import com.sun.jersey.guice.JerseyServletModule;

public class ContextListener extends GuiceServletContextListener {

static String username;
static String password;
static String serverAddress;

@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
super.contextInitialized(servletContextEvent);

username = servletContextEvent.getServletContext().getInitParameter("username") != null
? servletContextEvent.getServletContext().getInitParameter("username")
: null;
password = servletContextEvent.getServletContext().getInitParameter("password") != null
? servletContextEvent.getServletContext().getInitParameter("password")
: null;
serverAddress = servletContextEvent.getServletContext().getInitParameter("serverAddress") != null
? servletContextEvent.getServletContext().getInitParameter("serverAddress")
: null;
}

@Override
protected Injector getInjector() {
return Guice.createInjector(new JerseyServletModule() {

@Override
protected void configureServlets() {

AnnotationConfigWebApplicationContext webApp = new AnnotationConfigWebApplicationContext();
webApp.setConfigLocation(FhirTesterConfig.class.getName());
serve("/*").with(new DispatcherServlet(webApp));
bind(CORSFilter.class).in(Singleton.class);
filter("/*").through(CORSFilter.class);
}
});
}
}

0 comments on commit 3bf6555

Please sign in to comment.