ready for rereview

This commit is contained in:
Ken Stevens 2019-10-22 09:29:18 -04:00 committed by James Agnew
parent 0f40b2c48f
commit 427f7397da
2 changed files with 30 additions and 4 deletions

View File

@ -119,6 +119,10 @@ public class BinaryStorageInterceptor {
} }
private void extractLargeBinaries(ServletRequestDetails theRequestDetails, IBaseResource theResource, Pointcut thePoincut) throws IOException { private void extractLargeBinaries(ServletRequestDetails theRequestDetails, IBaseResource theResource, Pointcut thePoincut) throws IOException {
if (theRequestDetails == null) {
// RequestDetails will only be null for internal HAPI events. If externalization is required for them it will need to be done in a different way.
return;
}
IIdType resourceId = theResource.getIdElement(); IIdType resourceId = theResource.getIdElement();
if (!resourceId.hasResourceType() && resourceId.hasIdPart()) { if (!resourceId.hasResourceType() && resourceId.hasIdPart()) {
String resourceType = myCtx.getResourceDefinition(theResource).getName(); String resourceType = myCtx.getResourceDefinition(theResource).getName();

View File

@ -75,6 +75,28 @@ public class BinaryStorageInterceptorR4Test extends BaseResourceProviderR4Test {
} }
@Test
public void testCreateAndRetrieveBinary_ServerAssignedId_ExternalizedBinary_NullServletRequest() {
// Create a resource with a big enough binary
Binary binary = new Binary();
binary.setContentType("application/octet-stream");
binary.setData(SOME_BYTES);
DaoMethodOutcome outcome = myBinaryDao.create(binary);
// Make sure it was externalized
IIdType id = outcome.getId().toUnqualifiedVersionless();
String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource());
ourLog.info("Encoded: {}", encoded);
assertThat(encoded, not(containsString(JpaConstants.EXT_EXTERNALIZED_BINARY_ID)));
assertThat(encoded, containsString("\"data\""));
Binary output = myBinaryDao.read(id);
assertEquals("application/octet-stream", output.getContentType());
assertArrayEquals(SOME_BYTES, output.getData());
}
@Test @Test
public void testCreateAndRetrieveBinary_ServerAssignedId_NonExternalizedBinary() { public void testCreateAndRetrieveBinary_ServerAssignedId_NonExternalizedBinary() {