From f6ae22c59c0de5429c8e44da390c35bffccc9aa9 Mon Sep 17 00:00:00 2001 From: Michael Lawley Date: Fri, 25 Nov 2016 12:05:59 +1000 Subject: [PATCH] #517 Add fallback for for pre-CapabilityStatement STU3 client --- .../uhn/fhir/rest/client/RestfulClientFactory.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java index d33cacc4f55..88ffbdb748a 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java @@ -287,7 +287,17 @@ public abstract class RestfulClientFactory implements IRestfulClientFactory { } @SuppressWarnings("rawtypes") - Class implementingClass = myContext.getResourceDefinition(capabilityStatementResourceName).getImplementingClass(); + Class implementingClass; + try { + implementingClass = myContext.getResourceDefinition(capabilityStatementResourceName).getImplementingClass(); + } catch (DataFormatException e) { + if (!myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3) { + capabilityStatementResourceName = "Conformance"; + implementingClass = myContext.getResourceDefinition(capabilityStatementResourceName).getImplementingClass(); + } else { + throw e; + } + } try { conformance = (IBaseResource) client.fetchConformance().ofType(implementingClass).execute(); } catch (FhirClientConnectionException e) {