Version bumps

This commit is contained in:
jamesagnew 2018-06-03 15:28:58 -04:00
parent e36bc3889c
commit 987679483a
11 changed files with 1363 additions and 1244 deletions

View File

@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.dao;
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.dao;
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,34 +1,46 @@
<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>
<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>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hapi-fhir-spring-boot</artifactId>
<packaging>pom</packaging>
<modules>
<module>hapi-fhir-spring-boot-autoconfigure</module>
<module>hapi-fhir-spring-boot-starter</module>
<module>hapi-fhir-spring-boot-samples</module>
</modules>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hapi-fhir-spring-boot</artifactId>
<packaging>pom</packaging>
<modules>
<module>hapi-fhir-spring-boot-autoconfigure</module>
<module>hapi-fhir-spring-boot-starter</module>
<module>hapi-fhir-spring-boot-samples</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>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -24,10 +24,12 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.Callable;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.dstu2016may.model.*;
import org.hl7.fhir.dstu2016may.model.Conformance.*;
@ -64,21 +66,27 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
private IdentityHashMap<OperationMethodBinding, String> myOperationBindingToName;
private HashMap<String, List<OperationMethodBinding>> myOperationNameToBindings;
private String myPublisher = "Not provided";
private RestulfulServerConfiguration myServerConfiguration;
private Callable<RestulfulServerConfiguration> myServerConfiguration;
/*
* Add a no-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
/**
* No-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
*/
public ServerConformanceProvider() {
super();
}
/**
* Constructor
*/
public ServerConformanceProvider(RestfulServer theRestfulServer) {
this.myServerConfiguration = theRestfulServer.createConfiguration();
this.myServerConfiguration = theRestfulServer::createConfiguration;
}
/**
* Constructor
*/
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
this.myServerConfiguration = theServerConfiguration;
this.myServerConfiguration = () -> theServerConfiguration;
}
private void checkBindingForSystemOps(ConformanceRestComponent rest, Set<SystemRestfulInteraction> systemOps, BaseMethodBinding<?> nextMethodBinding) {
@ -103,20 +111,20 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
}
private Map<String, List<BaseMethodBinding<?>>> collectMethodBindings() {
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = new TreeMap<String, List<BaseMethodBinding<?>>>();
for (ResourceBinding next : myServerConfiguration.getResourceBindings()) {
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = new TreeMap<>();
for (ResourceBinding next : getServerConfiguration().getResourceBindings()) {
String resourceName = next.getResourceName();
for (BaseMethodBinding<?> nextMethodBinding : next.getMethodBindings()) {
if (resourceToMethods.containsKey(resourceName) == false) {
resourceToMethods.put(resourceName, new ArrayList<BaseMethodBinding<?>>());
resourceToMethods.put(resourceName, new ArrayList<>());
}
resourceToMethods.get(resourceName).add(nextMethodBinding);
}
}
for (BaseMethodBinding<?> nextMethodBinding : myServerConfiguration.getServerBindings()) {
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);
}
@ -124,7 +132,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
}
private DateTimeType conformanceDate() {
String buildDate = myServerConfiguration.getConformanceDate();
String buildDate = getServerConfiguration().getConformanceDate();
if (buildDate != null) {
try {
return new DateTimeType(buildDate);
@ -181,15 +189,15 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
// needs to be modified to actually allow it
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
String serverBase = getServerConfiguration().getServerAddressStrategy().determineServerBase(servletContext, theRequest);
retVal
.getImplementation()
.setUrl(serverBase)
.setDescription(myServerConfiguration.getImplementationDescription());
.setDescription(getServerConfiguration().getImplementationDescription());
retVal.setKind(ConformanceStatementKind.INSTANCE);
retVal.getSoftware().setName(myServerConfiguration.getServerName());
retVal.getSoftware().setVersion(myServerConfiguration.getServerVersion());
retVal.getSoftware().setName(getServerConfiguration().getServerName());
retVal.getSoftware().setVersion(getServerConfiguration().getServerVersion());
retVal.addFormat(Constants.CT_FHIR_XML);
retVal.addFormat(Constants.CT_FHIR_JSON);
retVal.setStatus(ConformanceResourceStatus.ACTIVE);
@ -197,17 +205,17 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
ConformanceRestComponent rest = retVal.addRest();
rest.setMode(RestfulConformanceMode.SERVER);
Set<SystemRestfulInteraction> systemOps = new HashSet<SystemRestfulInteraction>();
Set<String> operationNames = new HashSet<String>();
Set<SystemRestfulInteraction> systemOps = new HashSet<>();
Set<String> operationNames = new HashSet<>();
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = collectMethodBindings();
for (Entry<String, List<BaseMethodBinding<?>>> nextEntry : resourceToMethods.entrySet()) {
if (nextEntry.getKey().isEmpty() == false) {
Set<TypeRestfulInteraction> resourceOps = new HashSet<TypeRestfulInteraction>();
Set<TypeRestfulInteraction> resourceOps = new HashSet<>();
ConformanceRestResourceComponent resource = rest.addResource();
String resourceName = nextEntry.getKey();
RuntimeResourceDefinition def = myServerConfiguration.getFhirContext().getResourceDefinition(resourceName);
RuntimeResourceDefinition def = getServerConfiguration().getFhirContext().getResourceDefinition(resourceName);
resource.getTypeElement().setValue(def.getName());
resource.getProfile().setReference((def.getResourceProfile(serverBase)));
@ -432,7 +440,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode());
}
for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) {
RuntimeResourceDefinition targetDef = myServerConfiguration.getFhirContext().getResourceDefinition(nextTarget);
RuntimeResourceDefinition targetDef = getServerConfiguration().getFhirContext().getResourceDefinition(nextTarget);
if (targetDef != null) {
ResourceType code;
try {
@ -594,11 +602,15 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
@Override
public void setRestfulServer(RestfulServer theRestfulServer) {
myServerConfiguration = theRestfulServer.createConfiguration();
myServerConfiguration = theRestfulServer::createConfiguration;
}
RestulfulServerConfiguration getServerConfiguration() {
return myServerConfiguration;
try {
return myServerConfiguration.call();
} catch (Exception e) {
throw new InternalErrorException(e);
}
}
private void sortRuntimeSearchParameters(List<RuntimeSearchParam> searchParameters) {

View File

@ -1,6 +1,45 @@
package ca.uhn.fhir.rest.server.provider.dstu2;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.model.dstu2.resource.Conformance;
import ca.uhn.fhir.model.dstu2.resource.Conformance.Rest;
import ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource;
import ca.uhn.fhir.model.dstu2.resource.Conformance.RestResourceInteraction;
import ca.uhn.fhir.model.dstu2.resource.Conformance.RestResourceSearchParam;
import ca.uhn.fhir.model.dstu2.resource.OperationDefinition;
import ca.uhn.fhir.model.dstu2.resource.OperationDefinition.Parameter;
import ca.uhn.fhir.model.dstu2.valueset.*;
import ca.uhn.fhir.model.primitive.DateTimeDt;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Initialize;
import ca.uhn.fhir.rest.annotation.Metadata;
import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.server.IServerConformanceProvider;
import ca.uhn.fhir.rest.server.ResourceBinding;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.RestulfulServerConfiguration;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.method.*;
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IBaseResource;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.Callable;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
/*
* #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0)
@ -10,9 +49,9 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,39 +59,10 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.util.*;
import java.util.Map.Entry;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import ca.uhn.fhir.context.FhirVersionEnum;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.model.dstu2.resource.Conformance;
import ca.uhn.fhir.model.dstu2.resource.Conformance.*;
import ca.uhn.fhir.model.dstu2.resource.OperationDefinition;
import ca.uhn.fhir.model.dstu2.resource.OperationDefinition.Parameter;
import ca.uhn.fhir.model.dstu2.valueset.*;
import ca.uhn.fhir.model.primitive.DateTimeDt;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.annotation.*;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.server.*;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.method.*;
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
/**
* Server FHIR Provider which serves the conformance statement for a RESTful server implementation
*
*
* <p>
* Note: This class is safe to extend, but it is important to note that the same instance of {@link Conformance} is always returned unless {@link #setCache(boolean)} is called with a value of
* <code>false</code>. This means that if you are adding anything to the returned conformance instance on each call you should call <code>setCache(false)</code> in your provider constructor.
@ -65,25 +75,27 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
private IdentityHashMap<OperationMethodBinding, String> myOperationBindingToName;
private HashMap<String, List<OperationMethodBinding>> myOperationNameToBindings;
private String myPublisher = "Not provided";
private RestulfulServerConfiguration myServerConfiguration;
private Callable<RestulfulServerConfiguration> myServerConfiguration;
public ServerConformanceProvider(RestfulServer theRestfulServer) {
this.myServerConfiguration = theRestfulServer.createConfiguration();
}
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
this.myServerConfiguration = theServerConfiguration;
}
/*
* Add a no-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
/**
* No-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
*/
public ServerConformanceProvider() {
super();
}
public void setRestfulServer(RestfulServer theRestfulServer) {
myServerConfiguration = theRestfulServer.createConfiguration();
/**
* Constructor
*/
public ServerConformanceProvider(RestfulServer theRestfulServer) {
this.myServerConfiguration = theRestfulServer::createConfiguration;
}
/**
* Constructor
*/
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
this.myServerConfiguration = () -> theServerConfiguration;
}
private void checkBindingForSystemOps(Rest rest, Set<SystemRestfulInteractionEnum> systemOps, BaseMethodBinding<?> nextMethodBinding) {
@ -104,7 +116,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
private Map<String, List<BaseMethodBinding<?>>> collectMethodBindings() {
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = new TreeMap<String, List<BaseMethodBinding<?>>>();
for (ResourceBinding next : myServerConfiguration.getResourceBindings()) {
for (ResourceBinding next : getServerConfiguration().getResourceBindings()) {
String resourceName = next.getResourceName();
for (BaseMethodBinding<?> nextMethodBinding : next.getMethodBindings()) {
if (resourceToMethods.containsKey(resourceName) == false) {
@ -113,7 +125,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
resourceToMethods.get(resourceName).add(nextMethodBinding);
}
}
for (BaseMethodBinding<?> nextMethodBinding : myServerConfiguration.getServerBindings()) {
for (BaseMethodBinding<?> nextMethodBinding : getServerConfiguration().getServerBindings()) {
String resourceName = "";
if (resourceToMethods.containsKey(resourceName) == false) {
resourceToMethods.put(resourceName, new ArrayList<BaseMethodBinding<?>>());
@ -123,6 +135,18 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
return resourceToMethods;
}
private DateTimeDt conformanceDate() {
String buildDate = getServerConfiguration().getConformanceDate();
if (buildDate != null) {
try {
return new DateTimeDt(buildDate);
} catch (DataFormatException e) {
// fall through
}
}
return DateTimeDt.withCurrentTime();
}
private String createOperationName(OperationMethodBinding theMethodBinding) {
StringBuilder retVal = new StringBuilder();
if (theMethodBinding.getResourceName() != null) {
@ -137,10 +161,10 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
retVal.append('s');
}
retVal.append('-');
// Exclude the leading $
retVal.append(theMethodBinding.getName(), 1, theMethodBinding.getName().length());
return retVal.toString();
}
@ -152,6 +176,22 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
return myPublisher;
}
/**
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
*/
public void setPublisher(String thePublisher) {
myPublisher = thePublisher;
}
RestulfulServerConfiguration getServerConfiguration() {
try {
return myServerConfiguration.call();
} catch (Exception e) {
throw new InternalErrorException(e);
}
}
@Override
@Metadata
public Conformance getServerConformance(HttpServletRequest theRequest) {
@ -168,36 +208,36 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
// needs to be modified to actually allow it
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
String serverBase = getServerConfiguration().getServerAddressStrategy().determineServerBase(servletContext, theRequest);
retVal
.getImplementation()
.setUrl(serverBase)
.setDescription(myServerConfiguration.getImplementationDescription());
.setDescription(getServerConfiguration().getImplementationDescription());
retVal.setKind(ConformanceStatementKindEnum.INSTANCE);
retVal.getSoftware().setName(myServerConfiguration.getServerName());
retVal.getSoftware().setVersion(myServerConfiguration.getServerVersion());
retVal.getSoftware().setName(getServerConfiguration().getServerName());
retVal.getSoftware().setVersion(getServerConfiguration().getServerVersion());
retVal.addFormat(Constants.CT_FHIR_XML);
retVal.addFormat(Constants.CT_FHIR_JSON);
Rest rest = retVal.addRest();
rest.setMode(RestfulConformanceModeEnum.SERVER);
Set<SystemRestfulInteractionEnum> systemOps = new HashSet<SystemRestfulInteractionEnum>();
Set<String> operationNames = new HashSet<String>();
Set<SystemRestfulInteractionEnum> systemOps = new HashSet<>();
Set<String> operationNames = new HashSet<>();
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = collectMethodBindings();
for (Entry<String, List<BaseMethodBinding<?>>> nextEntry : resourceToMethods.entrySet()) {
if (nextEntry.getKey().isEmpty() == false) {
Set<TypeRestfulInteractionEnum> resourceOps = new HashSet<TypeRestfulInteractionEnum>();
Set<TypeRestfulInteractionEnum> resourceOps = new HashSet<>();
RestResource resource = rest.addResource();
String resourceName = nextEntry.getKey();
RuntimeResourceDefinition def = myServerConfiguration.getFhirContext().getResourceDefinition(resourceName);
RuntimeResourceDefinition def = getServerConfiguration().getFhirContext().getResourceDefinition(resourceName);
resource.getTypeElement().setValue(def.getName());
resource.getProfile().setReference(new IdDt(def.getResourceProfile(serverBase)));
TreeSet<String> includes = new TreeSet<String>();
TreeSet<String> includes = new TreeSet<>();
// Map<String, Conformance.RestResourceSearchParam> nameToSearchParam = new HashMap<String,
// Conformance.RestResourceSearchParam>();
@ -222,21 +262,21 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
if (nextMethodBinding.isSupportsConditional()) {
switch (resOp) {
case CREATE:
resource.setConditionalCreate(true);
break;
case DELETE:
if (nextMethodBinding.isSupportsConditionalMultiple()) {
resource.setConditionalDelete(ConditionalDeleteStatusEnum.MULTIPLE_DELETES_SUPPORTED);
} else {
resource.setConditionalDelete(ConditionalDeleteStatusEnum.SINGLE_DELETES_SUPPORTED);
}
break;
case UPDATE:
resource.setConditionalUpdate(true);
break;
default:
break;
case CREATE:
resource.setConditionalCreate(true);
break;
case DELETE:
if (nextMethodBinding.isSupportsConditionalMultiple()) {
resource.setConditionalDelete(ConditionalDeleteStatusEnum.MULTIPLE_DELETES_SUPPORTED);
} else {
resource.setConditionalDelete(ConditionalDeleteStatusEnum.SINGLE_DELETES_SUPPORTED);
}
break;
case UPDATE:
resource.setConditionalUpdate(true);
break;
default:
break;
}
}
}
@ -299,18 +339,6 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
return retVal;
}
private DateTimeDt conformanceDate() {
String buildDate = myServerConfiguration.getConformanceDate();
if (buildDate != null) {
try {
return new DateTimeDt(buildDate);
} catch (DataFormatException e) {
// fall through
}
}
return DateTimeDt.withCurrentTime();
}
private void handleDynamicSearchMethodBinding(RestResource resource, RuntimeResourceDefinition def, TreeSet<String> includes, DynamicSearchMethodBinding searchMethodBinding) {
includes.addAll(searchMethodBinding.getIncludes());
@ -424,7 +452,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode());
}
for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) {
RuntimeResourceDefinition targetDef = myServerConfiguration.getFhirContext().getResourceDefinition(nextTarget);
RuntimeResourceDefinition targetDef = getServerConfiguration().getFhirContext().getResourceDefinition(nextTarget);
if (targetDef != null) {
ResourceTypeEnum code = ResourceTypeEnum.VALUESET_BINDER.fromCodeString(targetDef.getName());
if (code != null) {
@ -537,7 +565,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
op.setName(op.getCode());
}
}
if (op.getSystem() == null) {
op.setSystem(false);
}
@ -558,12 +586,9 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
myCache = theCache;
}
/**
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
*/
public void setPublisher(String thePublisher) {
myPublisher = thePublisher;
@Override
public void setRestfulServer(RestfulServer theRestfulServer) {
myServerConfiguration = theRestfulServer::createConfiguration;
}
private void sortRuntimeSearchParameters(List<RuntimeSearchParam> searchParameters) {
@ -589,4 +614,5 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
}
});
}
}

View File

@ -122,6 +122,31 @@ public class MetadataCapabilityStatementDstu3Test {
}
}
@Test
public void testResponseContainsBaseUrlFixed() throws Exception {
IServerAddressStrategy addressStrategy = ourServlet.getServerAddressStrategy();
try {
ourServlet.setServerAddressStrategy(new HardcodedServerAddressStrategy("http://foo/bar"));
String output;
HttpRequestBase httpPost = new HttpGet("http://localhost:" + ourPort + "/metadata?_format=json");
CloseableHttpResponse status = ourClient.execute(httpPost);
try {
output = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
assertEquals(200, status.getStatusLine().getStatusCode());
ourLog.info(output);
CapabilityStatement cs = ourCtx.newJsonParser().parseResource(CapabilityStatement.class, output);
assertEquals("http://foo/bar", cs.getImplementation().getUrl());
} finally {
IOUtils.closeQuietly(status.getEntity().getContent());
}
} finally {
ourServlet.setServerAddressStrategy(addressStrategy);
}
}
@Test
public void testSummary() throws Exception {
String output;

View File

@ -24,12 +24,14 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.text.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.Callable;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.*;
import org.hl7.fhir.instance.model.Conformance.*;
@ -69,33 +71,40 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
private IdentityHashMap<OperationMethodBinding, String> myOperationBindingToName;
private HashMap<String, List<OperationMethodBinding>> myOperationNameToBindings;
private String myPublisher = "Not provided";
private RestulfulServerConfiguration myServerConfiguration;
private Callable<RestulfulServerConfiguration> myServerConfiguration;
public ServerConformanceProvider(RestfulServer theRestfulServer) {
this.myServerConfiguration = theRestfulServer.createConfiguration();
}
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
this.myServerConfiguration = theServerConfiguration;
/**
* No-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
*/
public ServerConformanceProvider() {
super();
}
/**
* Constructor
*/
public ServerConformanceProvider(RestfulServer theRestfulServer) {
this.myServerConfiguration = theRestfulServer::createConfiguration;
}
/**
* Constructor
*/
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
this.myServerConfiguration = () -> theServerConfiguration;
}
/*
* Add a no-arg constructor and seetter so that the
* ServerConfirmanceProvider can be Spring-wired with
* the RestfulService avoiding the potential reference
* cycle that would happen.
*/
public ServerConformanceProvider () {
super();
}
@Override
public void setRestfulServer (RestfulServer theRestfulServer) {
myServerConfiguration = theRestfulServer.createConfiguration();
myServerConfiguration = theRestfulServer::createConfiguration;
}
RestulfulServerConfiguration getServerConfiguration() {
return myServerConfiguration;
try {
return myServerConfiguration.call();
} catch (Exception e) {
throw new InternalErrorException(e);
}
}
private void checkBindingForSystemOps(ConformanceRestComponent rest, Set<SystemRestfulInteraction> systemOps,
@ -122,7 +131,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
private Map<String, List<BaseMethodBinding<?>>> collectMethodBindings() {
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = new TreeMap<String, List<BaseMethodBinding<?>>>();
for (ResourceBinding next : myServerConfiguration.getResourceBindings()) {
for (ResourceBinding next : getServerConfiguration().getResourceBindings()) {
String resourceName = next.getResourceName();
for (BaseMethodBinding<?> nextMethodBinding : next.getMethodBindings()) {
if (resourceToMethods.containsKey(resourceName) == false) {
@ -131,7 +140,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
resourceToMethods.get(resourceName).add(nextMethodBinding);
}
}
for (BaseMethodBinding<?> nextMethodBinding : myServerConfiguration.getServerBindings()) {
for (BaseMethodBinding<?> nextMethodBinding : getServerConfiguration().getServerBindings()) {
String resourceName = "";
if (resourceToMethods.containsKey(resourceName) == false) {
resourceToMethods.put(resourceName, new ArrayList<BaseMethodBinding<?>>());
@ -171,16 +180,10 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
retVal.setAcceptUnknown(UnknownContentCode.EXTENSIONS); // TODO: make this configurable - this is a fairly big effort since the parser
// needs to be modified to actually allow it
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
retVal
.getImplementation()
.setUrl(serverBase)
.setDescription(myServerConfiguration.getImplementationDescription());
retVal.getImplementation().setDescription(getServerConfiguration().getImplementationDescription());
retVal.setKind(ConformanceStatementKind.INSTANCE);
retVal.getSoftware().setName(myServerConfiguration.getServerName());
retVal.getSoftware().setVersion(myServerConfiguration.getServerVersion());
retVal.getSoftware().setName(getServerConfiguration().getServerName());
retVal.getSoftware().setVersion(getServerConfiguration().getServerVersion());
retVal.addFormat(Constants.CT_FHIR_XML);
retVal.addFormat(Constants.CT_FHIR_JSON);
@ -197,8 +200,10 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
Set<TypeRestfulInteraction> resourceOps = new HashSet<TypeRestfulInteraction>();
ConformanceRestResourceComponent resource = rest.addResource();
String resourceName = nextEntry.getKey();
RuntimeResourceDefinition def = myServerConfiguration.getFhirContext().getResourceDefinition(resourceName);
RuntimeResourceDefinition def = getServerConfiguration().getFhirContext().getResourceDefinition(resourceName);
resource.getTypeElement().setValue(def.getName());
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
String serverBase = getServerConfiguration().getServerAddressStrategy().determineServerBase(servletContext, theRequest);
resource.getProfile().setReference((def.getResourceProfile(serverBase)));
TreeSet<String> includes = new TreeSet<>();
@ -266,7 +271,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
}
}
resource.getInteraction().sort(new Comparator<ResourceInteractionComponent>() {
Collections.sort(resource.getInteraction(), new Comparator<ResourceInteractionComponent>() {
@Override
public int compare(ResourceInteractionComponent theO1, ResourceInteractionComponent theO2) {
TypeRestfulInteraction o1 = theO1.getCode();
@ -309,7 +314,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
}
private DateTimeType conformanceDate() {
String buildDate = myServerConfiguration.getConformanceDate();
String buildDate = getServerConfiguration().getConformanceDate();
if (buildDate != null) {
try {
return new DateTimeType(buildDate);
@ -430,7 +435,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode());
}
for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) {
RuntimeResourceDefinition targetDef = myServerConfiguration.getFhirContext().getResourceDefinition(nextTarget);
RuntimeResourceDefinition targetDef = getServerConfiguration().getFhirContext().getResourceDefinition(nextTarget);
if (targetDef != null) {
ResourceType code;
try {
@ -449,8 +454,8 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
@Initialize
public void initializeOperations() {
myOperationBindingToName = new IdentityHashMap<OperationMethodBinding, String>();
myOperationNameToBindings = new HashMap<String, List<OperationMethodBinding>>();
myOperationBindingToName = new IdentityHashMap<>();
myOperationNameToBindings = new HashMap<>();
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = collectMethodBindings();
for (Entry<String, List<BaseMethodBinding<?>>> nextEntry : resourceToMethods.entrySet()) {
@ -465,7 +470,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
String name = createOperationName(methodBinding);
myOperationBindingToName.put(methodBinding, name);
if (myOperationNameToBindings.containsKey(name) == false) {
myOperationNameToBindings.put(name, new ArrayList<OperationMethodBinding>());
myOperationNameToBindings.put(name, new ArrayList<>());
}
myOperationNameToBindings.get(name).add(methodBinding);
}
@ -487,8 +492,8 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
op.setStatus(ConformanceResourceStatus.ACTIVE);
op.setIdempotent(true);
Set<String> inParams = new HashSet<String>();
Set<String> outParams = new HashSet<String>();
Set<String> inParams = new HashSet<>();
Set<String> outParams = new HashSet<>();
for (OperationMethodBinding sharedDescription : sharedDescriptions) {
if (isNotBlank(sharedDescription.getDescription())) {

27
pom.xml
View File

@ -482,8 +482,8 @@
<apache_karaf_version>4.1.4</apache_karaf_version>
<aries_spifly_version>1.0.10</aries_spifly_version>
<caffeine_version>2.6.2</caffeine_version>
<commons_codec_version>1.10</commons_codec_version>
<commons_io_version>2.5</commons_io_version>
<commons_codec_version>1.11</commons_codec_version>
<commons_io_version>2.6</commons_io_version>
<commons_lang3_version>3.7</commons_lang3_version>
<derby_version>10.14.2.0</derby_version>
<error_prone_annotations_version>2.0.18</error_prone_annotations_version>
@ -508,6 +508,7 @@
<resteasy_version>4.0.0.Beta3</resteasy_version>
<ph_schematron_version>5.0.4</ph_schematron_version>
<ph_commons_version>9.1.1</ph_commons_version>
<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>
<spring_version>5.0.6.RELEASE</spring_version>
@ -906,17 +907,17 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-api</artifactId>
<version>2.8.2</version>
<version>${plexus_compiler_api_version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<version>2.8.2</version>
<version>${plexus_compiler_api_version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>2.8.4</version>
<version>${plexus_compiler_api_version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@ -1180,13 +1181,6 @@
<artifactId>spring-websocket</artifactId>
<version>${spring_version}</version>
</dependency>
<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>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
@ -1292,17 +1286,17 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-api</artifactId>
<version>2.8.4</version>
<version>${plexus_compiler_api_version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<version>2.8.4</version>
<version>${plexus_compiler_api_version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>2.8.4</version>
<version>${plexus_compiler_api_version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@ -1411,6 +1405,9 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.5</version>
<configuration>
<processDependencyManagementTransitive>false</processDependencyManagementTransitive>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>

View File

@ -21,6 +21,8 @@
<li>Hibernate OR (JPA): 5.2.16.Final -&gt; 5.3.1.Final</li>
<li>Hibernate Search (JPA): 5.7.1.Final -&gt; 5.10.1.Final</li>
<li>Jetty (CLI): 9.4.8.v20171121 -&gt; 9.4.10.v20180503</li>
<li>Commons-Codec (All): 1.10 -&gt; 1.11</li>
<li>Commons-IO (All): 2.5 -&gt; 2.6</li>
</ul>
]]>
</action>