One more fix for #4467 (#4469)

This commit is contained in:
James Agnew 2023-01-27 07:02:00 -05:00 committed by GitHub
parent 10060bef7f
commit cca0b633a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 = versions.get(versionId);
}
retVal = resource;
}
} 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));