Don't deliver subscription results for deleetd resource
This commit is contained in:
parent
89a834723c
commit
81305fb17f
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.jpa.subscription;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
|
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
|
||||||
|
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.r4.model.Subscription;
|
import org.hl7.fhir.r4.model.Subscription;
|
||||||
|
@ -62,7 +63,15 @@ public abstract class BaseSubscriptionDeliverySubscriber extends BaseSubscriptio
|
||||||
IIdType payloadId = msg.getPayloadId(getContext());
|
IIdType payloadId = msg.getPayloadId(getContext());
|
||||||
Class type = getContext().getResourceDefinition(payloadId.getResourceType()).getImplementingClass();
|
Class type = getContext().getResourceDefinition(payloadId.getResourceType()).getImplementingClass();
|
||||||
IFhirResourceDao dao = getSubscriptionDao().getDao(type);
|
IFhirResourceDao dao = getSubscriptionDao().getDao(type);
|
||||||
IBaseResource loadedPayload = dao.read(payloadId);
|
IBaseResource loadedPayload;
|
||||||
|
try {
|
||||||
|
loadedPayload = dao.read(payloadId);
|
||||||
|
} catch (ResourceNotFoundException e) {
|
||||||
|
// This can happen if a last minute failure happens when saving a resource,
|
||||||
|
// eg a constraint causes the transaction to roll back on commit
|
||||||
|
ourLog.warn("Unable to find resource {} - Aborting delivery", payloadId.getValue());
|
||||||
|
return;
|
||||||
|
}
|
||||||
msg.setPayload(getContext(), loadedPayload);
|
msg.setPayload(getContext(), loadedPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,18 @@ delete from hfj_spidx_uri where res_id in (select res_id from hfj_resource);
|
||||||
delete from hfj_res_tag where res_id in (select res_id from hfj_resource);
|
delete from hfj_res_tag where res_id in (select res_id from hfj_resource);
|
||||||
delete from hfj_search_result where resource_pid in (select res_id from hfj_resource);
|
delete from hfj_search_result where resource_pid in (select res_id from hfj_resource);
|
||||||
delete from hfj_res_param_present where res_id in (select res_id from hfj_resource);
|
delete from hfj_res_param_present where res_id in (select res_id from hfj_resource);
|
||||||
|
delete from hfj_idx_cmp_string_uniq where res_id in (select res_id from hfj_resource);
|
||||||
|
delete from hfj_subscription_stats where res_id in (select res_id from hfj_resource);
|
||||||
delete from hfj_resource where res_id in (select res_id from hfj_resource);
|
delete from hfj_resource where res_id in (select res_id from hfj_resource);
|
||||||
|
|
||||||
|
# Correct Version issues
|
||||||
|
update hfj_resource
|
||||||
|
set res_ver = res_ver + 1
|
||||||
|
where res_id in (
|
||||||
|
select distinct res.res_id from hfj_resource res
|
||||||
|
inner join hfj_res_ver rv on (rv.res_id = res.res_id)
|
||||||
|
where ((res.res_ver + 1) = (rv.res_ver))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue