Correctly include project description in capabilitystatement

This commit is contained in:
jamesagnew 2018-06-03 16:19:33 -04:00
parent 6d09f5025f
commit 3583dfd503
11 changed files with 180 additions and 122 deletions

View File

@ -96,6 +96,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j_version}</version>
</dependency>
</dependencies>

View File

@ -27,6 +27,8 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.server.method.BaseMethodBinding;
import ca.uhn.fhir.util.VersionUtil;
import static org.apache.commons.lang3.StringUtils.isBlank;
public class RestulfulServerConfiguration {
private Collection<ResourceBinding> resourceBindings;
@ -84,6 +86,9 @@ public class RestulfulServerConfiguration {
* @return the implementationDescription
*/
public String getImplementationDescription() {
if (isBlank(implementationDescription)) {
return "HAPI FHIR";
}
return implementationDescription;
}

View File

@ -116,4 +116,16 @@
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -18,4 +18,16 @@
<module>hapi-fhir-spring-boot-sample-server-jpa</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>
@ -25,4 +25,16 @@
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -14,6 +14,14 @@
<name>HAPI FHIR Structures - DSTU1 (FHIR v0.80)</name>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>

View File

@ -131,7 +131,7 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
for (BaseMethodBinding<?> nextMethodBinding : getServerConfiguration().getServerBindings()) {
String resourceName = "";
if (resourceToMethods.containsKey(resourceName) == false) {
resourceToMethods.put(resourceName, new ArrayList<BaseMethodBinding<?>>());
resourceToMethods.put(resourceName, new ArrayList<>());
}
resourceToMethods.get(resourceName).add(nextMethodBinding);
}
@ -618,8 +618,9 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
* See the class documentation for an important note if you are extending this class
* </p>
*/
public void setCache(boolean theCache) {
public ServerCapabilityStatementProvider setCache(boolean theCache) {
myCache = theCache;
return this;
}
@Override

View File

@ -25,6 +25,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
import org.hl7.fhir.dstu3.hapi.rest.server.ServerCapabilityStatementProvider;
import org.hl7.fhir.dstu3.model.CapabilityStatement;
import org.hl7.fhir.dstu3.model.Patient;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -45,6 +46,11 @@ public class MetadataCapabilityStatementDstu3Test {
private static Server ourServer;
private static RestfulServer ourServlet;
@After
public void after() {
ourServlet.setServerAddressStrategy(new IncomingRequestAddressStrategy());
}
@Test
public void testElements() throws Exception {
String output;
@ -124,8 +130,6 @@ public class MetadataCapabilityStatementDstu3Test {
@Test
public void testResponseContainsBaseUrlFixed() throws Exception {
IServerAddressStrategy addressStrategy = ourServlet.getServerAddressStrategy();
try {
ourServlet.setServerAddressStrategy(new HardcodedServerAddressStrategy("http://foo/bar"));
String output;
@ -142,9 +146,6 @@ public class MetadataCapabilityStatementDstu3Test {
} finally {
IOUtils.closeQuietly(status.getEntity().getContent());
}
} finally {
ourServlet.setServerAddressStrategy(addressStrategy);
}
}
@Test
@ -197,7 +198,7 @@ public class MetadataCapabilityStatementDstu3Test {
ourServlet = new RestfulServer(ourCtx);
ourServlet.setResourceProviders(patientProvider);
ourServlet.setServerConformanceProvider(new ServerCapabilityStatementProvider(ourServlet));
ourServlet.setServerConformanceProvider(new ServerCapabilityStatementProvider(ourServlet).setCache(false));
ServletHolder servletHolder = new ServletHolder(ourServlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");

12
pom.xml
View File

@ -515,6 +515,7 @@
<plexus_compiler_api_version>2.8.4</plexus_compiler_api_version>
<servicemix_saxon_version>9.5.1-5_1</servicemix_saxon_version>
<servicemix_xmlresolver_version>1.2_5</servicemix_xmlresolver_version>
<slf4j_version>1.7.25</slf4j_version>
<spring_version>5.0.6.RELEASE</spring_version>
<spring_data_version>2.0.7.RELEASE</spring_data_version>
@ -1108,17 +1109,17 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-android</artifactId>
<version>1.7.25</version>
<version>${slf4j_version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<version>${slf4j_version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.25</version>
<version>${slf4j_version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@ -1216,6 +1217,11 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>