From 4c9df3f7b4f2dfd960818cced6e3c4f354050e12 Mon Sep 17 00:00:00 2001 From: Tadgh Date: Mon, 25 Jan 2021 11:25:47 -0500 Subject: [PATCH] Add string mimetype to resourceoperationemssage --- .../email/SubscriptionDeliveringEmailSubscriber.java | 2 +- .../rest/server/messaging/BaseResourceMessage.java | 12 ++++++++++++ .../server/messaging/ResourceOperationMessage.java | 2 ++ .../messaging/BaseResourceModifiedMessageTest.java | 5 ++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/deliver/email/SubscriptionDeliveringEmailSubscriber.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/deliver/email/SubscriptionDeliveringEmailSubscriber.java index 80750c11ecc..383b00a747b 100644 --- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/deliver/email/SubscriptionDeliveringEmailSubscriber.java +++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/deliver/email/SubscriptionDeliveringEmailSubscriber.java @@ -55,7 +55,7 @@ public class SubscriptionDeliveringEmailSubscriber extends BaseSubscriptionDeliv @Override public void handleMessage(ResourceDeliveryMessage theMessage) throws Exception { CanonicalSubscription subscription = theMessage.getSubscription(); - + // The Subscription.endpoint is treated as the email "to" String endpointUrl = subscription.getEndpointUrl(); List destinationAddresses = new ArrayList<>(); diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceMessage.java index 2126e27f3c8..0f4a4e5e124 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceMessage.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceMessage.java @@ -24,6 +24,7 @@ package ca.uhn.fhir.rest.server.messaging; import ca.uhn.fhir.model.api.IModelJson; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.net.MediaType; import org.apache.commons.lang3.Validate; import javax.annotation.Nullable; @@ -43,6 +44,9 @@ public abstract class BaseResourceMessage implements IResourceMessage, IModelJso @JsonProperty("transactionId") private String myTransactionId; + @JsonProperty("mimeType") + private String myMimeType; + /** * Returns an attribute stored in this message. *

@@ -145,6 +149,14 @@ public abstract class BaseResourceMessage implements IResourceMessage, IModelJso myTransactionId = theTransactionId; } + public String getMimeType() { + return myMimeType; + } + + public void setMimeType(String theMimeType) { + myMimeType = theMimeType; + } + public enum OperationTypeEnum { CREATE, UPDATE, diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceOperationMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceOperationMessage.java index 52c1574b7a6..1540e9f7180 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceOperationMessage.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceOperationMessage.java @@ -25,6 +25,8 @@ import ca.uhn.fhir.rest.api.server.RequestDetails; import org.hl7.fhir.instance.model.api.IBaseResource; public class ResourceOperationMessage extends BaseResourceModifiedMessage { + + public ResourceOperationMessage() { } diff --git a/hapi-fhir-server/src/test/java/ca/uhn/fhir/rest/server/messaging/BaseResourceModifiedMessageTest.java b/hapi-fhir-server/src/test/java/ca/uhn/fhir/rest/server/messaging/BaseResourceModifiedMessageTest.java index 82a6f558a7c..ce78c325b9c 100644 --- a/hapi-fhir-server/src/test/java/ca/uhn/fhir/rest/server/messaging/BaseResourceModifiedMessageTest.java +++ b/hapi-fhir-server/src/test/java/ca/uhn/fhir/rest/server/messaging/BaseResourceModifiedMessageTest.java @@ -3,6 +3,7 @@ package ca.uhn.fhir.rest.server.messaging; import ca.uhn.fhir.rest.server.messaging.json.ResourceOperationJsonMessage; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.net.MediaType; import org.junit.jupiter.api.Test; import static ca.uhn.fhir.rest.server.messaging.json.HapiMessageHeaders.FIRST_FAILURE_KEY; @@ -17,7 +18,9 @@ class ResourceOperationMessageTest { @Test public void testSerializationAndDeserializationOfResourceModifiedMessage() throws JsonProcessingException { ResourceOperationJsonMessage jsonMessage = new ResourceOperationJsonMessage(); - jsonMessage.setPayload(new ResourceOperationMessage()); + ResourceOperationMessage payload = new ResourceOperationMessage(); + payload.setMimeType("application/json+fhir"); + jsonMessage.setPayload(payload); ObjectMapper mapper = new ObjectMapper(); String serialized = mapper.writeValueAsString(jsonMessage); jsonMessage = mapper.readValue(serialized, ResourceOperationJsonMessage.class);