From 8ea527fa7605ae866e12d742b018682792ebd7fd Mon Sep 17 00:00:00 2001 From: James Agnew Date: Thu, 15 Feb 2018 17:13:27 -0500 Subject: [PATCH] Make sure we load subscriptions from DB at some point --- .../BaseSubscriptionDeliverySubscriber.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionDeliverySubscriber.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionDeliverySubscriber.java index b8f5439a5f1..a9fc82cab76 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionDeliverySubscriber.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionDeliverySubscriber.java @@ -21,6 +21,8 @@ package ca.uhn.fhir.jpa.subscription; */ import ca.uhn.fhir.jpa.dao.IFhirResourceDao; +import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.Subscription; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,6 +53,16 @@ public abstract class BaseSubscriptionDeliverySubscriber extends BaseSubscriptio msg.setSubscription(updatedSubscription); } + // Reload the payload just in case any interceptors modified + // it before it was saved to the database. This is also + // useful for resources created in a transaction, since they + // can have placeholder IDs in them. + IIdType payloadId = msg.getPayloadId(getContext()); + Class type = Class.forName(payloadId.getResourceType()); + IFhirResourceDao dao = getSubscriptionDao().getDao(type); + IBaseResource loadedPayload = dao.read(payloadId); + msg.setPayload(getContext(), loadedPayload); + handleMessage(msg); } catch (Exception e) { ourLog.error("Failure handling subscription payload", e);