+ * Attributes are just a spot for user data of any kind to be
+ * added to the message for pasing along the subscription processing
+ * pipeline (typically by interceptors). Values will be carried from the beginning to the end.
+ *
+ *
+ * Note that messages are designed to be passed into queueing systems
+ * and serialized as JSON. As a result, only strings are currently allowed
+ * as values.
+ *
+ */
+ public Optional getAttribute(String theKey) {
+ Validate.notBlank(theKey);
+ if (myAttributes == null) {
+ return Optional.empty();
+ }
+ return Optional.ofNullable(myAttributes.get(theKey));
+ }
+
+ /**
+ * Sets an attribute stored in this message.
+ *
+ * Attributes are just a spot for user data of any kind to be
+ * added to the message for passing along the subscription processing
+ * pipeline (typically by interceptors). Values will be carried from the beginning to the end.
+ *
+ *
+ * Note that messages are designed to be passed into queueing systems
+ * and serialized as JSON. As a result, only strings are currently allowed
+ * as values.
+ *
+ *
+ * @param theKey The key (must not be null or blank)
+ * @param theValue The value (must not be null)
+ */
+ public void setAttribute(String theKey, String theValue) {
+ Validate.notBlank(theKey);
+ Validate.notNull(theValue);
+ if (myAttributes == null) {
+ myAttributes = new HashMap<>();
+ }
+ myAttributes.put(theKey, theValue);
+ }
+
+ /**
+ * Copies any attributes from the given message into this messsage.
+ *
+ * @see #setAttribute(String, String)
+ * @see #getAttribute(String)
+ */
+ public void copyAdditionalPropertiesFrom(LegacyBaseResourceMessage theMsg) {
+ if (theMsg.myAttributes != null) {
+ if (myAttributes == null) {
+ myAttributes = new HashMap<>();
+ }
+ myAttributes.putAll(theMsg.myAttributes);
+ }
+ }
+}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedJsonMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedJsonMessage.java
new file mode 100644
index 00000000000..821af831bbc
--- /dev/null
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedJsonMessage.java
@@ -0,0 +1,60 @@
+package ca.uhn.fhir.jpa.subscription.model;
+
+/*-
+ * #%L
+ * HAPI FHIR Subscription Server
+ * %%
+ * Copyright (C) 2014 - 2020 University Health Network
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+public class LegacyResourceModifiedJsonMessage extends BaseJsonMessage {
+
+ @JsonProperty("payload")
+ private LegacyResourceModifiedMessage myPayload;
+
+ /**
+ * Constructor
+ */
+ public LegacyResourceModifiedJsonMessage() {
+ super();
+ }
+
+ /**
+ * Constructor
+ */
+ public LegacyResourceModifiedJsonMessage(LegacyResourceModifiedMessage thePayload) {
+ myPayload = thePayload;
+ }
+
+ @Override
+ public LegacyResourceModifiedMessage getPayload() {
+ return myPayload;
+ }
+
+ public void setPayload(LegacyResourceModifiedMessage thePayload) {
+ myPayload = thePayload;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("myPayload", myPayload)
+ .toString();
+ }
+}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedMessage.java
new file mode 100644
index 00000000000..f2e8c543889
--- /dev/null
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedMessage.java
@@ -0,0 +1,198 @@
+package ca.uhn.fhir.jpa.subscription.model;
+
+/*-
+ * #%L
+ * HAPI FHIR Subscription Server
+ * %%
+ * Copyright (C) 2014 - 2020 University Health Network
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.model.api.IModelJson;
+import ca.uhn.fhir.rest.api.server.RequestDetails;
+import ca.uhn.fhir.util.ResourceReferenceInfo;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+import org.hl7.fhir.instance.model.api.IIdType;
+
+import java.util.List;
+
+import static org.apache.commons.lang3.StringUtils.isBlank;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
+
+public class LegacyResourceModifiedMessage extends LegacyBaseResourceMessage implements IResourceMessage, IModelJson {
+
+ @JsonProperty("resourceId")
+ private String myId;
+ @JsonProperty("operationType")
+ private OperationTypeEnum myOperationType;
+ /**
+ * This will only be set if the resource is being triggered for a specific
+ * subscription
+ */
+ @JsonProperty(value = "subscriptionId", required = false)
+ private String mySubscriptionId;
+ @JsonProperty("payload")
+ private String myPayload;
+ @JsonProperty("payloadId")
+ private String myPayloadId;
+ @JsonProperty("parentTransactionGuid")
+ private String myParentTransactionGuid;
+ @JsonIgnore
+ private transient IBaseResource myPayloadDecoded;
+
+ /**
+ * Constructor
+ */
+ public LegacyResourceModifiedMessage() {
+ super();
+ }
+
+ public LegacyResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
+ this();
+ setId(theResource.getIdElement());
+ setOperationType(theOperationType);
+ if (theOperationType != OperationTypeEnum.DELETE) {
+ setNewPayload(theFhirContext, theResource);
+ }
+ }
+
+ public LegacyResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
+ this(theFhirContext, theNewResource, theOperationType);
+ if (theRequest != null) {
+ setParentTransactionGuid(theRequest.getTransactionGuid());
+ }
+ }
+
+ @Override
+ public String getPayloadId() {
+ return myPayloadId;
+ }
+
+ public String getSubscriptionId() {
+ return mySubscriptionId;
+ }
+
+ public void setSubscriptionId(String theSubscriptionId) {
+ mySubscriptionId = theSubscriptionId;
+ }
+
+ public String getId() {
+ return myId;
+ }
+
+ public IIdType getId(FhirContext theCtx) {
+ IIdType retVal = null;
+ if (myId != null) {
+ retVal = theCtx.getVersion().newIdType().setValue(myId);
+ }
+ return retVal;
+ }
+
+ public IBaseResource getNewPayload(FhirContext theCtx) {
+ if (myPayloadDecoded == null && isNotBlank(myPayload)) {
+ myPayloadDecoded = theCtx.newJsonParser().parseResource(myPayload);
+ }
+ return myPayloadDecoded;
+ }
+
+ public OperationTypeEnum getOperationType() {
+ return myOperationType;
+ }
+
+ public void setOperationType(OperationTypeEnum theOperationType) {
+ myOperationType = theOperationType;
+ }
+
+ public void setId(IIdType theId) {
+ myId = null;
+ if (theId != null) {
+ myId = theId.getValue();
+ }
+ }
+
+ public String getParentTransactionGuid() {
+ return myParentTransactionGuid;
+ }
+
+ public void setParentTransactionGuid(String theParentTransactionGuid) {
+ myParentTransactionGuid = theParentTransactionGuid;
+ }
+
+ private void setNewPayload(FhirContext theCtx, IBaseResource theNewPayload) {
+ /*
+ * References with placeholders would be invalid by the time we get here, and
+ * would be caught before we even get here. This check is basically a last-ditch
+ * effort to make sure nothing has broken in the various safeguards that
+ * should prevent this from happening (hence it only being an assert as
+ * opposed to something executed all the time).
+ */
+ assert payloadContainsNoPlaceholderReferences(theCtx, theNewPayload);
+
+ /*
+ * Note: Don't set myPayloadDecoded in here- This is a false optimization since
+ * it doesn't actually get used if anyone is doing subscriptions at any
+ * scale using a queue engine, and not going through the serialize/deserialize
+ * as we would in a queue engine can mask bugs.
+ * -JA
+ */
+ myPayload = theCtx.newJsonParser().encodeResourceToString(theNewPayload);
+ myPayloadId = theNewPayload.getIdElement().toUnqualified().getValue();
+ }
+
+ public enum OperationTypeEnum {
+ CREATE,
+ UPDATE,
+ DELETE,
+ MANUALLY_TRIGGERED
+ }
+
+ private static boolean payloadContainsNoPlaceholderReferences(FhirContext theCtx, IBaseResource theNewPayload) {
+ List refs = theCtx.newTerser().getAllResourceReferences(theNewPayload);
+ for (ResourceReferenceInfo next : refs) {
+ String ref = next.getResourceReference().getReferenceElement().getValue();
+ if (isBlank(ref)) {
+ IBaseResource resource = next.getResourceReference().getResource();
+ if (resource != null) {
+ ref = resource.getIdElement().getValue();
+ }
+ }
+ if (isNotBlank(ref)) {
+ if (ref.startsWith("#")) {
+ continue;
+ }
+ if (ref.startsWith("urn:uuid:")) {
+ throw new AssertionError("Reference at " + next.getName() + " is invalid: " + ref);
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("myId", myId)
+ .append("myOperationType", myOperationType)
+ .append("mySubscriptionId", mySubscriptionId)
+// .append("myPayload", myPayload)
+ .append("myPayloadId", myPayloadId)
+// .append("myPayloadDecoded", myPayloadDecoded)
+ .toString();
+ }
+}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryMessage.java
index 9d990f53bca..aff2b34ed65 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryMessage.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryMessage.java
@@ -23,6 +23,8 @@ package ca.uhn.fhir.jpa.subscription.model;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.api.EncodingEnum;
+import ca.uhn.fhir.rest.server.messaging.BaseResourceMessage;
+import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionMatcherInterceptor.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionMatcherInterceptor.java
index 51e01bd6c69..a147fe9da12 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionMatcherInterceptor.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionMatcherInterceptor.java
@@ -10,10 +10,10 @@ import ca.uhn.fhir.jpa.subscription.channel.impl.LinkedBlockingChannel;
import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelFactory;
import ca.uhn.fhir.jpa.subscription.match.matcher.matching.IResourceModifiedConsumer;
import ca.uhn.fhir.jpa.subscription.match.matcher.subscriber.SubscriptionMatchingSubscriber;
-import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.jpa.util.JpaInterceptorBroadcaster;
import ca.uhn.fhir.rest.api.server.RequestDetails;
+import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.IBaseResource;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java
index 36723118bfb..f966ed90655 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java
@@ -26,21 +26,22 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc;
-import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
import ca.uhn.fhir.jpa.model.sched.HapiJob;
import ca.uhn.fhir.jpa.model.sched.ISchedulerService;
import ca.uhn.fhir.jpa.model.sched.ScheduledJobDefinition;
import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.jpa.subscription.match.matcher.matching.IResourceModifiedConsumer;
-import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.api.CacheControlDirective;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
+import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
+import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
+import ca.uhn.fhir.rest.server.messaging.ResourceModifiedSubscriptionMessage;
import ca.uhn.fhir.util.ParametersUtil;
import ca.uhn.fhir.util.StopWatch;
import ca.uhn.fhir.util.UrlUtil;
@@ -306,7 +307,7 @@ public class SubscriptionTriggeringSvcImpl implements ISubscriptionTriggeringSvc
ourLog.info("Submitting resource {} to subscription {}", theResourceToTrigger.getIdElement().toUnqualifiedVersionless().getValue(), theSubscriptionId);
- ResourceModifiedMessage msg = new ResourceModifiedMessage(myFhirContext, theResourceToTrigger, ResourceModifiedMessage.OperationTypeEnum.UPDATE);
+ ResourceModifiedSubscriptionMessage msg = new ResourceModifiedSubscriptionMessage(myFhirContext, theResourceToTrigger, ResourceModifiedMessage.OperationTypeEnum.UPDATE);
msg.setSubscriptionId(theSubscriptionId);
return myExecutorService.submit(() -> {
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java
index 288ad03b2d5..1f14b47f494 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java
@@ -25,8 +25,8 @@ import ca.uhn.fhir.interceptor.api.Interceptor;
import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType;
-import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
+import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import ca.uhn.fhir.util.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/channel/subscription/BroadcastingSubscribableChannelWrapperTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/channel/subscription/BroadcastingSubscribableChannelWrapperTest.java
index 4c29d2b86ad..a48f44b12dd 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/channel/subscription/BroadcastingSubscribableChannelWrapperTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/channel/subscription/BroadcastingSubscribableChannelWrapperTest.java
@@ -1,8 +1,8 @@
package ca.uhn.fhir.jpa.subscription.channel.subscription;
import ca.uhn.fhir.jpa.subscription.channel.api.IChannelReceiver;
-import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
+import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/deliver/BaseSubscriptionDeliverySubscriberTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/deliver/BaseSubscriptionDeliverySubscriberTest.java
index 512bb0a42a8..f1aee3f5541 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/deliver/BaseSubscriptionDeliverySubscriberTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/deliver/BaseSubscriptionDeliverySubscriberTest.java
@@ -3,33 +3,35 @@ package ca.uhn.fhir.jpa.subscription.match.deliver;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.interceptor.api.Pointcut;
+import ca.uhn.fhir.jpa.subscription.match.deliver.resthook.SubscriptionDeliveringRestHookSubscriber;
+import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryJsonMessage;
import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
-import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.match.deliver.resthook.SubscriptionDeliveringRestHookSubscriber;
-import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.api.IRestfulClientFactory;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
+import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Patient;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.support.GenericMessage;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
public class BaseSubscriptionDeliverySubscriberTest {
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/ResourceModifiedTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/ResourceModifiedTest.java
index ebe2b40c684..728510cf7a2 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/ResourceModifiedTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/ResourceModifiedTest.java
@@ -1,7 +1,7 @@
package ca.uhn.fhir.jpa.subscription.module;
import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
+import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import org.hl7.fhir.r4.model.Organization;
import org.junit.jupiter.api.Test;
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java
index 743be4dc972..6a5a10dc7bd 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java
@@ -113,7 +113,6 @@ public class InMemorySubscriptionMatcherR3Test extends BaseSubscriptionDstu3Test
pr.setSubject(new Reference("Patient/"));
assertMatched(pr, "ProcedureRequest?intent=original-order");
assertNotMatched(pr, "ProcedureRequest?subject=Patient/123");
-
}
@Test
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/BaseBlockingQueueSubscribableChannelDstu3Test.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/BaseBlockingQueueSubscribableChannelDstu3Test.java
index aaa6e1c0276..c2bdd952529 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/BaseBlockingQueueSubscribableChannelDstu3Test.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/BaseBlockingQueueSubscribableChannelDstu3Test.java
@@ -11,8 +11,6 @@ import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionLoader;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType;
-import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.jpa.subscription.module.BaseSubscriptionDstu3Test;
import ca.uhn.fhir.jpa.subscription.module.subscriber.SubscriptionMatchingSubscriberTest;
import ca.uhn.fhir.model.primitive.IdDt;
@@ -23,6 +21,8 @@ import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
+import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import ca.uhn.fhir.test.utilities.JettyUtil;
import ca.uhn.test.concurrency.IPointcutLatch;
import ca.uhn.test.concurrency.PointcutLatch;
diff --git a/hapi-fhir-server/pom.xml b/hapi-fhir-server/pom.xml
index e57afa70464..bcbf3a23dc0 100644
--- a/hapi-fhir-server/pom.xml
+++ b/hapi-fhir-server/pom.xml
@@ -73,8 +73,12 @@
org.apache.commonscommons-collections4
+
+ org.springframework
+ spring-messaging
+
-
+
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseResourceMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceMessage.java
similarity index 98%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseResourceMessage.java
rename to hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceMessage.java
index ba753078243..0b778c76521 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseResourceMessage.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceMessage.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.model;
+package ca.uhn.fhir.rest.server.messaging;
/*-
* #%L
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/IResourceMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/IResourceMessage.java
new file mode 100644
index 00000000000..d06e6e51789
--- /dev/null
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/IResourceMessage.java
@@ -0,0 +1,25 @@
+package ca.uhn.fhir.rest.server.messaging;
+
+/*-
+ * #%L
+ * HAPI FHIR Subscription Server
+ * %%
+ * Copyright (C) 2014 - 2020 University Health Network
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+public interface IResourceMessage {
+ String getPayloadId();
+}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedMessage.java
similarity index 81%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedMessage.java
rename to hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedMessage.java
index 28bd066cb02..8767e7e5895 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedMessage.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedMessage.java
@@ -1,24 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.model;
-
-/*-
- * #%L
- * HAPI FHIR Subscription Server
- * %%
- * Copyright (C) 2014 - 2020 University Health Network
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
+package ca.uhn.fhir.rest.server.messaging;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IModelJson;
@@ -41,12 +21,6 @@ public class ResourceModifiedMessage extends BaseResourceMessage implements IRes
private String myId;
@JsonProperty("operationType")
private OperationTypeEnum myOperationType;
- /**
- * This will only be set if the resource is being triggered for a specific
- * subscription
- */
- @JsonProperty(value = "subscriptionId", required = false)
- private String mySubscriptionId;
@JsonProperty("payload")
private String myPayload;
@JsonProperty("payloadId")
@@ -84,14 +58,6 @@ public class ResourceModifiedMessage extends BaseResourceMessage implements IRes
return myPayloadId;
}
- public String getSubscriptionId() {
- return mySubscriptionId;
- }
-
- public void setSubscriptionId(String theSubscriptionId) {
- mySubscriptionId = theSubscriptionId;
- }
-
public String getId() {
return myId;
}
@@ -189,10 +155,10 @@ public class ResourceModifiedMessage extends BaseResourceMessage implements IRes
return new ToStringBuilder(this)
.append("myId", myId)
.append("myOperationType", myOperationType)
- .append("mySubscriptionId", mySubscriptionId)
// .append("myPayload", myPayload)
.append("myPayloadId", myPayloadId)
// .append("myPayloadDecoded", myPayloadDecoded)
.toString();
}
}
+
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedSubscriptionMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedSubscriptionMessage.java
new file mode 100644
index 00000000000..9fe55618f7e
--- /dev/null
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedSubscriptionMessage.java
@@ -0,0 +1,36 @@
+package ca.uhn.fhir.rest.server.messaging;
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.rest.api.server.RequestDetails;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+
+public class ResourceModifiedSubscriptionMessage extends ResourceModifiedMessage {
+
+ /**
+ * This will only be set if the resource is being triggered for a specific
+ * subscription
+ */
+ @JsonProperty(value = "subscriptionId", required = false)
+ private String mySubscriptionId;
+
+ public ResourceModifiedSubscriptionMessage() {
+ }
+
+ public ResourceModifiedSubscriptionMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
+ super(theFhirContext, theResource, theOperationType);
+ }
+
+ public ResourceModifiedSubscriptionMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
+ super(theFhirContext, theNewResource, theOperationType, theRequest);
+ }
+
+ public String getSubscriptionId() {
+ return mySubscriptionId;
+ }
+
+ public void setSubscriptionId(String theSubscriptionId) {
+ mySubscriptionId = theSubscriptionId;
+ }
+
+}
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseJsonMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseJsonMessage.java
new file mode 100644
index 00000000000..40d7d7e487e
--- /dev/null
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseJsonMessage.java
@@ -0,0 +1,49 @@
+package ca.uhn.fhir.rest.server.messaging.json;
+
+/*-
+ * #%L
+ * HAPI FHIR Subscription Server
+ * %%
+ * Copyright (C) 2014 - 2020 University Health Network
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import ca.uhn.fhir.model.api.IModelJson;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.MessageHeaders;
+
+public abstract class BaseJsonMessage implements Message, IModelJson {
+
+ private static final long serialVersionUID = 1L;
+ @JsonProperty("headers")
+ private MessageHeaders myHeaders;
+
+ /**
+ * Constructor
+ */
+ public BaseJsonMessage() {
+ super();
+ }
+
+ @Override
+ public MessageHeaders getHeaders() {
+ return myHeaders;
+ }
+
+ public void setHeaders(MessageHeaders theHeaders) {
+ myHeaders = theHeaders;
+ }
+}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedJsonMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedJsonMessage.java
similarity index 92%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedJsonMessage.java
rename to hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedJsonMessage.java
index f8b8407d686..59ce15b7425 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedJsonMessage.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedJsonMessage.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.model;
+package ca.uhn.fhir.rest.server.messaging.json;
/*-
* #%L
@@ -20,6 +20,7 @@ package ca.uhn.fhir.jpa.subscription.model;
* #L%
*/
+import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedSubscriptionJsonMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedSubscriptionJsonMessage.java
new file mode 100644
index 00000000000..7f19ee426b1
--- /dev/null
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedSubscriptionJsonMessage.java
@@ -0,0 +1,61 @@
+package ca.uhn.fhir.rest.server.messaging.json;
+
+/*-
+ * #%L
+ * HAPI FHIR Subscription Server
+ * %%
+ * Copyright (C) 2014 - 2020 University Health Network
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import ca.uhn.fhir.rest.server.messaging.ResourceModifiedSubscriptionMessage;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+public class ResourceModifiedSubscriptionJsonMessage extends BaseJsonMessage {
+
+ @JsonProperty("payload")
+ private ResourceModifiedSubscriptionMessage myPayload;
+
+ /**
+ * Constructor
+ */
+ public ResourceModifiedSubscriptionJsonMessage() {
+ super();
+ }
+
+ /**
+ * Constructor
+ */
+ public ResourceModifiedSubscriptionJsonMessage(ResourceModifiedSubscriptionMessage thePayload) {
+ myPayload = thePayload;
+ }
+
+ @Override
+ public ResourceModifiedSubscriptionMessage getPayload() {
+ return myPayload;
+ }
+
+ public void setPayload(ResourceModifiedSubscriptionMessage thePayload) {
+ myPayload = thePayload;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("myPayload", myPayload)
+ .toString();
+ }
+}
From 28a9a53917d324c71910c3dca50c7dfd6afe7270 Mon Sep 17 00:00:00 2001
From: Tadgh
Date: Thu, 10 Sep 2020 16:05:56 -0400
Subject: [PATCH 03/25] Rework to keep several things in subscription
---
.../ca/uhn/fhir/interceptor/api/Pointcut.java | 4 +-
.../InMemorySubscriptionMatcherR4Test.java | 5 +-
.../RestHookWithInterceptorR4Test.java | 2 +-
.../jpa/empi/broker/EmpiMessageHandler.java | 9 +-
.../empi/broker/EmpiQueueConsumerLoader.java | 4 +-
.../empi/svc/EmpiChannelSubmitterSvcImpl.java | 4 +-
.../SubscriptionChannelFactory.java | 2 +-
...bscriptionDeliveringMessageSubscriber.java | 5 +-
...mpositeInMemoryDaoSubscriptionMatcher.java | 2 +-
.../matching/DaoSubscriptionMatcher.java | 2 +-
.../matching/IResourceModifiedConsumer.java | 2 +-
.../matching/ISubscriptionMatcher.java | 3 +-
.../matching/InMemorySubscriptionMatcher.java | 2 +-
...aseSubscriberForSubscriptionResources.java | 2 +-
.../SubscriptionActivatingSubscriber.java | 4 +-
.../SubscriptionMatchingSubscriber.java | 13 +-
.../SubscriptionRegisteringSubscriber.java | 4 +-
.../subscription/model/BaseJsonMessage.java | 49 -----
.../subscription/model/IResourceMessage.java | 25 ---
.../model/LegacyBaseResourceMessage.java | 97 ---------
.../LegacyResourceModifiedJsonMessage.java | 60 ------
.../model/LegacyResourceModifiedMessage.java | 198 ------------------
.../model/ResourceDeliveryJsonMessage.java | 1 +
.../model/ResourceDeliveryMessage.java | 2 +-
.../model}/ResourceModifiedJsonMessage.java | 4 +-
.../model/ResourceModifiedMessage.java | 78 +++++++
.../SubscriptionMatcherInterceptor.java | 4 +-
.../SubscriptionTriggeringSvcImpl.java | 5 +-
.../util/SubscriptionDebugLogInterceptor.java | 2 +-
...castingSubscribableChannelWrapperTest.java | 4 +-
...aseSubscriptionDeliverySubscriberTest.java | 2 +-
.../module/ResourceModifiedTest.java | 2 +-
...kingQueueSubscribableChannelDstu3Test.java | 4 +-
....java => BaseResourceModifiedMessage.java} | 44 ++--
.../ResourceModifiedSubscriptionMessage.java | 36 ----
.../messaging/json/BaseJsonMessage.java | 34 +++
...a => BaseResourceModifiedJsonMessage.java} | 23 +-
37 files changed, 210 insertions(+), 533 deletions(-)
delete mode 100644 hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseJsonMessage.java
delete mode 100644 hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/IResourceMessage.java
delete mode 100644 hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyBaseResourceMessage.java
delete mode 100644 hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedJsonMessage.java
delete mode 100644 hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedMessage.java
rename {hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json => hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model}/ResourceModifiedJsonMessage.java (92%)
create mode 100644 hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedMessage.java
rename hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/{ResourceModifiedMessage.java => BaseResourceModifiedMessage.java} (75%)
delete mode 100644 hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedSubscriptionMessage.java
rename hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/{ResourceModifiedSubscriptionJsonMessage.java => BaseResourceModifiedJsonMessage.java} (61%)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/api/Pointcut.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/api/Pointcut.java
index ec6bf9ee932..b027997a100 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/api/Pointcut.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/api/Pointcut.java
@@ -1620,7 +1620,7 @@ public enum Pointcut {
*
* Hooks may accept the following parameters:
*
- *
ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage - This parameter should not be modified as processing is complete when this hook is invoked.
+ *
ca.uhn.fhir.rest.server.messaging.BaseResourceModifiedMessage- This parameter should not be modified as processing is complete when this hook is invoked.
*
ca.uhn.fhir.empi.model.TransactionLogMessages - This parameter is for informational messages provided by the EMPI module during EMPI procesing. .
*
*
@@ -1628,7 +1628,7 @@ public enum Pointcut {
* Hooks should return void.
*
*/
- EMPI_AFTER_PERSISTED_RESOURCE_CHECKED(void.class, "ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage", "ca.uhn.fhir.rest.server.TransactionLogMessages"),
+ EMPI_AFTER_PERSISTED_RESOURCE_CHECKED(void.class, "ca.uhn.fhir.rest.server.messaging.BaseResourceModifiedMessage", "ca.uhn.fhir.rest.server.TransactionLogMessages"),
/**
* Performance Tracing Hook:
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR4Test.java
index c930738ecb8..439f51a2a19 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR4Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR4Test.java
@@ -11,6 +11,7 @@ import ca.uhn.fhir.jpa.subscription.match.matcher.matching.InMemorySubscriptionM
import ca.uhn.fhir.jpa.subscription.match.matcher.matching.SubscriptionMatchingStrategy;
import ca.uhn.fhir.jpa.subscription.match.matcher.matching.SubscriptionStrategyEvaluator;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.jpa.util.CoordCalculatorTest;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import ca.uhn.fhir.rest.param.CompositeParam;
@@ -29,8 +30,6 @@ import ca.uhn.fhir.rest.param.TokenOrListParam;
import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.param.TokenParamModifier;
import ca.uhn.fhir.rest.param.UriParam;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedSubscriptionMessage;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource;
@@ -466,7 +465,7 @@ public class InMemorySubscriptionMatcherR4Test {
CanonicalSubscription subscription = new CanonicalSubscription();
subscription.setCriteriaString(criteria);
subscription.setIdElement(new IdType("Subscription", 123L));
- ResourceModifiedSubscriptionMessage msg = new ResourceModifiedSubscriptionMessage(myFhirContext, patient, ResourceModifiedMessage.OperationTypeEnum.CREATE);
+ ResourceModifiedMessage msg = new ResourceModifiedMessage(myFhirContext, patient, ResourceModifiedMessage.OperationTypeEnum.CREATE);
msg.setSubscriptionId("123");
msg.setId(new IdType("Patient/ABC"));
InMemoryMatchResult result = myInMemorySubscriptionMatcher.match(subscription, msg);
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java
index cc79578577c..faa775e0771 100755
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java
@@ -10,10 +10,10 @@ import ca.uhn.fhir.jpa.config.StoppableSubscriptionDeliveringRestHookSubscriber;
import ca.uhn.fhir.jpa.subscription.BaseSubscriptionsR4Test;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.jpa.subscription.util.SubscriptionDebugLogInterceptor;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.MethodOutcome;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Observation;
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 94d18540f75..15e7aebc5f4 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
@@ -29,10 +29,11 @@ import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.empi.svc.EmpiMatchLinkSvc;
import ca.uhn.fhir.jpa.empi.svc.EmpiResourceFilteringSvc;
+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.json.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
+import ca.uhn.fhir.rest.server.messaging.BaseResourceModifiedMessage;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -58,6 +59,7 @@ public class EmpiMessageHandler implements MessageHandler {
public void handleMessage(Message> theMessage) throws MessagingException {
ourLog.info("Handling resource modified message: {}", theMessage);
+ //TODO GGG TEST THAT THE MESSAGE HEADERS COME IN HERE
if (!(theMessage instanceof ResourceModifiedJsonMessage)) {
ourLog.warn("Unexpected message payload type: {}", theMessage);
return;
@@ -95,7 +97,8 @@ public class EmpiMessageHandler implements MessageHandler {
} finally {
// Interceptor call: EMPI_AFTER_PERSISTED_RESOURCE_CHECKED
HookParams params = new HookParams()
- .add(ResourceModifiedMessage.class, theMsg)
+ //Janky upcast.
+ .add(BaseResourceModifiedMessage.class, (BaseResourceModifiedMessage) theMsg)
.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 1e83444a464..a620eb7eb10 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.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.rest.server.messaging.json.BaseResourceModifiedJsonMessage;
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, ResourceModifiedJsonMessage.class, config);
+ myEmpiChannel = myChannelFactory.getOrCreateReceiver(IEmpiSettings.EMPI_CHANNEL_NAME, BaseResourceModifiedJsonMessage.class, config);
}
if (myEmpiChannel != null) {
diff --git a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiChannelSubmitterSvcImpl.java b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiChannelSubmitterSvcImpl.java
index 6ebd4747e9f..05ae109316a 100644
--- a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiChannelSubmitterSvcImpl.java
+++ b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiChannelSubmitterSvcImpl.java
@@ -24,8 +24,8 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.empi.api.IEmpiChannelSubmitterSvc;
import ca.uhn.fhir.jpa.subscription.channel.api.ChannelProducerSettings;
import ca.uhn.fhir.jpa.subscription.channel.api.IChannelFactory;
-import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/channel/subscription/SubscriptionChannelFactory.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/channel/subscription/SubscriptionChannelFactory.java
index fe0b18020e8..a8abc0394eb 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/channel/subscription/SubscriptionChannelFactory.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/channel/subscription/SubscriptionChannelFactory.java
@@ -27,7 +27,7 @@ import ca.uhn.fhir.jpa.subscription.channel.api.IChannelProducer;
import ca.uhn.fhir.jpa.subscription.channel.api.IChannelReceiver;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionConstants;
import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryJsonMessage;
-import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
import org.apache.commons.lang3.Validate;
public class SubscriptionChannelFactory {
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 ccf096bb7f9..9b47757d8aa 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
@@ -28,9 +28,9 @@ import ca.uhn.fhir.jpa.subscription.channel.api.IChannelProducer;
import ca.uhn.fhir.jpa.subscription.match.deliver.BaseSubscriptionDeliverySubscriber;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.rest.api.EncodingEnum;
-import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,6 +63,7 @@ public class SubscriptionDeliveringMessageSubscriber extends BaseSubscriptionDel
}
protected void doDelivery(ResourceDeliveryMessage theMsg, CanonicalSubscription theSubscription, IChannelProducer theChannelProducer, IBaseResource thePayloadResource) {
+ //TODO GGG 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.setParentTransactionGuid(theMsg.getParentTransactionGuid());
ResourceModifiedJsonMessage message = new ResourceModifiedJsonMessage(payload);
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/CompositeInMemoryDaoSubscriptionMatcher.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/CompositeInMemoryDaoSubscriptionMatcher.java
index b9833dc1b1e..18351b3b5e7 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/CompositeInMemoryDaoSubscriptionMatcher.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/CompositeInMemoryDaoSubscriptionMatcher.java
@@ -23,7 +23,7 @@ package ca.uhn.fhir.jpa.subscription.match.matcher.matching;
import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/DaoSubscriptionMatcher.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/DaoSubscriptionMatcher.java
index 057eda8a377..87a69f109ca 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/DaoSubscriptionMatcher.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/DaoSubscriptionMatcher.java
@@ -28,8 +28,8 @@ import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.slf4j.Logger;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/IResourceModifiedConsumer.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/IResourceModifiedConsumer.java
index 2de668f2bdc..e02a5bdd82d 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/IResourceModifiedConsumer.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/IResourceModifiedConsumer.java
@@ -20,8 +20,8 @@ package ca.uhn.fhir.jpa.subscription.match.matcher.matching;
* #L%
*/
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.rest.api.server.RequestDetails;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import org.hl7.fhir.instance.model.api.IBaseResource;
public interface IResourceModifiedConsumer {
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/ISubscriptionMatcher.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/ISubscriptionMatcher.java
index 091202c2730..0880bbadfb9 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/ISubscriptionMatcher.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/ISubscriptionMatcher.java
@@ -22,9 +22,8 @@ package ca.uhn.fhir.jpa.subscription.match.matcher.matching;
import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
public interface ISubscriptionMatcher {
- //TODO GGG convert this to a ResourceModifiedSubscriptionMessage
InMemoryMatchResult match(CanonicalSubscription subscription, ResourceModifiedMessage msg);
}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/InMemorySubscriptionMatcher.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/InMemorySubscriptionMatcher.java
index 159d579cd7e..5eb0d304e9b 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/InMemorySubscriptionMatcher.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/InMemorySubscriptionMatcher.java
@@ -24,8 +24,8 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult;
import ca.uhn.fhir.jpa.searchparam.matcher.SearchParamMatcher;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/BaseSubscriberForSubscriptionResources.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/BaseSubscriberForSubscriptionResources.java
index 419be6b1c8e..c54a6b93113 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/BaseSubscriberForSubscriptionResources.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/BaseSubscriberForSubscriptionResources.java
@@ -21,8 +21,8 @@ package ca.uhn.fhir.jpa.subscription.match.matcher.subscriber;
*/
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionActivatingSubscriber.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionActivatingSubscriber.java
index cb4bc02f3f1..2a61ee8a1d0 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionActivatingSubscriber.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionActivatingSubscriber.java
@@ -28,9 +28,9 @@ import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionCanonicalizer;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionConstants;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
-import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import ca.uhn.fhir.util.SubscriptionUtil;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.slf4j.Logger;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionMatchingSubscriber.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionMatchingSubscriber.java
index da896a6c32f..d54f94020fc 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionMatchingSubscriber.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionMatchingSubscriber.java
@@ -12,10 +12,9 @@ import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryJsonMessage;
import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.rest.api.EncodingEnum;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
-import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedSubscriptionJsonMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedSubscriptionMessage;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
@@ -81,16 +80,16 @@ public class SubscriptionMatchingSubscriber implements MessageHandler {
ourLog.trace("Handling resource modified message: {}", theMessage);
//TODO ADD BACKPORT FOR HANDLING OLD LEGACY SUBSCRIPTIONS HERE
- if (!(theMessage instanceof ResourceModifiedSubscriptionJsonMessage)) {
+ if (!(theMessage instanceof ResourceModifiedJsonMessage)) {
ourLog.warn("Unexpected message payload type: {}", theMessage);
return;
}
- ResourceModifiedSubscriptionMessage msg = ((ResourceModifiedSubscriptionJsonMessage) theMessage).getPayload();
+ ResourceModifiedMessage msg = ((ResourceModifiedJsonMessage) theMessage).getPayload();
matchActiveSubscriptionsAndDeliver(msg);
}
- public void matchActiveSubscriptionsAndDeliver(ResourceModifiedSubscriptionMessage theMsg) {
+ public void matchActiveSubscriptionsAndDeliver(ResourceModifiedMessage theMsg) {
switch (theMsg.getOperationType()) {
case CREATE:
case UPDATE:
@@ -118,7 +117,7 @@ public class SubscriptionMatchingSubscriber implements MessageHandler {
}
}
- private void doMatchActiveSubscriptionsAndDeliver(ResourceModifiedSubscriptionMessage theMsg) {
+ private void doMatchActiveSubscriptionsAndDeliver(ResourceModifiedMessage theMsg) {
IIdType resourceId = theMsg.getId(myFhirContext);
Collection subscriptions = mySubscriptionRegistry.getAll();
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionRegisteringSubscriber.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionRegisteringSubscriber.java
index cff765be02f..a8b6208fd44 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionRegisteringSubscriber.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/matcher/subscriber/SubscriptionRegisteringSubscriber.java
@@ -23,8 +23,8 @@ package ca.uhn.fhir.jpa.subscription.match.matcher.subscriber;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionCanonicalizer;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry;
-import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseJsonMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseJsonMessage.java
deleted file mode 100644
index 1bb28358726..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseJsonMessage.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.model;
-
-/*-
- * #%L
- * HAPI FHIR Subscription Server
- * %%
- * Copyright (C) 2014 - 2020 University Health Network
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-import ca.uhn.fhir.model.api.IModelJson;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import org.springframework.messaging.Message;
-import org.springframework.messaging.MessageHeaders;
-
-public abstract class BaseJsonMessage implements Message, IModelJson {
-
- private static final long serialVersionUID = 1L;
- @JsonProperty("headers")
- private MessageHeaders myHeaders;
-
- /**
- * Constructor
- */
- public BaseJsonMessage() {
- super();
- }
-
- @Override
- public MessageHeaders getHeaders() {
- return myHeaders;
- }
-
- public void setHeaders(MessageHeaders theHeaders) {
- myHeaders = theHeaders;
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/IResourceMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/IResourceMessage.java
deleted file mode 100644
index 0881b8021c5..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/IResourceMessage.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.model;
-
-/*-
- * #%L
- * HAPI FHIR Subscription Server
- * %%
- * Copyright (C) 2014 - 2020 University Health Network
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-public interface IResourceMessage {
- String getPayloadId();
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyBaseResourceMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyBaseResourceMessage.java
deleted file mode 100644
index dfe55214cd4..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyBaseResourceMessage.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.model;
-
-/*-
- * #%L
- * HAPI FHIR Subscription Server
- * %%
- * Copyright (C) 2014 - 2020 University Health Network
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-import ca.uhn.fhir.model.api.IModelJson;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import org.apache.commons.lang3.Validate;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-
-@SuppressWarnings("WeakerAccess")
-public abstract class LegacyBaseResourceMessage implements IResourceMessage, IModelJson {
-
- @JsonProperty("attributes")
- private Map myAttributes;
-
- /**
- * Returns an attribute stored in this message.
- *
- * Attributes are just a spot for user data of any kind to be
- * added to the message for pasing along the subscription processing
- * pipeline (typically by interceptors). Values will be carried from the beginning to the end.
- *
- *
- * Note that messages are designed to be passed into queueing systems
- * and serialized as JSON. As a result, only strings are currently allowed
- * as values.
- *
- */
- public Optional getAttribute(String theKey) {
- Validate.notBlank(theKey);
- if (myAttributes == null) {
- return Optional.empty();
- }
- return Optional.ofNullable(myAttributes.get(theKey));
- }
-
- /**
- * Sets an attribute stored in this message.
- *
- * Attributes are just a spot for user data of any kind to be
- * added to the message for passing along the subscription processing
- * pipeline (typically by interceptors). Values will be carried from the beginning to the end.
- *
- *
- * Note that messages are designed to be passed into queueing systems
- * and serialized as JSON. As a result, only strings are currently allowed
- * as values.
- *
- *
- * @param theKey The key (must not be null or blank)
- * @param theValue The value (must not be null)
- */
- public void setAttribute(String theKey, String theValue) {
- Validate.notBlank(theKey);
- Validate.notNull(theValue);
- if (myAttributes == null) {
- myAttributes = new HashMap<>();
- }
- myAttributes.put(theKey, theValue);
- }
-
- /**
- * Copies any attributes from the given message into this messsage.
- *
- * @see #setAttribute(String, String)
- * @see #getAttribute(String)
- */
- public void copyAdditionalPropertiesFrom(LegacyBaseResourceMessage theMsg) {
- if (theMsg.myAttributes != null) {
- if (myAttributes == null) {
- myAttributes = new HashMap<>();
- }
- myAttributes.putAll(theMsg.myAttributes);
- }
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedJsonMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedJsonMessage.java
deleted file mode 100644
index 821af831bbc..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedJsonMessage.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.model;
-
-/*-
- * #%L
- * HAPI FHIR Subscription Server
- * %%
- * Copyright (C) 2014 - 2020 University Health Network
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
-public class LegacyResourceModifiedJsonMessage extends BaseJsonMessage {
-
- @JsonProperty("payload")
- private LegacyResourceModifiedMessage myPayload;
-
- /**
- * Constructor
- */
- public LegacyResourceModifiedJsonMessage() {
- super();
- }
-
- /**
- * Constructor
- */
- public LegacyResourceModifiedJsonMessage(LegacyResourceModifiedMessage thePayload) {
- myPayload = thePayload;
- }
-
- @Override
- public LegacyResourceModifiedMessage getPayload() {
- return myPayload;
- }
-
- public void setPayload(LegacyResourceModifiedMessage thePayload) {
- myPayload = thePayload;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this)
- .append("myPayload", myPayload)
- .toString();
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedMessage.java
deleted file mode 100644
index f2e8c543889..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/LegacyResourceModifiedMessage.java
+++ /dev/null
@@ -1,198 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.model;
-
-/*-
- * #%L
- * HAPI FHIR Subscription Server
- * %%
- * Copyright (C) 2014 - 2020 University Health Network
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.model.api.IModelJson;
-import ca.uhn.fhir.rest.api.server.RequestDetails;
-import ca.uhn.fhir.util.ResourceReferenceInfo;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.hl7.fhir.instance.model.api.IIdType;
-
-import java.util.List;
-
-import static org.apache.commons.lang3.StringUtils.isBlank;
-import static org.apache.commons.lang3.StringUtils.isNotBlank;
-
-public class LegacyResourceModifiedMessage extends LegacyBaseResourceMessage implements IResourceMessage, IModelJson {
-
- @JsonProperty("resourceId")
- private String myId;
- @JsonProperty("operationType")
- private OperationTypeEnum myOperationType;
- /**
- * This will only be set if the resource is being triggered for a specific
- * subscription
- */
- @JsonProperty(value = "subscriptionId", required = false)
- private String mySubscriptionId;
- @JsonProperty("payload")
- private String myPayload;
- @JsonProperty("payloadId")
- private String myPayloadId;
- @JsonProperty("parentTransactionGuid")
- private String myParentTransactionGuid;
- @JsonIgnore
- private transient IBaseResource myPayloadDecoded;
-
- /**
- * Constructor
- */
- public LegacyResourceModifiedMessage() {
- super();
- }
-
- public LegacyResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
- this();
- setId(theResource.getIdElement());
- setOperationType(theOperationType);
- if (theOperationType != OperationTypeEnum.DELETE) {
- setNewPayload(theFhirContext, theResource);
- }
- }
-
- public LegacyResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
- this(theFhirContext, theNewResource, theOperationType);
- if (theRequest != null) {
- setParentTransactionGuid(theRequest.getTransactionGuid());
- }
- }
-
- @Override
- public String getPayloadId() {
- return myPayloadId;
- }
-
- public String getSubscriptionId() {
- return mySubscriptionId;
- }
-
- public void setSubscriptionId(String theSubscriptionId) {
- mySubscriptionId = theSubscriptionId;
- }
-
- public String getId() {
- return myId;
- }
-
- public IIdType getId(FhirContext theCtx) {
- IIdType retVal = null;
- if (myId != null) {
- retVal = theCtx.getVersion().newIdType().setValue(myId);
- }
- return retVal;
- }
-
- public IBaseResource getNewPayload(FhirContext theCtx) {
- if (myPayloadDecoded == null && isNotBlank(myPayload)) {
- myPayloadDecoded = theCtx.newJsonParser().parseResource(myPayload);
- }
- return myPayloadDecoded;
- }
-
- public OperationTypeEnum getOperationType() {
- return myOperationType;
- }
-
- public void setOperationType(OperationTypeEnum theOperationType) {
- myOperationType = theOperationType;
- }
-
- public void setId(IIdType theId) {
- myId = null;
- if (theId != null) {
- myId = theId.getValue();
- }
- }
-
- public String getParentTransactionGuid() {
- return myParentTransactionGuid;
- }
-
- public void setParentTransactionGuid(String theParentTransactionGuid) {
- myParentTransactionGuid = theParentTransactionGuid;
- }
-
- private void setNewPayload(FhirContext theCtx, IBaseResource theNewPayload) {
- /*
- * References with placeholders would be invalid by the time we get here, and
- * would be caught before we even get here. This check is basically a last-ditch
- * effort to make sure nothing has broken in the various safeguards that
- * should prevent this from happening (hence it only being an assert as
- * opposed to something executed all the time).
- */
- assert payloadContainsNoPlaceholderReferences(theCtx, theNewPayload);
-
- /*
- * Note: Don't set myPayloadDecoded in here- This is a false optimization since
- * it doesn't actually get used if anyone is doing subscriptions at any
- * scale using a queue engine, and not going through the serialize/deserialize
- * as we would in a queue engine can mask bugs.
- * -JA
- */
- myPayload = theCtx.newJsonParser().encodeResourceToString(theNewPayload);
- myPayloadId = theNewPayload.getIdElement().toUnqualified().getValue();
- }
-
- public enum OperationTypeEnum {
- CREATE,
- UPDATE,
- DELETE,
- MANUALLY_TRIGGERED
- }
-
- private static boolean payloadContainsNoPlaceholderReferences(FhirContext theCtx, IBaseResource theNewPayload) {
- List refs = theCtx.newTerser().getAllResourceReferences(theNewPayload);
- for (ResourceReferenceInfo next : refs) {
- String ref = next.getResourceReference().getReferenceElement().getValue();
- if (isBlank(ref)) {
- IBaseResource resource = next.getResourceReference().getResource();
- if (resource != null) {
- ref = resource.getIdElement().getValue();
- }
- }
- if (isNotBlank(ref)) {
- if (ref.startsWith("#")) {
- continue;
- }
- if (ref.startsWith("urn:uuid:")) {
- throw new AssertionError("Reference at " + next.getName() + " is invalid: " + ref);
- }
- }
- }
- return true;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this)
- .append("myId", myId)
- .append("myOperationType", myOperationType)
- .append("mySubscriptionId", mySubscriptionId)
-// .append("myPayload", myPayload)
- .append("myPayloadId", myPayloadId)
-// .append("myPayloadDecoded", myPayloadDecoded)
- .toString();
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryJsonMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryJsonMessage.java
index 81bd263ec23..06d0e9a0b99 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryJsonMessage.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryJsonMessage.java
@@ -20,6 +20,7 @@ package ca.uhn.fhir.jpa.subscription.model;
* #L%
*/
+import ca.uhn.fhir.rest.server.messaging.json.BaseJsonMessage;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryMessage.java
index aff2b34ed65..46781aac430 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryMessage.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryMessage.java
@@ -24,7 +24,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.server.messaging.BaseResourceMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
+import ca.uhn.fhir.rest.server.messaging.IResourceMessage;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedJsonMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedJsonMessage.java
similarity index 92%
rename from hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedJsonMessage.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedJsonMessage.java
index 59ce15b7425..53affa50f14 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedJsonMessage.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedJsonMessage.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.rest.server.messaging.json;
+package ca.uhn.fhir.jpa.subscription.model;
/*-
* #%L
@@ -20,7 +20,7 @@ package ca.uhn.fhir.rest.server.messaging.json;
* #L%
*/
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
+import ca.uhn.fhir.rest.server.messaging.json.BaseJsonMessage;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedMessage.java
new file mode 100644
index 00000000000..957fa561eec
--- /dev/null
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedMessage.java
@@ -0,0 +1,78 @@
+package ca.uhn.fhir.jpa.subscription.model;
+
+/*-
+ * #%L
+ * HAPI FHIR Subscription Server
+ * %%
+ * Copyright (C) 2014 - 2020 University Health Network
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.rest.api.server.RequestDetails;
+import ca.uhn.fhir.rest.server.messaging.BaseResourceModifiedMessage;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+
+/**
+ * Most of this class has been moved to ResourceModifiedMessage in the hapi-fhir-server project, for a reusable channel ResourceModifiedMessage
+ * that doesn't require knowledge of subscriptions.
+ */
+public class ResourceModifiedMessage extends BaseResourceModifiedMessage {
+
+ /**
+ * This will only be set if the resource is being triggered for a specific
+ * subscription
+ */
+ @JsonProperty(value = "subscriptionId", required = false)
+ private String mySubscriptionId;
+
+ /**
+ * Constructor
+ */
+ public ResourceModifiedMessage() {
+ super();
+ }
+
+ public ResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
+ super(theFhirContext, theResource, theOperationType);
+ }
+
+ public ResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
+ super(theFhirContext, theNewResource, theOperationType, theRequest);
+ }
+
+
+ public String getSubscriptionId() {
+ return mySubscriptionId;
+ }
+
+ public void setSubscriptionId(String theSubscriptionId) {
+ mySubscriptionId = theSubscriptionId;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("myId", myId)
+ .append("myOperationType", myOperationType)
+ .append("mySubscriptionId", mySubscriptionId)
+// .append("myPayload", myPayload)
+ .append("myPayloadId", myPayloadId)
+// .append("myPayloadDecoded", myPayloadDecoded)
+ .toString();
+ }
+}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionMatcherInterceptor.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionMatcherInterceptor.java
index a147fe9da12..51e01bd6c69 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionMatcherInterceptor.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionMatcherInterceptor.java
@@ -10,10 +10,10 @@ import ca.uhn.fhir.jpa.subscription.channel.impl.LinkedBlockingChannel;
import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelFactory;
import ca.uhn.fhir.jpa.subscription.match.matcher.matching.IResourceModifiedConsumer;
import ca.uhn.fhir.jpa.subscription.match.matcher.subscriber.SubscriptionMatchingSubscriber;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.jpa.util.JpaInterceptorBroadcaster;
import ca.uhn.fhir.rest.api.server.RequestDetails;
-import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.IBaseResource;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java
index f966ed90655..84a2d36dd36 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java
@@ -32,6 +32,7 @@ import ca.uhn.fhir.jpa.model.sched.ScheduledJobDefinition;
import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.jpa.subscription.match.matcher.matching.IResourceModifiedConsumer;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.api.CacheControlDirective;
@@ -40,8 +41,6 @@ import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedSubscriptionMessage;
import ca.uhn.fhir.util.ParametersUtil;
import ca.uhn.fhir.util.StopWatch;
import ca.uhn.fhir.util.UrlUtil;
@@ -307,7 +306,7 @@ public class SubscriptionTriggeringSvcImpl implements ISubscriptionTriggeringSvc
ourLog.info("Submitting resource {} to subscription {}", theResourceToTrigger.getIdElement().toUnqualifiedVersionless().getValue(), theSubscriptionId);
- ResourceModifiedSubscriptionMessage msg = new ResourceModifiedSubscriptionMessage(myFhirContext, theResourceToTrigger, ResourceModifiedMessage.OperationTypeEnum.UPDATE);
+ ResourceModifiedMessage msg = new ResourceModifiedMessage(myFhirContext, theResourceToTrigger, ResourceModifiedMessage.OperationTypeEnum.UPDATE);
msg.setSubscriptionId(theSubscriptionId);
return myExecutorService.submit(() -> {
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java
index 1f14b47f494..23083343a0a 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java
@@ -26,7 +26,7 @@ import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType;
import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.util.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/channel/subscription/BroadcastingSubscribableChannelWrapperTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/channel/subscription/BroadcastingSubscribableChannelWrapperTest.java
index a48f44b12dd..4c29d2b86ad 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/channel/subscription/BroadcastingSubscribableChannelWrapperTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/channel/subscription/BroadcastingSubscribableChannelWrapperTest.java
@@ -1,8 +1,8 @@
package ca.uhn.fhir.jpa.subscription.channel.subscription;
import ca.uhn.fhir.jpa.subscription.channel.api.IChannelReceiver;
-import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/deliver/BaseSubscriptionDeliverySubscriberTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/deliver/BaseSubscriptionDeliverySubscriberTest.java
index f1aee3f5541..17e3f471021 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/deliver/BaseSubscriptionDeliverySubscriberTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/deliver/BaseSubscriptionDeliverySubscriberTest.java
@@ -8,11 +8,11 @@ import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryJsonMessage;
import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.api.IRestfulClientFactory;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Patient;
import org.junit.jupiter.api.BeforeEach;
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/ResourceModifiedTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/ResourceModifiedTest.java
index 728510cf7a2..ebe2b40c684 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/ResourceModifiedTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/ResourceModifiedTest.java
@@ -1,7 +1,7 @@
package ca.uhn.fhir.jpa.subscription.module;
import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import org.hl7.fhir.r4.model.Organization;
import org.junit.jupiter.api.Test;
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/BaseBlockingQueueSubscribableChannelDstu3Test.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/BaseBlockingQueueSubscribableChannelDstu3Test.java
index c2bdd952529..aaa6e1c0276 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/BaseBlockingQueueSubscribableChannelDstu3Test.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/BaseBlockingQueueSubscribableChannelDstu3Test.java
@@ -11,6 +11,8 @@ import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionLoader;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.jpa.subscription.module.BaseSubscriptionDstu3Test;
import ca.uhn.fhir.jpa.subscription.module.subscriber.SubscriptionMatchingSubscriberTest;
import ca.uhn.fhir.model.primitive.IdDt;
@@ -21,8 +23,6 @@ import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
-import ca.uhn.fhir.rest.server.messaging.json.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedMessage;
import ca.uhn.fhir.test.utilities.JettyUtil;
import ca.uhn.test.concurrency.IPointcutLatch;
import ca.uhn.test.concurrency.PointcutLatch;
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceModifiedMessage.java
similarity index 75%
rename from hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedMessage.java
rename to hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceModifiedMessage.java
index 8767e7e5895..1fb5bbfd83b 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedMessage.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/BaseResourceModifiedMessage.java
@@ -2,6 +2,8 @@ package ca.uhn.fhir.rest.server.messaging;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IModelJson;
+import ca.uhn.fhir.parser.IParser;
+import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.util.ResourceReferenceInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -15,29 +17,29 @@ import java.util.List;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
-public class ResourceModifiedMessage extends BaseResourceMessage implements IResourceMessage, IModelJson {
+public class BaseResourceModifiedMessage extends BaseResourceMessage implements IResourceMessage, IModelJson {
@JsonProperty("resourceId")
- private String myId;
+ protected String myId;
@JsonProperty("operationType")
- private OperationTypeEnum myOperationType;
+ protected OperationTypeEnum myOperationType;
@JsonProperty("payload")
- private String myPayload;
+ protected String myPayload;
@JsonProperty("payloadId")
- private String myPayloadId;
+ protected String myPayloadId;
@JsonProperty("parentTransactionGuid")
- private String myParentTransactionGuid;
+ protected String myParentTransactionGuid;
@JsonIgnore
- private transient IBaseResource myPayloadDecoded;
+ protected transient IBaseResource myPayloadDecoded;
/**
* Constructor
*/
- public ResourceModifiedMessage() {
+ public BaseResourceModifiedMessage() {
super();
}
- public ResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
+ public BaseResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
this();
setId(theResource.getIdElement());
setOperationType(theOperationType);
@@ -46,7 +48,7 @@ public class ResourceModifiedMessage extends BaseResourceMessage implements IRes
}
}
- public ResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
+ public BaseResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
this(theFhirContext, theNewResource, theOperationType);
if (theRequest != null) {
setParentTransactionGuid(theRequest.getTransactionGuid());
@@ -77,6 +79,24 @@ public class ResourceModifiedMessage extends BaseResourceMessage implements IRes
return myPayloadDecoded;
}
+ public IBaseResource getPayload(FhirContext theCtx) {
+ IBaseResource retVal = myPayloadDecoded;
+ if (retVal == null && isNotBlank(myPayload)) {
+ IParser parser = EncodingEnum.detectEncoding(myPayload).newParser(theCtx);
+ retVal = parser.parseResource(myPayload);
+ myPayloadDecoded = retVal;
+ }
+ return retVal;
+ }
+
+ public String getPayloadString() {
+ if (this.myPayload != null) {
+ return this.myPayload;
+ }
+
+ return "";
+ }
+
public OperationTypeEnum getOperationType() {
return myOperationType;
}
@@ -100,7 +120,7 @@ public class ResourceModifiedMessage extends BaseResourceMessage implements IRes
myParentTransactionGuid = theParentTransactionGuid;
}
- private void setNewPayload(FhirContext theCtx, IBaseResource theNewPayload) {
+ protected void setNewPayload(FhirContext theCtx, IBaseResource theNewPayload) {
/*
* References with placeholders would be invalid by the time we get here, and
* would be caught before we even get here. This check is basically a last-ditch
@@ -128,7 +148,7 @@ public class ResourceModifiedMessage extends BaseResourceMessage implements IRes
MANUALLY_TRIGGERED
}
- private static boolean payloadContainsNoPlaceholderReferences(FhirContext theCtx, IBaseResource theNewPayload) {
+ protected static boolean payloadContainsNoPlaceholderReferences(FhirContext theCtx, IBaseResource theNewPayload) {
List refs = theCtx.newTerser().getAllResourceReferences(theNewPayload);
for (ResourceReferenceInfo next : refs) {
String ref = next.getResourceReference().getReferenceElement().getValue();
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedSubscriptionMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedSubscriptionMessage.java
deleted file mode 100644
index 9fe55618f7e..00000000000
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/ResourceModifiedSubscriptionMessage.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package ca.uhn.fhir.rest.server.messaging;
-
-import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.rest.api.server.RequestDetails;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-
-public class ResourceModifiedSubscriptionMessage extends ResourceModifiedMessage {
-
- /**
- * This will only be set if the resource is being triggered for a specific
- * subscription
- */
- @JsonProperty(value = "subscriptionId", required = false)
- private String mySubscriptionId;
-
- public ResourceModifiedSubscriptionMessage() {
- }
-
- public ResourceModifiedSubscriptionMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
- super(theFhirContext, theResource, theOperationType);
- }
-
- public ResourceModifiedSubscriptionMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
- super(theFhirContext, theNewResource, theOperationType, theRequest);
- }
-
- public String getSubscriptionId() {
- return mySubscriptionId;
- }
-
- public void setSubscriptionId(String theSubscriptionId) {
- mySubscriptionId = theSubscriptionId;
- }
-
-}
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseJsonMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseJsonMessage.java
index 40d7d7e487e..0edf77cf96f 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseJsonMessage.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseJsonMessage.java
@@ -25,23 +25,57 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
public abstract class BaseJsonMessage implements Message, IModelJson {
private static final long serialVersionUID = 1L;
@JsonProperty("headers")
private MessageHeaders myHeaders;
+ private String RETRY_COUNT_HEADER = "retryCount";
+ private String FIRST_FAILURE_HEADER = "firstFailure";
+ private String LAST_FAILURE_HEADER = "lastFailure";
+
/**
* Constructor
*/
public BaseJsonMessage() {
super();
+ setDefaultRetryHeaders();
+ }
+
+ protected void setDefaultRetryHeaders() {
+ Map headers = new HashMap<>();
+ headers.put(RETRY_COUNT_HEADER, 0);
+ headers.put(FIRST_FAILURE_HEADER, null);
+ headers.put(LAST_FAILURE_HEADER, null);
+ MessageHeaders messageHeaders = new MessageHeaders(headers);
+ setHeaders(messageHeaders);
}
@Override
public MessageHeaders getHeaders() {
return myHeaders;
}
+ public final Integer getRetryCount() {
+ //TODO GGG this is not NPE-safe
+ return (Integer)this.getHeaders().get(RETRY_COUNT_HEADER);
+ }
+
+ public final Date getFirstFailureDate() {
+ //TODO GGG this is not NPE-safe
+ return (Date)this.getHeaders().get(FIRST_FAILURE_HEADER);
+
+ }
+
+ public final Date getLastFailureDate() {
+ //TODO GGG this is not NPE-safe
+ return (Date)this.getHeaders().get(LAST_FAILURE_HEADER);
+
+ }
public void setHeaders(MessageHeaders theHeaders) {
myHeaders = theHeaders;
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedSubscriptionJsonMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseResourceModifiedJsonMessage.java
similarity index 61%
rename from hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedSubscriptionJsonMessage.java
rename to hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseResourceModifiedJsonMessage.java
index 7f19ee426b1..df43b0f9970 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/ResourceModifiedSubscriptionJsonMessage.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseResourceModifiedJsonMessage.java
@@ -20,35 +20,44 @@ package ca.uhn.fhir.rest.server.messaging.json;
* #L%
*/
-import ca.uhn.fhir.rest.server.messaging.ResourceModifiedSubscriptionMessage;
+import ca.uhn.fhir.rest.server.messaging.BaseResourceModifiedMessage;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.springframework.messaging.MessageHeaders;
+
+public class BaseResourceModifiedJsonMessage extends BaseJsonMessage {
-public class ResourceModifiedSubscriptionJsonMessage extends BaseJsonMessage {
@JsonProperty("payload")
- private ResourceModifiedSubscriptionMessage myPayload;
+ private BaseResourceModifiedMessage myPayload;
/**
* Constructor
*/
- public ResourceModifiedSubscriptionJsonMessage() {
+ public BaseResourceModifiedJsonMessage() {
super();
}
/**
* Constructor
*/
- public ResourceModifiedSubscriptionJsonMessage(ResourceModifiedSubscriptionMessage thePayload) {
+ public BaseResourceModifiedJsonMessage(BaseResourceModifiedMessage thePayload) {
myPayload = thePayload;
+ setDefaultRetryHeaders();
}
+ public BaseResourceModifiedJsonMessage(MessageHeaders theRetryMessageHeaders, BaseResourceModifiedMessage thePayload) {
+ myPayload = thePayload;
+ setHeaders(theRetryMessageHeaders);
+ }
+
+
@Override
- public ResourceModifiedSubscriptionMessage getPayload() {
+ public BaseResourceModifiedMessage getPayload() {
return myPayload;
}
- public void setPayload(ResourceModifiedSubscriptionMessage thePayload) {
+ public void setPayload(BaseResourceModifiedMessage thePayload) {
myPayload = thePayload;
}
From c3ddf59d6fd699d35471ce31968ca66a8a4c4ae5 Mon Sep 17 00:00:00 2001
From: Tadgh
Date: Mon, 14 Sep 2020 13:02:32 -0400
Subject: [PATCH 04/25] Add HapiMessageHeaders to BaseJsonMessage class
---
.../InMemorySubscriptionMatcherR3Test.java | 16 ----
.../messaging/json/BaseJsonMessage.java | 86 ++++++++++++++++++-
.../json/BaseResourceModifiedJsonMessage.java | 3 +-
.../json/MessageHeaderDeserializer.java | 24 ++++++
4 files changed, 108 insertions(+), 21 deletions(-)
create mode 100644 hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/MessageHeaderDeserializer.java
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java
index 6a5a10dc7bd..c5eb62b95ec 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java
@@ -10,8 +10,6 @@ import ca.uhn.fhir.jpa.subscription.module.BaseSubscriptionDstu3Test;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.server.SimpleBundleProvider;
import ca.uhn.fhir.util.UrlUtil;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.hl7.fhir.dstu3.model.BodySite;
import org.hl7.fhir.dstu3.model.CodeableConcept;
import org.hl7.fhir.dstu3.model.Coding;
@@ -38,12 +36,9 @@ import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.messaging.MessageHeaders;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -115,17 +110,6 @@ public class InMemorySubscriptionMatcherR3Test extends BaseSubscriptionDstu3Test
assertNotMatched(pr, "ProcedureRequest?subject=Patient/123");
}
- @Test
- public void testSerializationOfMessageHeaders() throws JsonProcessingException {
- Map headers = new HashMap<>();
- headers.put("zoop", "zoop");
- MessageHeaders mh = new MessageHeaders(headers);
-
- ObjectMapper mapper = new ObjectMapper();
- //Test that serialization of MessageHeaders works.
- mapper.writeValueAsString(mh);
- }
-
@Test
public void testResourceById() {
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseJsonMessage.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseJsonMessage.java
index 0edf77cf96f..ae9cb3ced38 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseJsonMessage.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/messaging/json/BaseJsonMessage.java
@@ -25,15 +25,17 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
+import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
public abstract class BaseJsonMessage implements Message, IModelJson {
private static final long serialVersionUID = 1L;
@JsonProperty("headers")
- private MessageHeaders myHeaders;
+ private HapiMessageHeaders myHeaders;
private String RETRY_COUNT_HEADER = "retryCount";
private String FIRST_FAILURE_HEADER = "firstFailure";
@@ -46,20 +48,98 @@ public abstract class BaseJsonMessage implements Message, IModelJson {
super();
setDefaultRetryHeaders();
}
+ public static class HapiMessageHeaders implements Map{
+
+ private final Map headers;
+
+ public HapiMessageHeaders(Map theHeaders) {
+ headers = theHeaders;
+ }
+
+ public HapiMessageHeaders() {
+ headers = new HashMap<>();
+ }
+
+
+ @Override
+ public int size() {
+ return this.headers.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return this.headers.isEmpty();
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ return this.headers.containsKey(key);
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ return this.headers.containsValue(value);
+ }
+
+ @Override
+ public Object get(Object key) {
+ return this.headers.get(key);
+ }
+
+ @Override
+ public Object put(String key, Object value) {
+ return this.headers.put(key, value);
+ }
+
+ @Override
+ public Object remove(Object key) {
+ return this.headers.remove(key);
+ }
+
+ @Override
+ public void putAll(Map extends String, ?> m) {
+ this.headers.putAll(m);
+ }
+
+ @Override
+ public void clear() {
+ this.headers.clear();
+ }
+
+ @Override
+ public Set keySet() {
+ return this.headers.keySet();
+ }
+
+ @Override
+ public Collection