ready for rereview
This commit is contained in:
parent
d85e73c6fd
commit
2e532e4e98
|
@ -119,6 +119,10 @@ public class BinaryStorageInterceptor {
|
|||
}
|
||||
|
||||
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();
|
||||
if (!resourceId.hasResourceType() && resourceId.hasIdPart()) {
|
||||
String resourceType = myCtx.getResourceDefinition(theResource).getName();
|
||||
|
@ -145,7 +149,7 @@ public class BinaryStorageInterceptor {
|
|||
newBlobId = myBinaryStorageSvc.newBlobId();
|
||||
List<DeferredBinaryTarget> deferredBinaryTargets = getOrCreateDeferredBinaryStorageMap(theRequestDetails);
|
||||
DeferredBinaryTarget newDeferredBinaryTarget = new DeferredBinaryTarget(newBlobId, nextTarget, data);
|
||||
deferredBinaryTargets.add(newDeferredBinaryTarget);
|
||||
deferredBinaryTargets.add(newDeferredBinaryTarget);
|
||||
}
|
||||
|
||||
myBinaryAccessProvider.replaceDataWithExtension(nextTarget, newBlobId);
|
||||
|
@ -159,9 +163,9 @@ public class BinaryStorageInterceptor {
|
|||
@SuppressWarnings("unchecked")
|
||||
private List<DeferredBinaryTarget> getOrCreateDeferredBinaryStorageMap(ServletRequestDetails theRequestDetails) {
|
||||
List<DeferredBinaryTarget> deferredBinaryTargets = (List<DeferredBinaryTarget>) theRequestDetails.getUserData().get(getDeferredListKey());
|
||||
if (deferredBinaryTargets == null) {
|
||||
deferredBinaryTargets = new ArrayList<>();
|
||||
theRequestDetails.getUserData().put(getDeferredListKey(), deferredBinaryTargets);
|
||||
if (deferredBinaryTargets == null) {
|
||||
deferredBinaryTargets = new ArrayList<>();
|
||||
theRequestDetails.getUserData().put(getDeferredListKey(), deferredBinaryTargets);
|
||||
}
|
||||
return deferredBinaryTargets;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
public void testCreateAndRetrieveBinary_ServerAssignedId_NonExternalizedBinary() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue