From ea64bea1b03fe4823cb45bcef30eb837af93b00e Mon Sep 17 00:00:00 2001
From: Tadgh
* Hooks may accept the following parameters:
*
- *
*
void
.
*
*/
- EMPI_AFTER_PERSISTED_RESOURCE_CHECKED(void.class, "ca.uhn.fhir.rest.server.messaging.BaseResourceModifiedMessage", "ca.uhn.fhir.rest.server.TransactionLogMessages"),
+ EMPI_AFTER_PERSISTED_RESOURCE_CHECKED(void.class, "ca.uhn.fhir.rest.server.messaging.ConcreteResourceModifiedMessage", "ca.uhn.fhir.rest.server.TransactionLogMessages"),
/**
* Performance Tracing Hook:
diff --git a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/broker/EmpiMessageHandler.java b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/broker/EmpiMessageHandler.java
index 2662a2a2e5e..585f88aa5c3 100644
--- a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/broker/EmpiMessageHandler.java
+++ b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/broker/EmpiMessageHandler.java
@@ -33,7 +33,7 @@ import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.rest.server.TransactionLogMessages;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
-import ca.uhn.fhir.rest.server.messaging.BaseResourceModifiedMessage;
+import ca.uhn.fhir.rest.server.messaging.ConcreteResourceModifiedMessage;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -94,10 +94,14 @@ public class EmpiMessageHandler implements MessageHandler {
}catch (Exception e) {
log(empiContext, "Failure during EMPI processing: " + e.getMessage());
} finally {
+
// Interceptor call: EMPI_AFTER_PERSISTED_RESOURCE_CHECKED
+ ConcreteResourceModifiedMessage outgoingMsg = new ConcreteResourceModifiedMessage(myFhirContext, theMsg.getPayload(myFhirContext), theMsg.getOperationType());
+ outgoingMsg.setTransactionId(theMsg.getTransactionId());
+
HookParams params = new HookParams()
//Janky upcast.
- .add(BaseResourceModifiedMessage.class, (BaseResourceModifiedMessage) theMsg)
+ .add(ConcreteResourceModifiedMessage.class,outgoingMsg)
.add(TransactionLogMessages.class, empiContext.getTransactionLogMessages());
myInterceptorBroadcaster.callHooks(Pointcut.EMPI_AFTER_PERSISTED_RESOURCE_CHECKED, params);
}
diff --git a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/broker/EmpiQueueConsumerLoader.java b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/broker/EmpiQueueConsumerLoader.java
index a620eb7eb10..647a5b2b9c4 100644
--- a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/broker/EmpiQueueConsumerLoader.java
+++ b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/broker/EmpiQueueConsumerLoader.java
@@ -5,7 +5,7 @@ import ca.uhn.fhir.empi.log.Logs;
import ca.uhn.fhir.jpa.subscription.channel.api.ChannelConsumerSettings;
import ca.uhn.fhir.jpa.subscription.channel.api.IChannelFactory;
import ca.uhn.fhir.jpa.subscription.channel.api.IChannelReceiver;
-import ca.uhn.fhir.rest.server.messaging.json.BaseResourceModifiedJsonMessage;
+import ca.uhn.fhir.rest.server.messaging.json.ConcreteResourceModifiedJsonMessage;
import com.google.common.annotations.VisibleForTesting;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -52,7 +52,7 @@ public class EmpiQueueConsumerLoader {
if (myEmpiChannel == null) {
ChannelConsumerSettings config = new ChannelConsumerSettings();
config.setConcurrentConsumers(myEmpiSettings.getConcurrentConsumers());
- myEmpiChannel = myChannelFactory.getOrCreateReceiver(IEmpiSettings.EMPI_CHANNEL_NAME, BaseResourceModifiedJsonMessage.class, config);
+ myEmpiChannel = myChannelFactory.getOrCreateReceiver(IEmpiSettings.EMPI_CHANNEL_NAME, ConcreteResourceModifiedJsonMessage.class, config);
}
if (myEmpiChannel != null) {
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/deliver/message/SubscriptionDeliveringMessageSubscriber.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/deliver/message/SubscriptionDeliveringMessageSubscriber.java
index 2239958ba10..916957f07be 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/deliver/message/SubscriptionDeliveringMessageSubscriber.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/deliver/message/SubscriptionDeliveringMessageSubscriber.java
@@ -63,7 +63,6 @@ public class SubscriptionDeliveringMessageSubscriber extends BaseSubscriptionDel
}
protected void doDelivery(ResourceDeliveryMessage theMsg, CanonicalSubscription theSubscription, IChannelProducer theChannelProducer, IBaseResource thePayloadResource) {
- //TODO GGG/KHS Question: is this the point at which we can use a BaseResourceModifiedMessage, since technically we no longer have need of a subscriptionId?
ResourceModifiedMessage payload = new ResourceModifiedMessage(myFhirContext, thePayloadResource, theMsg.getOperationType());
payload.setTransactionId(theMsg.getTransactionId());
ResourceModifiedJsonMessage message = new ResourceModifiedJsonMessage(payload);
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceModifiedMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceModifiedMessage.java
index ff90ae5b4b9..a3b9303cebe 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceModifiedMessage.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceModifiedMessage.java
@@ -17,7 +17,7 @@ import java.util.List;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
-public class BaseResourceModifiedMessage extends BaseResourceMessage implements IResourceMessage, IModelJson {
+public abstract class BaseResourceModifiedMessage extends BaseResourceMessage implements IResourceMessage, IModelJson {
@JsonProperty("resourceId")
protected String myId;
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ConcreteResourceModifiedMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ConcreteResourceModifiedMessage.java
new file mode 100644
index 00000000000..e2ff33f00ac
--- /dev/null
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ConcreteResourceModifiedMessage.java
@@ -0,0 +1,18 @@
+package ca.uhn.fhir.rest.server.messaging;
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.rest.api.server.RequestDetails;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+
+public class ConcreteResourceModifiedMessage extends BaseResourceModifiedMessage {
+ public ConcreteResourceModifiedMessage() {
+ }
+
+ public ConcreteResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
+ super(theFhirContext, theResource, theOperationType);
+ }
+
+ public ConcreteResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
+ super(theFhirContext, theNewResource, theOperationType, theRequest);
+ }
+}
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseResourceModifiedJsonMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseResourceModifiedJsonMessage.java
deleted file mode 100644
index ee1e9f47876..00000000000
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseResourceModifiedJsonMessage.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package ca.uhn.fhir.rest.server.messaging.json;
-
-import ca.uhn.fhir.rest.server.messaging.BaseResourceModifiedMessage;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
-public class BaseResourceModifiedJsonMessage extends BaseJsonMessage