Skip to content

Commit

Permalink
Merge pull request #1390 from hapifhir/2023-08-gg-flat-draft-bugs-ver…
Browse files Browse the repository at this point in the history
…sion-rendering

2023 08 gg flat draft bugs version rendering
  • Loading branch information
grahamegrieve authored Aug 12, 2023
2 parents cce9d9c + 2474c19 commit d136c0c
Show file tree
Hide file tree
Showing 58 changed files with 825 additions and 266 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public FHIRToolingClient(String baseServiceUrl, String userAgent) throws URISynt

public void initialize(String baseServiceUrl) throws URISyntaxException {
base = baseServiceUrl;
client.setBase(base);
resourceAddress = new ResourceAddress(baseServiceUrl);
this.allowedVersions = supportableVersions();
this.maxResultSetSize = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ public class Client {
private ToolingClientLogger logger;
private int retryCount;
private long timeout = DEFAULT_TIMEOUT;
private String base;

public String getBase() {
return base;
}

public void setBase(String base) {
this.base = base;
}


public ToolingClientLogger getLogger() {
return logger;
Expand Down Expand Up @@ -167,7 +177,7 @@ public <T extends Resource> Bundle executeBundleRequest(Request.Builder request,
String message,
int retryCount,
long timeout) throws IOException {
return new FhirRequestBuilder(request)
return new FhirRequestBuilder(request, base)
.withLogger(logger)
.withResourceFormat(resourceFormat)
.withRetryCount(retryCount)
Expand All @@ -183,7 +193,7 @@ public <T extends Resource> ResourceRequest<T> executeFhirRequest(Request.Builde
String message,
int retryCount,
long timeout) throws IOException {
return new FhirRequestBuilder(request)
return new FhirRequestBuilder(request, base)
.withLogger(logger)
.withResourceFormat(resourceFormat)
.withRetryCount(retryCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ public class FhirRequestBuilder {
* {@link ToolingClientLogger} for log output.
*/
private ToolingClientLogger logger = null;
private String source;

public FhirRequestBuilder(Request.Builder httpRequest) {
public FhirRequestBuilder(Request.Builder httpRequest, String source) {
this.httpRequest = httpRequest;
this.source = source;
}

/**
Expand Down Expand Up @@ -265,9 +267,9 @@ protected <T extends Resource> T unmarshalReference(Response response, String fo
error = (OperationOutcome) resource;
}
} catch (IOException ioe) {
throw new EFhirClientException("Error reading Http Response: " + ioe.getMessage(), ioe);
throw new EFhirClientException("Error reading Http Response from "+source+": " + ioe.getMessage(), ioe);
} catch (Exception e) {
throw new EFhirClientException("Error parsing response message: " + e.getMessage(), e);
throw new EFhirClientException("Error parsing response message from "+source+": " + e.getMessage(), e);
}
}

Expand Down Expand Up @@ -301,12 +303,12 @@ else if (rf instanceof OperationOutcome && hasError((OperationOutcome) rf)) {
}
}
} catch (IOException ioe) {
throw new EFhirClientException("Error reading Http Response", ioe);
throw new EFhirClientException("Error reading Http Response from "+source+": "+ioe.getMessage(), ioe);
} catch (Exception e) {
throw new EFhirClientException("Error parsing response message", e);
throw new EFhirClientException("Error parsing response message from "+source+":"+e.getMessage(), e);
}
if (error != null) {
throw new EFhirClientException("Error from server: " + ResourceUtilities.getErrorDescription(error), error);
throw new EFhirClientException("Error from "+source+": " + ResourceUtilities.getErrorDescription(error), error);
}
return feed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class FhirRequestBuilderTests {
final Request.Builder requestBuilder = new Request.Builder()
.url(DUMMY_URL);

final FhirRequestBuilder fhirRequestBuilder = Mockito.spy(new FhirRequestBuilder(requestBuilder));
final FhirRequestBuilder fhirRequestBuilder = Mockito.spy(new FhirRequestBuilder(requestBuilder, "http://local/local"));

@Mock
OkHttpClient client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public FHIRToolingClient(String baseServiceUrl, String userAgent) throws URISynt

public void initialize(String baseServiceUrl) throws URISyntaxException {
base = baseServiceUrl;
client.setBase(base);
resourceAddress = new ResourceAddress(baseServiceUrl);
this.maxResultSetSize = -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ public class Client {
private FhirLoggingInterceptor fhirLoggingInterceptor;
private int retryCount;
private long timeout = DEFAULT_TIMEOUT;
private String base;

public String getBase() {
return base;
}

public void setBase(String base) {
this.base = base;
}


public ToolingClientLogger getLogger() {
return logger;
Expand Down Expand Up @@ -131,15 +141,15 @@ public Bundle postBatchRequest(URI resourceUri, byte[] payload, String resourceF

public <T extends Resource> Bundle executeBundleRequest(Request.Builder request, String resourceFormat,
Headers headers, String message, int retryCount, long timeout) throws IOException {
return new FhirRequestBuilder(request).withLogger(fhirLoggingInterceptor).withResourceFormat(resourceFormat)
return new FhirRequestBuilder(request, base).withLogger(fhirLoggingInterceptor).withResourceFormat(resourceFormat)
.withRetryCount(retryCount).withMessage(message)
.withHeaders(headers == null ? new Headers.Builder().build() : headers)
.withTimeout(timeout, TimeUnit.MILLISECONDS).executeAsBatch();
}

public <T extends Resource> ResourceRequest<T> executeFhirRequest(Request.Builder request, String resourceFormat,
Headers headers, String message, int retryCount, long timeout) throws IOException {
return new FhirRequestBuilder(request).withLogger(fhirLoggingInterceptor).withResourceFormat(resourceFormat)
return new FhirRequestBuilder(request, base).withLogger(fhirLoggingInterceptor).withResourceFormat(resourceFormat)
.withRetryCount(retryCount).withMessage(message)
.withHeaders(headers == null ? new Headers.Builder().build() : headers)
.withTimeout(timeout, TimeUnit.MILLISECONDS).execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ public class FhirRequestBuilder {
* {@link FhirLoggingInterceptor} for log output.
*/
private FhirLoggingInterceptor logger = null;
private String source;

public FhirRequestBuilder(Request.Builder httpRequest) {
public FhirRequestBuilder(Request.Builder httpRequest, String source) {
this.httpRequest = httpRequest;
this.source = source;
}

/**
Expand Down Expand Up @@ -264,9 +266,9 @@ protected <T extends Resource> T unmarshalReference(Response response, String fo
error = (OperationOutcome) resource;
}
} catch (IOException ioe) {
throw new EFhirClientException("Error reading Http Response: " + ioe.getMessage(), ioe);
throw new EFhirClientException("Error reading Http Response from "+source+": " + ioe.getMessage(), ioe);
} catch (Exception e) {
throw new EFhirClientException("Error parsing response message: " + e.getMessage(), e);
throw new EFhirClientException("Error parsing response message from "+source+": " + e.getMessage(), e);
}
}

Expand Down Expand Up @@ -296,17 +298,17 @@ protected Bundle unmarshalFeed(Response response, String format) {
else if (rf instanceof OperationOutcome && hasError((OperationOutcome) rf)) {
error = (OperationOutcome) rf;
} else {
throw new EFhirClientException("Error reading server response: a resource was returned instead");
throw new EFhirClientException("Error reading server response from "+source+": a resource was returned instead");
}
}
}
} catch (IOException ioe) {
throw new EFhirClientException("Error reading Http Response", ioe);
throw new EFhirClientException("Error reading Http Response from "+source+":"+ioe.getMessage(), ioe);
} catch (Exception e) {
throw new EFhirClientException("Error parsing response message", e);
throw new EFhirClientException("Error parsing response message from "+source+":"+e.getMessage(), e);
}
if (error != null) {
throw new EFhirClientException("Error from server: " + ResourceUtilities.getErrorDescription(error), error);
throw new EFhirClientException("Error from "+source+": " + ResourceUtilities.getErrorDescription(error), error);
}
return feed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public FHIRToolingClient(String baseServiceUrl, String userAgent) throws URISynt

public void initialize(String baseServiceUrl) throws URISyntaxException {
base = baseServiceUrl;
client.setBase(base);
resourceAddress = new ResourceAddress(baseServiceUrl);
this.maxResultSetSize = -1;
checkCapabilities();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ public class Client {
private int retryCount;
private long timeout = DEFAULT_TIMEOUT;
private byte[] payload;
private String base;

public String getBase() {
return base;
}

public void setBase(String base) {
this.base = base;
}


public ToolingClientLogger getLogger() {
return logger;
Expand Down Expand Up @@ -135,15 +145,15 @@ public Bundle postBatchRequest(URI resourceUri, byte[] payload, String resourceF

public <T extends Resource> Bundle executeBundleRequest(Request.Builder request, String resourceFormat,
Headers headers, String message, int retryCount, long timeout) throws IOException {
return new FhirRequestBuilder(request).withLogger(fhirLoggingInterceptor).withResourceFormat(resourceFormat)
return new FhirRequestBuilder(request, base).withLogger(fhirLoggingInterceptor).withResourceFormat(resourceFormat)
.withRetryCount(retryCount).withMessage(message)
.withHeaders(headers == null ? new Headers.Builder().build() : headers)
.withTimeout(timeout, TimeUnit.MILLISECONDS).executeAsBatch();
}

public <T extends Resource> ResourceRequest<T> executeFhirRequest(Request.Builder request, String resourceFormat,
Headers headers, String message, int retryCount, long timeout) throws IOException {
return new FhirRequestBuilder(request).withLogger(fhirLoggingInterceptor).withResourceFormat(resourceFormat)
return new FhirRequestBuilder(request, base).withLogger(fhirLoggingInterceptor).withResourceFormat(resourceFormat)
.withRetryCount(retryCount).withMessage(message)
.withHeaders(headers == null ? new Headers.Builder().build() : headers)
.withTimeout(timeout, TimeUnit.MILLISECONDS).execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ public class FhirRequestBuilder {
* {@link FhirLoggingInterceptor} for log output.
*/
private FhirLoggingInterceptor logger = null;
private String source;

public FhirRequestBuilder(Request.Builder httpRequest) {
public FhirRequestBuilder(Request.Builder httpRequest, String source) {
this.httpRequest = httpRequest;
this.source = source;
}

/**
Expand Down Expand Up @@ -253,9 +255,9 @@ protected <T extends Resource> T unmarshalReference(Response response, String fo
error = (OperationOutcome) resource;
}
} catch (IOException ioe) {
throw new EFhirClientException("Error reading Http Response: " + ioe.getMessage(), ioe);
throw new EFhirClientException("Error reading Http Response from "+source+": " + ioe.getMessage(), ioe);
} catch (Exception e) {
throw new EFhirClientException("Error parsing response message: " + e.getMessage(), e);
throw new EFhirClientException("Error parsing response message from "+source+": " + e.getMessage(), e);
}
}

Expand Down Expand Up @@ -290,12 +292,12 @@ else if (rf instanceof OperationOutcome && hasError((OperationOutcome) rf)) {
}
}
} catch (IOException ioe) {
throw new EFhirClientException("Error reading Http Response", ioe);
throw new EFhirClientException("Error reading Http Response from "+source+": "+ioe.getMessage(), ioe);
} catch (Exception e) {
throw new EFhirClientException("Error parsing response message", e);
throw new EFhirClientException("Error parsing response message from "+source+": "+e.getMessage(), e);
}
if (error != null) {
throw new EFhirClientException("Error from server: " + ResourceUtilities.getErrorDescription(error), error);
throw new EFhirClientException("Error from "+source+": " + ResourceUtilities.getErrorDescription(error), error);
}
return feed;
}
Expand Down
Loading

0 comments on commit d136c0c

Please sign in to comment.