don't send xhtml for tx operations
This commit is contained in:
parent
3fb9bc20f4
commit
81cb12d0ed
|
@ -251,7 +251,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resource.getClass(), resource.getId()),
|
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resource.getClass(), resource.getId()),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
withVer(getPreferredResourceFormat(), "3.0"),
|
withVer(getPreferredResourceFormat(), "3.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"Update " + resource.fhirType() + "/" + resource.getId(),
|
"Update " + resource.fhirType() + "/" + resource.getId(),
|
||||||
|
@ -279,7 +279,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
ResourceRequest<T> result = null;
|
ResourceRequest<T> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id),
|
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
withVer(getPreferredResourceFormat(), "3.0"),
|
withVer(getPreferredResourceFormat(), "3.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"Update " + resource.fhirType() + "/" + id,
|
"Update " + resource.fhirType() + "/" + id,
|
||||||
|
@ -316,7 +316,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
ResourceRequest<T> result;
|
ResourceRequest<T> result;
|
||||||
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
||||||
if (complex) {
|
if (complex) {
|
||||||
byte[] body = ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()));
|
byte[] body = ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true);
|
||||||
if (client.getLogger() != null) {
|
if (client.getLogger() != null) {
|
||||||
client.getLogger().logRequest("POST", url.toString(), null, body);
|
client.getLogger().logRequest("POST", url.toString(), null, body);
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
recordUse();
|
recordUse();
|
||||||
Bundle transactionResult = null;
|
Bundle transactionResult = null;
|
||||||
try {
|
try {
|
||||||
transactionResult = client.postBatchRequest(resourceAddress.getBaseServiceUri(), ByteUtils.resourceToByteArray(batch, false, isJson(getPreferredResourceFormat())), withVer(getPreferredResourceFormat(), "3.0"), "transaction", timeoutOperation + (timeoutEntry * batch.getEntry().size()));
|
transactionResult = client.postBatchRequest(resourceAddress.getBaseServiceUri(), ByteUtils.resourceToByteArray(batch, false, isJson(getPreferredResourceFormat()), false), withVer(getPreferredResourceFormat(), "3.0"), "transaction", timeoutOperation + (timeoutEntry * batch.getEntry().size()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
handleException("An error occurred trying to process this transaction request", e);
|
handleException("An error occurred trying to process this transaction request", e);
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
ResourceRequest<T> result = null;
|
ResourceRequest<T> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveValidateUri(resourceClass, id),
|
result = client.issuePostRequest(resourceAddress.resolveValidateUri(resourceClass, id),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
withVer(getPreferredResourceFormat(), "3.0"), generateHeaders(),
|
withVer(getPreferredResourceFormat(), "3.0"), generateHeaders(),
|
||||||
"POST " + resourceClass.getName() + (id != null ? "/" + id : "") + "/$validate", timeoutLong);
|
"POST " + resourceClass.getName() + (id != null ? "/" + id : "") + "/$validate", timeoutLong);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
|
@ -437,7 +437,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup"),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup"),
|
||||||
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "3.0"),
|
withVer(getPreferredResourceFormat(), "3.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"CodeSystem/$lookup",
|
"CodeSystem/$lookup",
|
||||||
|
@ -456,7 +456,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ConceptMap.class, "transform"),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ConceptMap.class, "transform"),
|
||||||
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "3.0"),
|
withVer(getPreferredResourceFormat(), "3.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"ConceptMap/$transform",
|
"ConceptMap/$transform",
|
||||||
|
@ -477,7 +477,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"),
|
||||||
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "3.0"),
|
withVer(getPreferredResourceFormat(), "3.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"ValueSet/$expand?url=" + source.getUrl(),
|
"ValueSet/$expand?url=" + source.getUrl(),
|
||||||
|
@ -502,7 +502,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
ResourceRequest<Resource> result = null;
|
ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
||||||
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "3.0"),
|
withVer(getPreferredResourceFormat(), "3.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"Closure?name=" + name,
|
"Closure?name=" + name,
|
||||||
|
@ -524,7 +524,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
||||||
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "3.0"),
|
withVer(getPreferredResourceFormat(), "3.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"UpdateClosure?name=" + name,
|
"UpdateClosure?name=" + name,
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.hl7.fhir.dstu3.utils.client.EFhirClientException;
|
||||||
|
|
||||||
public class ByteUtils {
|
public class ByteUtils {
|
||||||
|
|
||||||
public static <T extends Resource> byte[] resourceToByteArray(T resource, boolean pretty, boolean isJson) {
|
public static <T extends Resource> byte[] resourceToByteArray(T resource, boolean pretty, boolean isJson, boolean noXhtml) {
|
||||||
ByteArrayOutputStream baos = null;
|
ByteArrayOutputStream baos = null;
|
||||||
byte[] byteArray = null;
|
byte[] byteArray = null;
|
||||||
try {
|
try {
|
||||||
|
@ -26,6 +26,9 @@ public class ByteUtils {
|
||||||
parser = new XmlParser();
|
parser = new XmlParser();
|
||||||
}
|
}
|
||||||
parser.setOutputStyle(pretty ? IParser.OutputStyle.PRETTY : IParser.OutputStyle.NORMAL);
|
parser.setOutputStyle(pretty ? IParser.OutputStyle.PRETTY : IParser.OutputStyle.NORMAL);
|
||||||
|
if (noXhtml) {
|
||||||
|
parser.setSuppressXhtml("Narrative removed");
|
||||||
|
}
|
||||||
parser.compose(baos, resource);
|
parser.compose(baos, resource);
|
||||||
baos.close();
|
baos.close();
|
||||||
byteArray = baos.toByteArray();
|
byteArray = baos.toByteArray();
|
||||||
|
|
|
@ -243,7 +243,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
try {
|
try {
|
||||||
result = client.issuePutRequest(
|
result = client.issuePutRequest(
|
||||||
resourceAddress.resolveGetUriFromResourceClassAndId(resource.getClass(), resource.getId()),
|
resourceAddress.resolveGetUriFromResourceClassAndId(resource.getClass(), resource.getId()),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "Update " + resource.fhirType() + "/" + resource.getId(),
|
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "Update " + resource.fhirType() + "/" + resource.getId(),
|
||||||
timeoutOperation);
|
timeoutOperation);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
|
@ -273,7 +273,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
ResourceRequest<T> result = null;
|
ResourceRequest<T> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id),
|
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "Update " + resource.fhirType() + "/" + id,
|
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "Update " + resource.fhirType() + "/" + id,
|
||||||
timeoutOperation);
|
timeoutOperation);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
|
@ -311,7 +311,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
ResourceRequest<T> result;
|
ResourceRequest<T> result;
|
||||||
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
||||||
if (complex) {
|
if (complex) {
|
||||||
byte[] body = ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()));
|
byte[] body = ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true);
|
||||||
result = client.issuePostRequest(url, body, withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(),
|
result = client.issuePostRequest(url, body, withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(),
|
||||||
"POST " + resourceClass.getName() + "/$" + name, timeoutLong);
|
"POST " + resourceClass.getName() + "/$" + name, timeoutLong);
|
||||||
} else {
|
} else {
|
||||||
|
@ -336,7 +336,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
Bundle transactionResult = null;
|
Bundle transactionResult = null;
|
||||||
try {
|
try {
|
||||||
transactionResult = client.postBatchRequest(resourceAddress.getBaseServiceUri(),
|
transactionResult = client.postBatchRequest(resourceAddress.getBaseServiceUri(),
|
||||||
ByteUtils.resourceToByteArray(batch, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(batch, false, isJson(getPreferredResourceFormat()), false),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"), "transaction", timeoutOperation + (timeoutEntry * batch.getEntry().size()));
|
withVer(getPreferredResourceFormat(), "4.0"), "transaction", timeoutOperation + (timeoutEntry * batch.getEntry().size()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
handleException("An error occurred trying to process this transaction request", e);
|
handleException("An error occurred trying to process this transaction request", e);
|
||||||
|
@ -350,7 +350,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
ResourceRequest<T> result = null;
|
ResourceRequest<T> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveValidateUri(resourceClass, id),
|
result = client.issuePostRequest(resourceAddress.resolveValidateUri(resourceClass, id),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(),
|
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(),
|
||||||
"POST " + resourceClass.getName() + (id != null ? "/" + id : "") + "/$validate", timeoutLong);
|
"POST " + resourceClass.getName() + (id != null ? "/" + id : "") + "/$validate", timeoutLong);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
|
@ -424,7 +424,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.r4.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.r4.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup"),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup"),
|
||||||
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "CodeSystem/$lookup", timeoutNormal);
|
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "CodeSystem/$lookup", timeoutNormal);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new FHIRException(e);
|
throw new FHIRException(e);
|
||||||
|
@ -441,7 +441,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.r4.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.r4.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ConceptMap.class, "translate"),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ConceptMap.class, "translate"),
|
||||||
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "ConceptMap/$translate", timeoutNormal);
|
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "ConceptMap/$translate", timeoutNormal);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new FHIRException(e);
|
throw new FHIRException(e);
|
||||||
|
@ -456,11 +456,13 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
public ValueSet expandValueset(ValueSet source, Parameters expParams) {
|
public ValueSet expandValueset(ValueSet source, Parameters expParams) {
|
||||||
recordUse();
|
recordUse();
|
||||||
Parameters p = expParams == null ? new Parameters() : expParams.copy();
|
Parameters p = expParams == null ? new Parameters() : expParams.copy();
|
||||||
p.addParameter().setName("valueSet").setResource(source);
|
if (source != null) {
|
||||||
|
p.addParameter().setName("valueSet").setResource(source);
|
||||||
|
}
|
||||||
org.hl7.fhir.r4.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.r4.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"),
|
||||||
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())), withVer(getPreferredResourceFormat(), "4.0"),
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat()), true), withVer(getPreferredResourceFormat(), "4.0"),
|
||||||
generateHeaders(), source == null ? "ValueSet/$expand" : "ValueSet/$expand?url=" + source.getUrl(),
|
generateHeaders(), source == null ? "ValueSet/$expand" : "ValueSet/$expand?url=" + source.getUrl(),
|
||||||
timeoutExpand);
|
timeoutExpand);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
|
@ -491,7 +493,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(
|
result = client.issuePostRequest(
|
||||||
resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
||||||
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "Closure?name=" + name, timeoutNormal);
|
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "Closure?name=" + name, timeoutNormal);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
||||||
|
@ -512,7 +514,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(
|
result = client.issuePostRequest(
|
||||||
resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
||||||
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "UpdateClosure?name=" + name, timeoutOperation);
|
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "UpdateClosure?name=" + name, timeoutOperation);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.hl7.fhir.r4.utils.client.EFhirClientException;
|
||||||
|
|
||||||
public class ByteUtils {
|
public class ByteUtils {
|
||||||
|
|
||||||
public static <T extends Resource> byte[] resourceToByteArray(T resource, boolean pretty, boolean isJson) {
|
public static <T extends Resource> byte[] resourceToByteArray(T resource, boolean pretty, boolean isJson, boolean noXhtml) {
|
||||||
ByteArrayOutputStream baos = null;
|
ByteArrayOutputStream baos = null;
|
||||||
byte[] byteArray = null;
|
byte[] byteArray = null;
|
||||||
try {
|
try {
|
||||||
|
@ -26,6 +26,9 @@ public class ByteUtils {
|
||||||
parser = new XmlParser();
|
parser = new XmlParser();
|
||||||
}
|
}
|
||||||
parser.setOutputStyle(pretty ? IParser.OutputStyle.PRETTY : IParser.OutputStyle.NORMAL);
|
parser.setOutputStyle(pretty ? IParser.OutputStyle.PRETTY : IParser.OutputStyle.NORMAL);
|
||||||
|
if (noXhtml) {
|
||||||
|
parser.setSuppressXhtml("Narrative removed");
|
||||||
|
}
|
||||||
parser.compose(baos, resource);
|
parser.compose(baos, resource);
|
||||||
baos.close();
|
baos.close();
|
||||||
byteArray = baos.toByteArray();
|
byteArray = baos.toByteArray();
|
||||||
|
|
|
@ -237,7 +237,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient{
|
||||||
try {
|
try {
|
||||||
result = client.issuePutRequest(
|
result = client.issuePutRequest(
|
||||||
resourceAddress.resolveGetUriFromResourceClassAndId(resource.getClass(), resource.getId()),
|
resourceAddress.resolveGetUriFromResourceClassAndId(resource.getClass(), resource.getId()),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
getPreferredResourceFormat(), generateHeaders(), "Update " + resource.fhirType() + "/" + resource.getId(),
|
getPreferredResourceFormat(), generateHeaders(), "Update " + resource.fhirType() + "/" + resource.getId(),
|
||||||
timeoutOperation);
|
timeoutOperation);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
|
@ -266,7 +266,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient{
|
||||||
ResourceRequest<T> result = null;
|
ResourceRequest<T> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id),
|
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
getPreferredResourceFormat(), generateHeaders(), "Update " + resource.fhirType() + "/" + id,
|
getPreferredResourceFormat(), generateHeaders(), "Update " + resource.fhirType() + "/" + id,
|
||||||
timeoutOperation);
|
timeoutOperation);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
|
@ -304,7 +304,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient{
|
||||||
ResourceRequest<T> result;
|
ResourceRequest<T> result;
|
||||||
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
||||||
if (complex) {
|
if (complex) {
|
||||||
byte[] body = ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()));
|
byte[] body = ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true);
|
||||||
result = client.issuePostRequest(url, body, getPreferredResourceFormat(), generateHeaders(),
|
result = client.issuePostRequest(url, body, getPreferredResourceFormat(), generateHeaders(),
|
||||||
"POST " + resourceClass.getName() + "/$" + name, timeoutLong);
|
"POST " + resourceClass.getName() + "/$" + name, timeoutLong);
|
||||||
} else {
|
} else {
|
||||||
|
@ -333,7 +333,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient{
|
||||||
Bundle transactionResult = null;
|
Bundle transactionResult = null;
|
||||||
try {
|
try {
|
||||||
transactionResult = client.postBatchRequest(resourceAddress.getBaseServiceUri(),
|
transactionResult = client.postBatchRequest(resourceAddress.getBaseServiceUri(),
|
||||||
ByteUtils.resourceToByteArray(batch, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(batch, false, isJson(getPreferredResourceFormat()), false),
|
||||||
getPreferredResourceFormat(), generateHeaders(), "transaction",
|
getPreferredResourceFormat(), generateHeaders(), "transaction",
|
||||||
timeoutOperation + (timeoutEntry * batch.getEntry().size()));
|
timeoutOperation + (timeoutEntry * batch.getEntry().size()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -347,7 +347,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient{
|
||||||
ResourceRequest<T> result = null;
|
ResourceRequest<T> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveValidateUri(resourceClass, id),
|
result = client.issuePostRequest(resourceAddress.resolveValidateUri(resourceClass, id),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
getPreferredResourceFormat(), generateHeaders(),
|
getPreferredResourceFormat(), generateHeaders(),
|
||||||
"POST " + resourceClass.getName() + (id != null ? "/" + id : "") + "/$validate", timeoutLong);
|
"POST " + resourceClass.getName() + (id != null ? "/" + id : "") + "/$validate", timeoutLong);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
|
@ -405,7 +405,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient{
|
||||||
org.hl7.fhir.r4b.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.r4b.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"),
|
||||||
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(),
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat()), true), getPreferredResourceFormat(),
|
||||||
generateHeaders(), "ValueSet/$expand?url=" + source.getUrl(), timeoutExpand);
|
generateHeaders(), "ValueSet/$expand?url=" + source.getUrl(), timeoutExpand);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
||||||
|
@ -442,7 +442,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params),
|
||||||
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(),
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat()), true), getPreferredResourceFormat(),
|
||||||
generateHeaders(), "ValueSet/$expand?url=" + source.getUrl(), timeoutExpand);
|
generateHeaders(), "ValueSet/$expand?url=" + source.getUrl(), timeoutExpand);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
||||||
|
@ -465,7 +465,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient{
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(
|
result = client.issuePostRequest(
|
||||||
resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
||||||
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true),
|
||||||
getPreferredResourceFormat(), generateHeaders(), "Closure?name=" + name, timeoutNormal);
|
getPreferredResourceFormat(), generateHeaders(), "Closure?name=" + name, timeoutNormal);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
||||||
|
@ -485,7 +485,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient{
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(
|
result = client.issuePostRequest(
|
||||||
resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
||||||
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true),
|
||||||
getPreferredResourceFormat(), generateHeaders(), "UpdateClosure?name=" + name, timeoutOperation);
|
getPreferredResourceFormat(), generateHeaders(), "UpdateClosure?name=" + name, timeoutOperation);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(),
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Map;
|
||||||
|
|
||||||
public class ByteUtils {
|
public class ByteUtils {
|
||||||
|
|
||||||
public static <T extends Resource> byte[] resourceToByteArray(T resource, boolean pretty, boolean isJson) {
|
public static <T extends Resource> byte[] resourceToByteArray(T resource, boolean pretty, boolean isJson, boolean noXhtml) {
|
||||||
ByteArrayOutputStream baos = null;
|
ByteArrayOutputStream baos = null;
|
||||||
byte[] byteArray = null;
|
byte[] byteArray = null;
|
||||||
try {
|
try {
|
||||||
|
@ -27,6 +27,9 @@ public class ByteUtils {
|
||||||
parser = new XmlParser();
|
parser = new XmlParser();
|
||||||
}
|
}
|
||||||
parser.setOutputStyle(pretty ? IParser.OutputStyle.PRETTY : IParser.OutputStyle.NORMAL);
|
parser.setOutputStyle(pretty ? IParser.OutputStyle.PRETTY : IParser.OutputStyle.NORMAL);
|
||||||
|
if (noXhtml) {
|
||||||
|
parser.setSuppressXhtml("Narrative removed");
|
||||||
|
}
|
||||||
parser.compose(baos, resource);
|
parser.compose(baos, resource);
|
||||||
baos.close();
|
baos.close();
|
||||||
byteArray = baos.toByteArray();
|
byteArray = baos.toByteArray();
|
||||||
|
|
|
@ -96,7 +96,7 @@ class ClientTest {
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("PUT request, test payload received by server matches sent.")
|
@DisplayName("PUT request, test payload received by server matches sent.")
|
||||||
void test_put() throws IOException, URISyntaxException, InterruptedException {
|
void test_put() throws IOException, URISyntaxException, InterruptedException {
|
||||||
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false);
|
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false, false);
|
||||||
// Mock server response of 200, with the same resource payload returned that we
|
// Mock server response of 200, with the same resource payload returned that we
|
||||||
// included in the PUT request
|
// included in the PUT request
|
||||||
server.enqueue(new MockResponse().setResponseCode(200).setBody(new String(payload)));
|
server.enqueue(new MockResponse().setResponseCode(200).setBody(new String(payload)));
|
||||||
|
@ -111,7 +111,7 @@ class ClientTest {
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("POST request, test payload received by server matches sent.")
|
@DisplayName("POST request, test payload received by server matches sent.")
|
||||||
void test_post() throws IOException, URISyntaxException, InterruptedException {
|
void test_post() throws IOException, URISyntaxException, InterruptedException {
|
||||||
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false);
|
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false, false);
|
||||||
// Mock server response of 200, with the same resource payload returned that we
|
// Mock server response of 200, with the same resource payload returned that we
|
||||||
// included in the PUT request
|
// included in the PUT request
|
||||||
server.enqueue(new MockResponse().setResponseCode(200).setBody(new String(payload)));
|
server.enqueue(new MockResponse().setResponseCode(200).setBody(new String(payload)));
|
||||||
|
@ -126,7 +126,7 @@ class ClientTest {
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Testing the logger works.")
|
@DisplayName("Testing the logger works.")
|
||||||
void test_logger() throws IOException, URISyntaxException, InterruptedException {
|
void test_logger() throws IOException, URISyntaxException, InterruptedException {
|
||||||
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false);
|
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false, false);
|
||||||
server.enqueue(new MockResponse().setResponseCode(200).setBody(new String(payload)));
|
server.enqueue(new MockResponse().setResponseCode(200).setBody(new String(payload)));
|
||||||
HTMLClientLogger mockLogger = Mockito.mock(HTMLClientLogger.class);
|
HTMLClientLogger mockLogger = Mockito.mock(HTMLClientLogger.class);
|
||||||
client.setLogger(mockLogger);
|
client.setLogger(mockLogger);
|
||||||
|
|
|
@ -291,7 +291,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resource.getClass(), resource.getId()),
|
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resource.getClass(), resource.getId()),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"),
|
withVer(getPreferredResourceFormat(), "4.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"Update " + resource.fhirType() + "/" + resource.getId(),
|
"Update " + resource.fhirType() + "/" + resource.getId(),
|
||||||
|
@ -319,7 +319,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
ResourceRequest<T> result = null;
|
ResourceRequest<T> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id),
|
result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"),
|
withVer(getPreferredResourceFormat(), "4.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"Update " + resource.fhirType() + "/" + id,
|
"Update " + resource.fhirType() + "/" + id,
|
||||||
|
@ -356,7 +356,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
ResourceRequest<T> result;
|
ResourceRequest<T> result;
|
||||||
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
||||||
if (complex) {
|
if (complex) {
|
||||||
byte[] body = ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()));
|
byte[] body = ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true);
|
||||||
result = client.issuePostRequest(url, body, withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(),
|
result = client.issuePostRequest(url, body, withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(),
|
||||||
"POST " + resourceClass.getName() + "/$" + name, timeoutLong);
|
"POST " + resourceClass.getName() + "/$" + name, timeoutLong);
|
||||||
} else {
|
} else {
|
||||||
|
@ -382,7 +382,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
recordUse();
|
recordUse();
|
||||||
Bundle transactionResult = null;
|
Bundle transactionResult = null;
|
||||||
try {
|
try {
|
||||||
transactionResult = client.postBatchRequest(resourceAddress.getBaseServiceUri(), ByteUtils.resourceToByteArray(batch, false, isJson(getPreferredResourceFormat())), withVer(getPreferredResourceFormat(), "4.0"),
|
transactionResult = client.postBatchRequest(resourceAddress.getBaseServiceUri(), ByteUtils.resourceToByteArray(batch, false, isJson(getPreferredResourceFormat()), false), withVer(getPreferredResourceFormat(), "4.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"transaction", timeoutOperation + (timeoutEntry * batch.getEntry().size()));
|
"transaction", timeoutOperation + (timeoutEntry * batch.getEntry().size()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -397,7 +397,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
ResourceRequest<T> result = null;
|
ResourceRequest<T> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveValidateUri(resourceClass, id),
|
result = client.issuePostRequest(resourceAddress.resolveValidateUri(resourceClass, id),
|
||||||
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat()), false),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(),
|
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(),
|
||||||
"POST " + resourceClass.getName() + (id != null ? "/" + id : "") + "/$validate", timeoutLong);
|
"POST " + resourceClass.getName() + (id != null ? "/" + id : "") + "/$validate", timeoutLong);
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
|
@ -456,7 +456,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"),
|
||||||
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"),
|
withVer(getPreferredResourceFormat(), "4.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"ValueSet/$expand?url=" + source.getUrl(),
|
"ValueSet/$expand?url=" + source.getUrl(),
|
||||||
|
@ -493,7 +493,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup"),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup"),
|
||||||
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"),
|
withVer(getPreferredResourceFormat(), "4.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"CodeSystem/$lookup",
|
"CodeSystem/$lookup",
|
||||||
|
@ -512,7 +512,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ConceptMap.class, "translate"),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ConceptMap.class, "translate"),
|
||||||
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"),
|
withVer(getPreferredResourceFormat(), "4.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"ConceptMap/$translate",
|
"ConceptMap/$translate",
|
||||||
|
@ -537,7 +537,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
ResourceRequest<Resource> result = null;
|
ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
||||||
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"),
|
withVer(getPreferredResourceFormat(), "4.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"Closure?name=" + name,
|
"Closure?name=" + name,
|
||||||
|
@ -559,7 +559,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||||
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
|
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
try {
|
try {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap<String, String>()),
|
||||||
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())),
|
ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()), true),
|
||||||
withVer(getPreferredResourceFormat(), "4.0"),
|
withVer(getPreferredResourceFormat(), "4.0"),
|
||||||
generateHeaders(),
|
generateHeaders(),
|
||||||
"UpdateClosure?name=" + name,
|
"UpdateClosure?name=" + name,
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Map;
|
||||||
|
|
||||||
public class ByteUtils {
|
public class ByteUtils {
|
||||||
|
|
||||||
public static <T extends Resource> byte[] resourceToByteArray(T resource, boolean pretty, boolean isJson) {
|
public static <T extends Resource> byte[] resourceToByteArray(T resource, boolean pretty, boolean isJson, boolean noXhtml) {
|
||||||
ByteArrayOutputStream baos = null;
|
ByteArrayOutputStream baos = null;
|
||||||
byte[] byteArray = null;
|
byte[] byteArray = null;
|
||||||
try {
|
try {
|
||||||
|
@ -27,6 +27,9 @@ public class ByteUtils {
|
||||||
parser = new XmlParser();
|
parser = new XmlParser();
|
||||||
}
|
}
|
||||||
parser.setOutputStyle(pretty ? IParser.OutputStyle.PRETTY : IParser.OutputStyle.NORMAL);
|
parser.setOutputStyle(pretty ? IParser.OutputStyle.PRETTY : IParser.OutputStyle.NORMAL);
|
||||||
|
if (noXhtml) {
|
||||||
|
parser.setSuppressXhtml("Narrative removed");
|
||||||
|
}
|
||||||
parser.compose(baos, resource);
|
parser.compose(baos, resource);
|
||||||
baos.close();
|
baos.close();
|
||||||
byteArray = baos.toByteArray();
|
byteArray = baos.toByteArray();
|
||||||
|
|
|
@ -122,7 +122,7 @@ class ClientTest {
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("PUT request, test payload received by server matches sent.")
|
@DisplayName("PUT request, test payload received by server matches sent.")
|
||||||
void test_put() throws IOException, URISyntaxException, InterruptedException {
|
void test_put() throws IOException, URISyntaxException, InterruptedException {
|
||||||
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false);
|
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false, false);
|
||||||
// Mock server response of 200, with the same resource payload returned that we included in the PUT request
|
// Mock server response of 200, with the same resource payload returned that we included in the PUT request
|
||||||
server.enqueue(
|
server.enqueue(
|
||||||
new MockResponse()
|
new MockResponse()
|
||||||
|
@ -140,7 +140,7 @@ class ClientTest {
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("POST request, test payload received by server matches sent.")
|
@DisplayName("POST request, test payload received by server matches sent.")
|
||||||
void test_post() throws IOException, URISyntaxException, InterruptedException {
|
void test_post() throws IOException, URISyntaxException, InterruptedException {
|
||||||
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false);
|
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false, false);
|
||||||
// Mock server response of 200, with the same resource payload returned that we included in the PUT request
|
// Mock server response of 200, with the same resource payload returned that we included in the PUT request
|
||||||
server.enqueue(
|
server.enqueue(
|
||||||
new MockResponse()
|
new MockResponse()
|
||||||
|
@ -158,7 +158,7 @@ class ClientTest {
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Testing the logger works.")
|
@DisplayName("Testing the logger works.")
|
||||||
void test_logger() throws IOException, URISyntaxException, InterruptedException {
|
void test_logger() throws IOException, URISyntaxException, InterruptedException {
|
||||||
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false);
|
byte[] payload = ByteUtils.resourceToByteArray(patient, true, false, false);
|
||||||
server.enqueue(
|
server.enqueue(
|
||||||
new MockResponse()
|
new MockResponse()
|
||||||
.setResponseCode(200)
|
.setResponseCode(200)
|
||||||
|
|
Loading…
Reference in New Issue