Merge branch 'master' of github.com:jamesagnew/hapi-fhir
This commit is contained in:
commit
5f63dcfe7d
|
@ -49,6 +49,7 @@ import ca.uhn.fhir.rest.api.EncodingEnum;
|
|||
import ca.uhn.fhir.util.ElementUtil;
|
||||
import static ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum.ID_DATATYPE;
|
||||
import static ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum.PRIMITIVE_DATATYPE;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* This class is the FHIR JSON parser/encoder. Users should not interact with this class directly, but should use
|
||||
|
@ -705,6 +706,21 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
if (isNotBlank(contentAsBase64)) {
|
||||
write(theEventWriter, "content", contentAsBase64);
|
||||
}
|
||||
try {
|
||||
Method getSC = bin.getClass().getMethod("getSecurityContext");
|
||||
Object securityContext = getSC.invoke(bin);
|
||||
if (securityContext != null) {
|
||||
Method getRef = securityContext.getClass().getMethod("getReference");
|
||||
String securityContextRef = (String) getRef.invoke(securityContext);
|
||||
if (securityContextRef != null) {
|
||||
beginObject(theEventWriter, "securityContext");
|
||||
writeOptionalTagWithTextNode(theEventWriter, "reference", securityContextRef);
|
||||
theEventWriter.endObject();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
encodeCompositeElementToStreamWriter(theResDef, theResource, theResource, theEventWriter, theContainedResource, theSubResource, new CompositeChildElement(resDef, theSubResource));
|
||||
}
|
||||
|
|
|
@ -575,6 +575,23 @@ public class JsonParserDstu3Test {
|
|||
String output = ourCtx.newJsonParser().encodeResourceToString(new Binary());
|
||||
assertEquals("{\"resourceType\":\"Binary\"}", output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeBinaryWithSecurityContext() {
|
||||
Binary bin = new Binary();
|
||||
bin.setContentType("text/plain");
|
||||
bin.setContent("Now is the time".getBytes());
|
||||
Reference securityContext = new Reference();
|
||||
securityContext.setReference("DiagnosticReport/1");
|
||||
bin.setSecurityContext(securityContext);
|
||||
String encoded = ourCtx.newJsonParser().encodeResourceToString(bin);
|
||||
assertThat(encoded, containsString("Binary"));
|
||||
assertThat(encoded, containsString("contentType"));
|
||||
assertThat(encoded, containsString("text/plain"));
|
||||
assertThat(encoded, containsString("Tm93IGlzIHRoZSB0aW1l"));
|
||||
assertThat(encoded, containsString("securityContext"));
|
||||
assertThat(encoded, containsString("{\"reference\":\"DiagnosticReport/1\"}"));
|
||||
}
|
||||
|
||||
/**
|
||||
* #158
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -366,6 +366,10 @@
|
|||
<id>patrick-werner</id>
|
||||
<name>Patrick Werner</name>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>malcolmm83</id>
|
||||
<name>Malcolm McRoberts</name>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
|
|
|
@ -170,6 +170,11 @@
|
|||
DSTU2-hl7org and DSTU2.1 structures did not copy resource IDs when invoking
|
||||
copyValues(). Thanks to Clayton Bodendein for the pull request!
|
||||
</action>
|
||||
<action type="fix" issue="734">
|
||||
When encoding a Binary resource, the Binary.securityContext field
|
||||
was not encoded correctly. Thanks to Malcolm McRoberts for the pull
|
||||
request with fix and test case!
|
||||
</action>
|
||||
</release>
|
||||
<release version="3.0.0" date="2017-09-27">
|
||||
<action type="add">
|
||||
|
|
Loading…
Reference in New Issue