Revert IFhirVersion method signature changes for #520
This commit is contained in:
parent
43adae1d01
commit
ab17ee68a3
|
@ -74,7 +74,7 @@ public class GenericClientDstu3IT {
|
|||
}
|
||||
|
||||
private String expectedUserAgent() {
|
||||
return "HAPI-FHIR/" + VersionUtil.getVersion() + " (FHIR Client; FHIR " + FhirVersionEnum.DSTU3.getVersionImplementation().getVersionString() + "/DSTU3; okhttp/3.4.1)";
|
||||
return "HAPI-FHIR/" + VersionUtil.getVersion() + " (FHIR Client; FHIR " + FhirVersionEnum.DSTU3.getFhirVersionString() + "/DSTU3; okhttp/3.4.1)";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ca.uhn.fhir.context;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
@ -34,28 +36,34 @@ public enum FhirVersionEnum {
|
|||
* ***********************
|
||||
*/
|
||||
|
||||
DSTU1("ca.uhn.fhir.model.dstu.FhirDstu1", null, false),
|
||||
DSTU1("ca.uhn.fhir.model.dstu.FhirDstu1", null, false, new Version("0.0.82")),
|
||||
|
||||
DSTU2("ca.uhn.fhir.model.dstu2.FhirDstu2", null, false),
|
||||
DSTU2("ca.uhn.fhir.model.dstu2.FhirDstu2", null, false, new Version("1.0.2")),
|
||||
|
||||
DSTU2_HL7ORG("org.hl7.fhir.instance.FhirDstu2Hl7Org", DSTU2, true),
|
||||
DSTU2_HL7ORG("org.hl7.fhir.instance.FhirDstu2Hl7Org", DSTU2, true, new Version("1.0.2")),
|
||||
|
||||
DSTU2_1("org.hl7.fhir.dstu2016may.hapi.ctx.FhirDstu2_1", null, true),
|
||||
DSTU2_1("org.hl7.fhir.dstu2016may.hapi.ctx.FhirDstu2_1", null, true, new Version("1.4.0")),
|
||||
|
||||
DSTU3("org.hl7.fhir.dstu3.hapi.ctx.FhirDstu3", null, true);
|
||||
DSTU3("org.hl7.fhir.dstu3.hapi.ctx.FhirDstu3", null, true, new Dstu3Version());
|
||||
|
||||
private final FhirVersionEnum myEquivalent;
|
||||
private final boolean myIsRi;
|
||||
private volatile Boolean myPresentOnClasspath;
|
||||
private final String myVersionClass;
|
||||
private volatile IFhirVersion myVersionImplementation;
|
||||
private String myFhirVersionString;
|
||||
|
||||
FhirVersionEnum(String theVersionClass, FhirVersionEnum theEquivalent, boolean theIsRi) {
|
||||
FhirVersionEnum(String theVersionClass, FhirVersionEnum theEquivalent, boolean theIsRi, IVersionProvider theVersionExtractor) {
|
||||
myVersionClass = theVersionClass;
|
||||
myEquivalent = theEquivalent;
|
||||
myFhirVersionString = theVersionExtractor.provideVersion();
|
||||
myIsRi = theIsRi;
|
||||
}
|
||||
|
||||
public String getFhirVersionString() {
|
||||
return myFhirVersionString;
|
||||
}
|
||||
|
||||
public IFhirVersion getVersionImplementation() {
|
||||
if (!isPresentOnClasspath()) {
|
||||
throw new IllegalStateException("Version " + name() + " is not present on classpath");
|
||||
|
@ -93,12 +101,12 @@ public enum FhirVersionEnum {
|
|||
*/
|
||||
public boolean isPresentOnClasspath() {
|
||||
Boolean retVal = myPresentOnClasspath;
|
||||
if (retVal==null) {
|
||||
if (retVal == null) {
|
||||
try {
|
||||
Class.forName(myVersionClass);
|
||||
retVal= true;
|
||||
retVal = true;
|
||||
} catch (Exception e) {
|
||||
retVal= false;
|
||||
retVal = false;
|
||||
}
|
||||
myPresentOnClasspath = retVal;
|
||||
}
|
||||
|
@ -112,4 +120,44 @@ public enum FhirVersionEnum {
|
|||
return myIsRi;
|
||||
}
|
||||
|
||||
private static class Version implements IVersionProvider {
|
||||
|
||||
public Version(String theVersion) {
|
||||
super();
|
||||
myVersion = theVersion;
|
||||
}
|
||||
|
||||
private String myVersion;
|
||||
|
||||
@Override
|
||||
public String provideVersion() {
|
||||
return myVersion;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private interface IVersionProvider {
|
||||
String provideVersion();
|
||||
}
|
||||
|
||||
private static class Dstu3Version implements IVersionProvider {
|
||||
|
||||
public Dstu3Version() {
|
||||
try {
|
||||
Class<?> c = Class.forName("org.hl7.fhir.dstu3.model.Constants");
|
||||
myVersion = (String) c.getDeclaredField("VERSION").get(null);
|
||||
} catch (Exception e) {
|
||||
myVersion = "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
private String myVersion;
|
||||
|
||||
@Override
|
||||
public String provideVersion() {
|
||||
return myVersion;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,8 +62,6 @@ public interface IFhirVersion {
|
|||
|
||||
FhirVersionEnum getVersion();
|
||||
|
||||
String getVersionString();
|
||||
|
||||
IVersionSpecificBundleFactory newBundleFactory(FhirContext theContext);
|
||||
|
||||
IBase newCodingDt();
|
||||
|
|
|
@ -30,7 +30,7 @@ public class HttpClientUtil {
|
|||
b.append("HAPI-FHIR/");
|
||||
b.append(VersionUtil.getVersion());
|
||||
b.append(" (FHIR Client; FHIR ");
|
||||
b.append(theContext.getVersion().getVersionString());
|
||||
b.append(theContext.getVersion().getVersion().getFhirVersionString());
|
||||
b.append('/');
|
||||
b.append(theContext.getVersion().getVersion().name());
|
||||
b.append("; ");
|
||||
|
|
|
@ -30,8 +30,16 @@ import java.lang.annotation.Annotation;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.jar.Manifest;
|
||||
|
@ -42,7 +50,6 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
@ -72,7 +79,11 @@ import ca.uhn.fhir.rest.server.interceptor.ExceptionHandlingInterceptor;
|
|||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.*;
|
||||
import ca.uhn.fhir.util.CoverageIgnore;
|
||||
import ca.uhn.fhir.util.ReflectionUtil;
|
||||
import ca.uhn.fhir.util.UrlPathTokenizer;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
import ca.uhn.fhir.util.VersionUtil;
|
||||
|
||||
public class RestfulServer extends HttpServlet implements IRestfulServer<ServletRequestDetails> {
|
||||
|
||||
|
@ -158,7 +169,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
b.append("HAPI FHIR ");
|
||||
b.append(VersionUtil.getVersion());
|
||||
b.append(" REST Server (FHIR Server; FHIR ");
|
||||
b.append(myFhirContext.getVersion().getVersionString());
|
||||
b.append(myFhirContext.getVersion().getVersion().getFhirVersionString());
|
||||
b.append('/');
|
||||
b.append(myFhirContext.getVersion().getVersion().name());
|
||||
b.append(")");
|
||||
|
|
|
@ -759,14 +759,14 @@ public class RestfulServerUtils {
|
|||
if (theContentType.equals(EncodingEnum.JSON_PLAIN_STRING) || theContentType.equals(EncodingEnum.XML_PLAIN_STRING)) {
|
||||
FhirVersionEnum ctxtEnum = theCtx.getVersion().getVersion();
|
||||
myNonLegacy = ctxtEnum.isNewerThan(FhirVersionEnum.DSTU3)
|
||||
|| (ctxtEnum.isEquivalentTo(FhirVersionEnum.DSTU3) && !"1.4.0".equals(theCtx.getVersion().getVersionString()));
|
||||
|| (ctxtEnum.isEquivalentTo(FhirVersionEnum.DSTU3) && !"1.4.0".equals(theCtx.getVersion().getVersion().getFhirVersionString()));
|
||||
} else {
|
||||
myNonLegacy = EncodingEnum.isNonLegacy(theContentType);
|
||||
}
|
||||
} else {
|
||||
FhirVersionEnum ctxtEnum = theCtx.getVersion().getVersion();
|
||||
if (ctxtEnum.isOlderThan(FhirVersionEnum.DSTU3)
|
||||
|| (ctxtEnum.isEquivalentTo(FhirVersionEnum.DSTU3) && "1.4.0".equals(theCtx.getVersion().getVersionString()))) {
|
||||
|| (ctxtEnum.isEquivalentTo(FhirVersionEnum.DSTU3) && "1.4.0".equals(theCtx.getVersion().getVersion().getFhirVersionString()))) {
|
||||
myNonLegacy = null;
|
||||
} else {
|
||||
myNonLegacy = Boolean.TRUE;
|
||||
|
|
|
@ -405,10 +405,4 @@ public class FhirDstu1 implements IFhirVersion {
|
|||
throw new UnsupportedOperationException("FluentPath is not supported in DSTU1 contexts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionString() {
|
||||
return "0.0.82";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -129,11 +129,6 @@ public class FhirDstu2_1 implements IFhirVersion {
|
|||
return FhirVersionEnum.DSTU2_1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionString() {
|
||||
return Constants.VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVersionSpecificBundleFactory newBundleFactory(FhirContext theContext) {
|
||||
return new Dstu2_1BundleFactory(theContext);
|
||||
|
|
|
@ -213,7 +213,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
|
||||
retVal.setPublisher(myPublisher);
|
||||
retVal.setDateElement(conformanceDate());
|
||||
retVal.setFhirVersion(FhirVersionEnum.DSTU2_1.getVersionImplementation().getVersionString());
|
||||
retVal.setFhirVersion(FhirVersionEnum.DSTU2_1.getFhirVersionString());
|
||||
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
|
||||
|
|
|
@ -102,7 +102,7 @@ public class GenericClientDstu2_1Test {
|
|||
}
|
||||
|
||||
private String expectedUserAgent() {
|
||||
return "HAPI-FHIR/" + VersionUtil.getVersion() + " (FHIR Client; FHIR " + FhirVersionEnum.DSTU2_1.getVersionImplementation().getVersionString() + "/DSTU2_1; apache)";
|
||||
return "HAPI-FHIR/" + VersionUtil.getVersion() + " (FHIR Client; FHIR " + FhirVersionEnum.DSTU2_1.getFhirVersionString() + "/DSTU2_1; apache)";
|
||||
}
|
||||
|
||||
private byte[] extractBodyAsByteArray(ArgumentCaptor<HttpUriRequest> capt) throws IOException {
|
||||
|
|
|
@ -110,7 +110,7 @@ public class MetadataConformanceDstu2_1Test {
|
|||
output = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertThat(output, containsString("<Conformance"));
|
||||
assertEquals("HAPI FHIR " + VersionUtil.getVersion() + " REST Server (FHIR Server; FHIR " + FhirVersionEnum.DSTU2_1.getVersionImplementation().getVersionString() + "/DSTU2_1)", status.getFirstHeader("X-Powered-By").getValue());
|
||||
assertEquals("HAPI FHIR " + VersionUtil.getVersion() + " REST Server (FHIR Server; FHIR " + FhirVersionEnum.DSTU2_1.getFhirVersionString() + "/DSTU2_1)", status.getFirstHeader("X-Powered-By").getValue());
|
||||
} finally {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
|
|
|
@ -128,11 +128,6 @@ public class FhirDstu2 implements IFhirVersion {
|
|||
return FhirVersionEnum.DSTU2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionString() {
|
||||
return "1.0.2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVersionSpecificBundleFactory newBundleFactory(FhirContext theContext) {
|
||||
return new Dstu2BundleFactory(theContext);
|
||||
|
|
|
@ -131,11 +131,6 @@ public class FhirDstu3 implements IFhirVersion {
|
|||
return FhirVersionEnum.DSTU3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionString() {
|
||||
return Constants.VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVersionSpecificBundleFactory newBundleFactory(FhirContext theContext) {
|
||||
return new Dstu3BundleFactory(theContext);
|
||||
|
|
|
@ -213,7 +213,7 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
|
||||
retVal.setPublisher(myPublisher);
|
||||
retVal.setDateElement(conformanceDate());
|
||||
retVal.setFhirVersion(FhirVersionEnum.DSTU3.getVersionImplementation().getVersionString());
|
||||
retVal.setFhirVersion(FhirVersionEnum.DSTU3.getFhirVersionString());
|
||||
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
|
||||
|
|
|
@ -216,7 +216,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
|
||||
retVal.setPublisher(myPublisher);
|
||||
retVal.setDateElement(conformanceDate());
|
||||
retVal.setFhirVersion(FhirVersionEnum.DSTU3.getVersionImplementation().getVersionString());
|
||||
retVal.setFhirVersion(FhirVersionEnum.DSTU3.getFhirVersionString());
|
||||
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
|
||||
|
|
|
@ -337,7 +337,7 @@ public final class HapiWorkerContext implements IWorkerContext, ValueSetExpander
|
|||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return myCtx.getVersion().getVersionString();
|
||||
return myCtx.getVersion().getVersion().getFhirVersionString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package ca.uhn.fhir.context;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class VersionDstu3Test {
|
||||
|
||||
@Test
|
||||
public void testVersion() {
|
||||
assertEquals("1.8.0", FhirVersionEnum.DSTU3.getFhirVersionString());
|
||||
}
|
||||
|
||||
}
|
|
@ -91,7 +91,7 @@ public class GenericClientDstu3Test {
|
|||
}
|
||||
|
||||
private String expectedUserAgent() {
|
||||
return "HAPI-FHIR/" + VersionUtil.getVersion() + " (FHIR Client; FHIR " + FhirVersionEnum.DSTU3.getVersionImplementation().getVersionString() + "/DSTU3; apache)";
|
||||
return "HAPI-FHIR/" + VersionUtil.getVersion() + " (FHIR Client; FHIR " + FhirVersionEnum.DSTU3.getFhirVersionString() + "/DSTU3; apache)";
|
||||
}
|
||||
|
||||
private byte[] extractBodyAsByteArray(ArgumentCaptor<HttpUriRequest> capt) throws IOException {
|
||||
|
|
|
@ -108,7 +108,7 @@ public class MetadataCapabilityStatementDstu3Test {
|
|||
output = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertThat(output, containsString("<CapabilityStatement"));
|
||||
assertEquals("HAPI FHIR " + VersionUtil.getVersion() + " REST Server (FHIR Server; FHIR " + FhirVersionEnum.DSTU3.getVersionImplementation().getVersionString() + "/DSTU3)",
|
||||
assertEquals("HAPI FHIR " + VersionUtil.getVersion() + " REST Server (FHIR Server; FHIR " + FhirVersionEnum.DSTU3.getFhirVersionString() + "/DSTU3)",
|
||||
status.getFirstHeader("X-Powered-By").getValue());
|
||||
} finally {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
|
|
@ -110,7 +110,7 @@ public class MetadataConformanceDstu3Test {
|
|||
output = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertThat(output, containsString("<Conformance"));
|
||||
assertEquals("HAPI FHIR " + VersionUtil.getVersion() + " REST Server (FHIR Server; FHIR " + FhirVersionEnum.DSTU3.getVersionImplementation().getVersionString() + "/DSTU3)", status.getFirstHeader("X-Powered-By").getValue());
|
||||
assertEquals("HAPI FHIR " + VersionUtil.getVersion() + " REST Server (FHIR Server; FHIR " + FhirVersionEnum.DSTU3.getFhirVersionString() + "/DSTU3)", status.getFirstHeader("X-Powered-By").getValue());
|
||||
} finally {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
|
|
|
@ -126,11 +126,6 @@ public class FhirDstu2Hl7Org implements IFhirVersion {
|
|||
return FhirVersionEnum.DSTU2_HL7ORG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionString() {
|
||||
return "1.0.2";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IVersionSpecificBundleFactory newBundleFactory(FhirContext theContext) {
|
||||
|
|
Loading…
Reference in New Issue