parent
10060bef7f
commit
cca0b633a8
|
@ -264,17 +264,16 @@ public class HashMapResourceProvider<T extends IBaseResource> implements IResour
|
||||||
if (!versions.containsKey(versionId)) {
|
if (!versions.containsKey(versionId)) {
|
||||||
throw new ResourceNotFoundException(Msg.code(1982) + theId);
|
throw new ResourceNotFoundException(Msg.code(1982) + theId);
|
||||||
} else {
|
} else {
|
||||||
T resource = versions.get(versionId);
|
retVal = versions.get(versionId);
|
||||||
if (resource == null || ResourceMetadataKeyEnum.DELETED_AT.get(resource) != null) {
|
|
||||||
throw new ResourceGoneException(Msg.code(1983) + theId);
|
|
||||||
}
|
|
||||||
retVal = resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
retVal = versions.lastEntry().getValue();
|
retVal = versions.lastEntry().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (retVal == null || ResourceMetadataKeyEnum.DELETED_AT.get(retVal) != null) {
|
||||||
|
throw new ResourceGoneException(Msg.code(1983) + theId);
|
||||||
|
}
|
||||||
|
|
||||||
myReadCount.incrementAndGet();
|
myReadCount.incrementAndGet();
|
||||||
|
|
||||||
retVal = fireInterceptorsAndFilterAsNeeded(retVal, theRequestDetails);
|
retVal = fireInterceptorsAndFilterAsNeeded(retVal, theRequestDetails);
|
||||||
|
|
|
@ -115,8 +115,10 @@ public class HashMapResourceProviderTest {
|
||||||
|
|
||||||
assertEquals(1, myPatientResourceProvider.getCountDelete());
|
assertEquals(1, myPatientResourceProvider.getCountDelete());
|
||||||
|
|
||||||
// Read
|
// VRead original version
|
||||||
ourRestServer.getFhirClient().read().resource("Patient").withId(id.withVersion("1")).execute();
|
ourRestServer.getFhirClient().read().resource("Patient").withId(id.withVersion("1")).execute();
|
||||||
|
|
||||||
|
// Vread gone version
|
||||||
try {
|
try {
|
||||||
ourRestServer.getFhirClient().read().resource("Patient").withId(id.withVersion("2")).execute();
|
ourRestServer.getFhirClient().read().resource("Patient").withId(id.withVersion("2")).execute();
|
||||||
fail();
|
fail();
|
||||||
|
@ -124,6 +126,14 @@ public class HashMapResourceProviderTest {
|
||||||
// good
|
// 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
|
// History should include deleted entry
|
||||||
Bundle history = ourRestServer.getFhirClient().history().onType(Patient.class).returnBundle(Bundle.class).execute();
|
Bundle history = ourRestServer.getFhirClient().history().onType(Patient.class).returnBundle(Bundle.class).execute();
|
||||||
ourLog.info("History:\n{}", ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(history));
|
ourLog.info("History:\n{}", ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(history));
|
||||||
|
|
Loading…
Reference in New Issue