parent
4313dc9958
commit
a308f60e16
|
@ -257,7 +257,11 @@ public class HashMapResourceProvider<T extends IBaseResource> implements IResour
|
|||
}
|
||||
|
||||
@Read(version = true)
|
||||
public synchronized T read(@IdParam IIdType theId, RequestDetails theRequestDetails) {
|
||||
public T read(@IdParam IIdType theId, RequestDetails theRequestDetails) {
|
||||
return read(theId, theRequestDetails, false);
|
||||
}
|
||||
|
||||
public synchronized T read(IIdType theId, RequestDetails theRequestDetails, boolean theDeletedOk) {
|
||||
TreeMap<Long, T> versions = myIdToVersionToResourceMap.get(theId.getIdPart());
|
||||
if (versions == null || versions.isEmpty()) {
|
||||
throw new ResourceNotFoundException(Msg.code(2247) + theId);
|
||||
|
@ -276,7 +280,9 @@ public class HashMapResourceProvider<T extends IBaseResource> implements IResour
|
|||
}
|
||||
|
||||
if (retVal == null || retVal.isDeleted()) {
|
||||
throw new ResourceGoneException(Msg.code(2244) + theId);
|
||||
if (!theDeletedOk) {
|
||||
throw new ResourceGoneException(Msg.code(2244) + theId);
|
||||
}
|
||||
}
|
||||
|
||||
myReadCount.incrementAndGet();
|
||||
|
|
|
@ -3,15 +3,13 @@ package ca.uhn.fhir.rest.server.provider;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.interceptor.api.IAnonymousInterceptor;
|
||||
import ca.uhn.fhir.interceptor.api.Pointcut;
|
||||
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ResponseValidatingInterceptor;
|
||||
import ca.uhn.fhir.test.utilities.server.HashMapResourceProviderExtension;
|
||||
import ca.uhn.fhir.test.utilities.server.RestfulServerExtension;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
import ca.uhn.fhir.validation.ResultSeverityEnum;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
|
@ -350,6 +348,29 @@ public class HashMapResourceProviderTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReadDeletedOk() {
|
||||
Patient patient = new Patient();
|
||||
patient.setActive(true);
|
||||
SystemRequestDetails srd = new SystemRequestDetails();
|
||||
|
||||
IIdType patientId = myPatientResourceProvider.create(patient, srd).getId().toVersionless();
|
||||
Patient readPatient = myPatientResourceProvider.read(patientId, srd, true);
|
||||
assertFalse(readPatient.isDeleted());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReadDeletedDeletedOk() {
|
||||
Patient patient = new Patient();
|
||||
patient.setActive(true);
|
||||
SystemRequestDetails srd = new SystemRequestDetails();
|
||||
|
||||
IIdType patientId = myPatientResourceProvider.create(patient, srd).getId().toVersionless();
|
||||
myPatientResourceProvider.delete(patientId, srd);
|
||||
Patient readPatient = myPatientResourceProvider.read(patientId, srd, true);
|
||||
assertTrue(readPatient.isDeleted());
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
TestUtil.randomizeLocaleAndTimezone();
|
||||
|
|
Loading…
Reference in New Issue