One more fix for #4467

This commit is contained in:
James Agnew 2023-01-26 12:22:30 -05:00 committed by Tadgh
parent 10060bef7f
commit 078dcd9c0d
2 changed files with 16 additions and 7 deletions

View File

@ -264,17 +264,16 @@ public class HashMapResourceProvider<T extends IBaseResource> implements IResour
if (!versions.containsKey(versionId)) {
throw new ResourceNotFoundException(Msg.code(1982) + theId);
} else {
T resource = versions.get(versionId);
if (resource == null || ResourceMetadataKeyEnum.DELETED_AT.get(resource) != null) {
throw new ResourceGoneException(Msg.code(1983) + theId);
}
retVal = resource;
retVal = versions.get(versionId);
}
} else {
retVal = versions.lastEntry().getValue();
}
if (retVal == null || ResourceMetadataKeyEnum.DELETED_AT.get(retVal) != null) {
throw new ResourceGoneException(Msg.code(1983) + theId);
}
myReadCount.incrementAndGet();
retVal = fireInterceptorsAndFilterAsNeeded(retVal, theRequestDetails);

View File

@ -115,8 +115,10 @@ public class HashMapResourceProviderTest {
assertEquals(1, myPatientResourceProvider.getCountDelete());
// Read
// VRead original version
ourRestServer.getFhirClient().read().resource("Patient").withId(id.withVersion("1")).execute();
// Vread gone version
try {
ourRestServer.getFhirClient().read().resource("Patient").withId(id.withVersion("2")).execute();
fail();
@ -124,6 +126,14 @@ public class HashMapResourceProviderTest {
// good
}
// Read (non vread) gone version
try {
ourRestServer.getFhirClient().read().resource("Patient").withId(id.toUnqualifiedVersionless()).execute();
fail();
} catch (ResourceGoneException e) {
// good
}
// History should include deleted entry
Bundle history = ourRestServer.getFhirClient().history().onType(Patient.class).returnBundle(Bundle.class).execute();
ourLog.info("History:\n{}", ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(history));