createDeliveryHandler(CanonicalSubscriptionChannelType theChannelType) {
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseJsonMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseJsonMessage.java
similarity index 95%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseJsonMessage.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseJsonMessage.java
index a140978bec3..1bb28358726 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseJsonMessage.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseJsonMessage.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
+package ca.uhn.fhir.jpa.subscription.model;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseResourceMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseResourceMessage.java
similarity index 98%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseResourceMessage.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseResourceMessage.java
index fe00948e503..ba753078243 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseResourceMessage.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/BaseResourceMessage.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
+package ca.uhn.fhir.jpa.subscription.model;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/CanonicalSubscription.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/CanonicalSubscription.java
similarity index 99%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/CanonicalSubscription.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/CanonicalSubscription.java
index 7ddc2f5f637..a8ba6d41f77 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/CanonicalSubscription.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/CanonicalSubscription.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module;
+package ca.uhn.fhir.jpa.subscription.model;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/CanonicalSubscriptionChannelType.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/CanonicalSubscriptionChannelType.java
similarity index 99%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/CanonicalSubscriptionChannelType.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/CanonicalSubscriptionChannelType.java
index 474fd3ac1e3..6c523562f82 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/CanonicalSubscriptionChannelType.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/CanonicalSubscriptionChannelType.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module;
+package ca.uhn.fhir.jpa.subscription.model;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/IResourceMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/IResourceMessage.java
similarity index 92%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/IResourceMessage.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/IResourceMessage.java
index 6bc41c53e4d..0881b8021c5 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/IResourceMessage.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/IResourceMessage.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
+package ca.uhn.fhir.jpa.subscription.model;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryJsonMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryJsonMessage.java
similarity index 96%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryJsonMessage.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryJsonMessage.java
index fdeaef18d67..81bd263ec23 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryJsonMessage.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryJsonMessage.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
+package ca.uhn.fhir.jpa.subscription.model;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryMessage.java
similarity index 95%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryMessage.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryMessage.java
index 51e9d752ce8..69b40d7004a 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryMessage.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceDeliveryMessage.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
+package ca.uhn.fhir.jpa.subscription.model;
/*-
* #%L
@@ -21,8 +21,6 @@ package ca.uhn.fhir.jpa.subscription.module.subscriber;
*/
import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
import ca.uhn.fhir.rest.api.EncodingEnum;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/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-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceModifiedJsonMessage.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedJsonMessage.java
index 9a0c2be5c72..f8b8407d686 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/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.jpa.subscription.module.subscriber;
+package ca.uhn.fhir.jpa.subscription.model;
/*-
* #%L
@@ -20,7 +20,6 @@ package ca.uhn.fhir.jpa.subscription.module.subscriber;
* #L%
*/
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
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/module/ResourceModifiedMessage.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedMessage.java
similarity index 96%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/ResourceModifiedMessage.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedMessage.java
index 2bda901b43b..b72ad8ddc1a 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/ResourceModifiedMessage.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/model/ResourceModifiedMessage.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module;
+package ca.uhn.fhir.jpa.subscription.model;
/*-
* #%L
@@ -21,8 +21,6 @@ package ca.uhn.fhir.jpa.subscription.module;
*/
import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.BaseResourceMessage;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.IResourceMessage;
import ca.uhn.fhir.model.api.IModelJson;
import ca.uhn.fhir.util.ResourceReferenceInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/LinkedBlockingQueueSubscribableChannelFactory.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/LinkedBlockingQueueSubscribableChannelFactory.java
deleted file mode 100644
index 472a07a0931..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/LinkedBlockingQueueSubscribableChannelFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
-
-/*-
- * #%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.jpa.subscription.module.LinkedBlockingQueueSubscribableChannel;
-import ca.uhn.fhir.jpa.subscription.module.channel.ISubscribableChannelFactory;
-import org.springframework.messaging.SubscribableChannel;
-
-import java.util.concurrent.LinkedBlockingQueue;
-
-public class LinkedBlockingQueueSubscribableChannelFactory implements ISubscribableChannelFactory {
- @Override
- public SubscribableChannel createSubscribableChannel(String theChannelName, Class theMessageType, int theConcurrentConsumers) {
- return new LinkedBlockingQueueSubscribableChannel(new LinkedBlockingQueue<>(SubscriptionConstants.DELIVERY_EXECUTOR_QUEUE_SIZE), theChannelName + "-%d", theConcurrentConsumers);
- }
-
- @Override
- public int getDeliveryChannelConcurrentConsumers() {
- return SubscriptionConstants.DELIVERY_CHANNEL_CONCURRENT_CONSUMERS;
- }
-
- @Override
- public int getMatchingChannelConcurrentConsumers() {
- return SubscriptionConstants.MATCHING_CHANNEL_CONCURRENT_CONSUMERS;
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/channel/ISubscribableChannelFactory.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/channel/ISubscribableChannelFactory.java
deleted file mode 100644
index 669401726d7..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/channel/ISubscribableChannelFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.channel;
-
-/*-
- * #%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 org.springframework.messaging.SubscribableChannel;
-
-public interface ISubscribableChannelFactory {
- SubscribableChannel createSubscribableChannel(String theChannelName, Class theMessageType, int theConcurrentConsumers);
-
- int getDeliveryChannelConcurrentConsumers();
-
- int getMatchingChannelConcurrentConsumers();
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/channel/SubscriptionChannelFactory.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/channel/SubscriptionChannelFactory.java
deleted file mode 100644
index c2a2eca6589..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/channel/SubscriptionChannelFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.channel;
-
-/*-
- * #%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.jpa.subscription.module.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.messaging.SubscribableChannel;
-
-public class SubscriptionChannelFactory {
-
- @Autowired
- private ISubscribableChannelFactory mySubscribableChannelFactory;
-
- public SubscribableChannel newDeliveryChannel(String theChannelName) {
- return mySubscribableChannelFactory.createSubscribableChannel(theChannelName, ResourceDeliveryMessage.class, mySubscribableChannelFactory.getDeliveryChannelConcurrentConsumers());
- }
-
- public SubscribableChannel newMatchingChannel(String theChannelName) {
- return mySubscribableChannelFactory.createSubscribableChannel(theChannelName, ResourceModifiedMessage.class, mySubscribableChannelFactory.getMatchingChannelConcurrentConsumers());
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/FhirClientResourceRetriever.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/FhirClientResourceRetriever.java
deleted file mode 100644
index c7a27d05851..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/FhirClientResourceRetriever.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.standalone;
-
-/*-
- * #%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.context.RuntimeResourceDefinition;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.IResourceRetriever;
-import ca.uhn.fhir.rest.client.api.IGenericClient;
-import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.hl7.fhir.instance.model.api.IIdType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-public class FhirClientResourceRetriever implements IResourceRetriever {
- private static final Logger ourLog = LoggerFactory.getLogger(FhirClientResourceRetriever.class);
-
- @Autowired
- FhirContext myFhirContext;
- @Autowired
- IGenericClient myClient;
-
- @Override
- public IBaseResource getResource(IIdType payloadId) throws ResourceGoneException {
- RuntimeResourceDefinition resourceDef = myFhirContext.getResourceDefinition(payloadId.getResourceType());
-
- return myClient.read().resource(resourceDef.getName()).withId(payloadId).execute();
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/FhirClientSearchParamProvider.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/FhirClientSearchParamProvider.java
deleted file mode 100644
index 45928ed71f1..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/FhirClientSearchParamProvider.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.standalone;
-
-/*-
- * #%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.jpa.searchparam.SearchParameterMap;
-import ca.uhn.fhir.jpa.searchparam.registry.SearchParamRegistryImpl;
-import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamProvider;
-import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum;
-import ca.uhn.fhir.rest.api.CacheControlDirective;
-import ca.uhn.fhir.rest.api.server.IBundleProvider;
-import ca.uhn.fhir.rest.client.api.IGenericClient;
-import ca.uhn.fhir.rest.server.SimpleBundleProvider;
-import ca.uhn.fhir.util.BundleUtil;
-import org.hl7.fhir.instance.model.api.IBaseBundle;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-public class FhirClientSearchParamProvider implements ISearchParamProvider {
- private static final Logger ourLog = LoggerFactory.getLogger(FhirClientSearchParamProvider.class);
-
- private IGenericClient myClient;
-
- /**
- * Constructor
- */
- @Autowired
- public FhirClientSearchParamProvider(IGenericClient theClient) {
- myClient = theClient;
- }
-
- @Override
- public IBundleProvider search(SearchParameterMap theParams) {
- FhirContext fhirContext = myClient.getFhirContext();
-
- IBaseBundle bundle = myClient
- .search()
- .forResource(ResourceTypeEnum.SEARCHPARAMETER.getCode())
- .cacheControl(new CacheControlDirective().setNoCache(true))
- .execute();
-
- return new SimpleBundleProvider(BundleUtil.toListOfResources(fhirContext, bundle));
- }
-
- @Override
- public int refreshCache(SearchParamRegistryImpl theSearchParamRegistry, long theRefreshInterval) {
- return theSearchParamRegistry.doRefresh(theRefreshInterval);
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/FhirClientSubscriptionProvider.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/FhirClientSubscriptionProvider.java
deleted file mode 100644
index 1e8e8cb0031..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/FhirClientSubscriptionProvider.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.standalone;
-
-/*-
- * #%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.jpa.searchparam.SearchParameterMap;
-import ca.uhn.fhir.jpa.subscription.module.cache.ISubscriptionProvider;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
-import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum;
-import ca.uhn.fhir.rest.api.CacheControlDirective;
-import ca.uhn.fhir.rest.api.server.IBundleProvider;
-import ca.uhn.fhir.rest.client.api.IGenericClient;
-import ca.uhn.fhir.rest.server.SimpleBundleProvider;
-import ca.uhn.fhir.util.BundleUtil;
-import org.hl7.fhir.instance.model.api.IBaseBundle;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-public class FhirClientSubscriptionProvider implements ISubscriptionProvider {
- @Autowired
- private FhirContext myFhirContext;
- @Autowired
- private SubscriptionRegistry mySubscriptionRegistry;
-
- IGenericClient myClient;
-
- @Autowired
- public FhirClientSubscriptionProvider(IGenericClient theClient) {
- myClient = theClient;
- }
-
- @Override
- public IBundleProvider search(SearchParameterMap theMap) {
- FhirContext fhirContext = myClient.getFhirContext();
-
- String searchURL = ResourceTypeEnum.SUBSCRIPTION.getCode() + theMap.toNormalizedQueryString(myFhirContext);
-
- IBaseBundle bundle = myClient
- .search()
- .byUrl(searchURL)
- .cacheControl(new CacheControlDirective().setNoCache(true))
- .execute();
-
- return new SimpleBundleProvider(BundleUtil.toListOfResources(fhirContext, bundle));
- }
-
- @Override
- public boolean loadSubscription(IBaseResource theResource) {
- return mySubscriptionRegistry.registerSubscriptionUnlessAlreadyRegistered(theResource);
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/StandaloneSubscriptionConfig.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/StandaloneSubscriptionConfig.java
deleted file mode 100644
index e798406255a..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/StandaloneSubscriptionConfig.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.standalone;
-
-/*-
- * #%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.client.api.IGenericClient;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-// FIXME: rename
-@Configuration
-public class StandaloneSubscriptionConfig {
-
- /**
- * Constructor
- */
- public StandaloneSubscriptionConfig() {
- super();
- }
-
- @Autowired
- private IGenericClient myClient;
-
- @Bean
- public FhirClientResourceRetriever fhirClientResourceRetriever() {
- return new FhirClientResourceRetriever();
- }
-
- @Bean
- public FhirClientSearchParamProvider fhirClientSearchParamProvider() {
- return new FhirClientSearchParamProvider(myClient);
- }
-
- @Bean
- public FhirClientSubscriptionProvider fhirClientSubscriptionProvider() {
- return new FhirClientSubscriptionProvider(myClient);
- }
-
- @Bean
- public StandaloneSubscriptionMessageHandler fhirClientSubscriptionMessageHandler() {
- return new StandaloneSubscriptionMessageHandler();
- }
-
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/StandaloneSubscriptionMessageHandler.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/StandaloneSubscriptionMessageHandler.java
deleted file mode 100644
index 8841696cccc..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/standalone/StandaloneSubscriptionMessageHandler.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.standalone;
-
-/*-
- * #%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.context.RuntimeResourceDefinition;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionCanonicalizer;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionConstants;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.SubscriptionMatchingSubscriber;
-import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.hl7.fhir.instance.model.api.IIdType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.messaging.Message;
-import org.springframework.messaging.MessageHandler;
-import org.springframework.messaging.MessagingException;
-import org.springframework.stereotype.Service;
-
-public class StandaloneSubscriptionMessageHandler implements MessageHandler {
- private static final Logger ourLog = LoggerFactory.getLogger(StandaloneSubscriptionMessageHandler.class);
-
- @Autowired
- FhirContext myFhirContext;
- @Autowired
- SubscriptionMatchingSubscriber mySubscriptionMatchingSubscriber;
- @Autowired
- SubscriptionRegistry mySubscriptionRegistry;
- @Autowired
- SubscriptionCanonicalizer mySubscriptionCanonicalizer;
-
- @Override
- public void handleMessage(Message> theMessage) throws MessagingException {
- if (!(theMessage instanceof ResourceModifiedJsonMessage)) {
- ourLog.warn("Unexpected message payload type: {}", theMessage);
- return;
- }
- updateSubscriptionRegistryAndPerformMatching(((ResourceModifiedJsonMessage) theMessage).getPayload());
- }
-
- public void updateSubscriptionRegistryAndPerformMatching(ResourceModifiedMessage theResourceModifiedMessage) {
- switch (theResourceModifiedMessage.getOperationType()) {
- case DELETE:
- if (isSubscription(theResourceModifiedMessage)) {
- mySubscriptionRegistry.unregisterSubscription(theResourceModifiedMessage.getId(myFhirContext).getIdPart());
- }
- return;
- case CREATE:
- case UPDATE:
- if (isSubscription(theResourceModifiedMessage)) {
- registerActiveSubscription(theResourceModifiedMessage.getNewPayload(myFhirContext));
- }
- break;
- default:
- break;
- }
-
- mySubscriptionMatchingSubscriber.matchActiveSubscriptionsAndDeliver(theResourceModifiedMessage);
- }
-
- private boolean isSubscription(ResourceModifiedMessage theResourceModifiedMessage) {
- String resourceType;
- IIdType id = theResourceModifiedMessage.getId(myFhirContext);
- if (id != null) {
- resourceType = id.getResourceType();
- } else {
- resourceType = theResourceModifiedMessage.getNewPayload(myFhirContext).getIdElement().getResourceType();
- }
- if (resourceType == null) {
- return false;
- }
- RuntimeResourceDefinition resourceDef = myFhirContext.getResourceDefinition(resourceType);
- return resourceDef.getName().equals(ResourceTypeEnum.SUBSCRIPTION.getCode());
- }
-
- private void registerActiveSubscription(IBaseResource theSubscription) {
- String status = mySubscriptionCanonicalizer.getSubscriptionStatus(theSubscription);
- if (SubscriptionConstants.ACTIVE_STATUS.equals(status)) {
- mySubscriptionRegistry.registerSubscriptionUnlessAlreadyRegistered(theSubscription);
- }
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/config/SubscriptionProcessorConfig.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/config/SubscriptionProcessorConfig.java
new file mode 100644
index 00000000000..d923ce00336
--- /dev/null
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/config/SubscriptionProcessorConfig.java
@@ -0,0 +1,136 @@
+package ca.uhn.fhir.jpa.subscription.process.config;
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelRegistry;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionDeliveryChannelNamer;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionDeliveryHandlerFactory;
+import ca.uhn.fhir.jpa.subscription.process.deliver.DaoResourceRetriever;
+import ca.uhn.fhir.jpa.subscription.process.deliver.IResourceRetriever;
+import ca.uhn.fhir.jpa.subscription.process.deliver.resthook.SubscriptionDeliveringRestHookSubscriber;
+import ca.uhn.fhir.jpa.subscription.process.deliver.websocket.WebsocketConnectionValidator;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.CompositeInMemoryDaoSubscriptionMatcher;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.DaoSubscriptionMatcher;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.ISubscriptionMatcher;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.InMemorySubscriptionMatcher;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.SubscriptionStrategyEvaluator;
+import ca.uhn.fhir.jpa.subscription.process.matcher.subscriber.MatchingQueueSubscriberLoader;
+import ca.uhn.fhir.jpa.subscription.process.matcher.subscriber.SubscriptionActivatingSubscriber;
+import ca.uhn.fhir.jpa.subscription.process.matcher.subscriber.SubscriptionMatchingSubscriber;
+import ca.uhn.fhir.jpa.subscription.process.matcher.subscriber.SubscriptionRegisteringSubscriber;
+import ca.uhn.fhir.jpa.subscription.process.registry.DaoSubscriptionProvider;
+import ca.uhn.fhir.jpa.subscription.process.registry.ISubscriptionProvider;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionCanonicalizer;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionLoader;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionRegistry;
+import ca.uhn.fhir.jpa.subscription.triggering.ISubscriptionTriggeringSvc;
+import ca.uhn.fhir.jpa.subscription.triggering.SubscriptionTriggeringSvcImpl;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.Scope;
+
+/**
+ * This Spring config should be imported by a system that pulls messages off of the
+ * matching queue for processing, and handles delivery
+ */
+public class SubscriptionProcessorConfig {
+
+ @Bean
+ public SubscriptionMatchingSubscriber subscriptionMatchingSubscriber() {
+ return new SubscriptionMatchingSubscriber();
+ }
+
+ @Bean
+ public SubscriptionActivatingSubscriber subscriptionActivatingSubscriber() {
+ return new SubscriptionActivatingSubscriber();
+ }
+
+ @Bean
+ public MatchingQueueSubscriberLoader subscriptionMatchingSubscriberLoader() {
+ return new MatchingQueueSubscriberLoader();
+ }
+
+ @Bean
+ public SubscriptionRegisteringSubscriber subscriptionRegisteringSubscriber() {
+ return new SubscriptionRegisteringSubscriber();
+ }
+
+ @Bean
+ public SubscriptionRegistry subscriptionRegistry() {
+ return new SubscriptionRegistry();
+ }
+
+ @Bean
+ public SubscriptionDeliveryChannelNamer subscriptionDeliveryChannelNamer() {
+ return new SubscriptionDeliveryChannelNamer();
+ }
+
+ @Bean
+ public ISubscriptionProvider subscriptionProvider() {
+ return new DaoSubscriptionProvider();
+ }
+
+ @Bean
+ public IResourceRetriever resourceRetriever() {
+ return new DaoResourceRetriever();
+ }
+
+ @Bean
+ public WebsocketConnectionValidator websocketConnectionValidator() {
+ return new WebsocketConnectionValidator();
+ }
+
+ @Bean
+ public SubscriptionStrategyEvaluator subscriptionStrategyEvaluator() {
+ return new SubscriptionStrategyEvaluator();
+ }
+
+ @Bean
+ public SubscriptionCanonicalizer subscriptionCanonicalizer(FhirContext theFhirContext) {
+ return new SubscriptionCanonicalizer(theFhirContext);
+ }
+
+ @Bean
+ public SubscriptionLoader subscriptionLoader() {
+ return new SubscriptionLoader();
+ }
+
+ @Bean
+ public SubscriptionChannelRegistry subscriptionChannelRegistry() {
+ return new SubscriptionChannelRegistry();
+ }
+
+ @Bean
+ public SubscriptionDeliveryHandlerFactory subscriptionDeliveryHandlerFactory() {
+ return new SubscriptionDeliveryHandlerFactory();
+ }
+
+ @Bean
+ @Lazy
+ public ISubscriptionTriggeringSvc subscriptionTriggeringSvc() {
+ return new SubscriptionTriggeringSvcImpl();
+ }
+
+ @Bean
+ @Scope("prototype")
+ public SubscriptionDeliveringRestHookSubscriber subscriptionDeliveringRestHookSubscriber() {
+ return new SubscriptionDeliveringRestHookSubscriber();
+ }
+
+ @Bean
+ public InMemorySubscriptionMatcher inMemorySubscriptionMatcher() {
+ return new InMemorySubscriptionMatcher();
+ }
+
+ @Bean
+ public DaoSubscriptionMatcher daoSubscriptionMatcher() {
+ return new DaoSubscriptionMatcher();
+ }
+
+ @Bean
+ @Primary
+ public ISubscriptionMatcher subscriptionMatcher(DaoSubscriptionMatcher theDaoSubscriptionMatcher, InMemorySubscriptionMatcher theInMemorySubscriptionMatcher) {
+ return new CompositeInMemoryDaoSubscriptionMatcher(theDaoSubscriptionMatcher, theInMemorySubscriptionMatcher);
+ }
+
+}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseSubscriptionDeliverySubscriber.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/BaseSubscriptionDeliverySubscriber.java
similarity index 86%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseSubscriptionDeliverySubscriber.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/BaseSubscriptionDeliverySubscriber.java
index 0107adf61ad..d8745eef8d6 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseSubscriptionDeliverySubscriber.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/BaseSubscriptionDeliverySubscriber.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
+package ca.uhn.fhir.jpa.subscription.process.deliver;
/*-
* #%L
@@ -24,9 +24,10 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.interceptor.api.HookParams;
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.interceptor.api.Pointcut;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.cache.ActiveSubscription;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
+import ca.uhn.fhir.jpa.subscription.process.registry.ActiveSubscription;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionRegistry;
import com.google.common.annotations.VisibleForTesting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -99,17 +100,17 @@ public abstract class BaseSubscriptionDeliverySubscriber implements MessageHandl
public abstract void handleMessage(ResourceDeliveryMessage theMessage) throws Exception;
@VisibleForTesting
- void setFhirContextForUnitTest(FhirContext theCtx) {
+ public void setFhirContextForUnitTest(FhirContext theCtx) {
myFhirContext = theCtx;
}
@VisibleForTesting
- void setInterceptorBroadcasterForUnitTest(IInterceptorBroadcaster theInterceptorBroadcaster) {
+ public void setInterceptorBroadcasterForUnitTest(IInterceptorBroadcaster theInterceptorBroadcaster) {
myInterceptorBroadcaster = theInterceptorBroadcaster;
}
@VisibleForTesting
- void setSubscriptionRegistryForUnitTest(SubscriptionRegistry theSubscriptionRegistry) {
+ public void setSubscriptionRegistryForUnitTest(SubscriptionRegistry theSubscriptionRegistry) {
mySubscriptionRegistry = theSubscriptionRegistry;
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/DaoResourceRetriever.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/DaoResourceRetriever.java
similarity index 83%
rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/DaoResourceRetriever.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/DaoResourceRetriever.java
index c4f5dcea4d4..d070b5adcba 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/DaoResourceRetriever.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/DaoResourceRetriever.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription;
+package ca.uhn.fhir.jpa.subscription.process.deliver;
/*-
* #%L
@@ -22,19 +22,16 @@ package ca.uhn.fhir.jpa.subscription;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
-import ca.uhn.fhir.jpa.dao.DaoRegistry;
-import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
-import ca.uhn.fhir.jpa.subscription.module.cache.ActiveSubscription;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.IResourceRetriever;
+import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
+import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
+import ca.uhn.fhir.jpa.subscription.process.registry.ActiveSubscription;
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-@Service
public class DaoResourceRetriever implements IResourceRetriever {
private static final Logger ourLog = LoggerFactory.getLogger(ActiveSubscription.class);
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/IResourceRetriever.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/IResourceRetriever.java
similarity index 93%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/IResourceRetriever.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/IResourceRetriever.java
index 939fd5f1bfc..930cc43f880 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/IResourceRetriever.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/IResourceRetriever.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
+package ca.uhn.fhir.jpa.subscription.process.deliver;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/EmailDetails.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/EmailDetails.java
similarity index 96%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/EmailDetails.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/EmailDetails.java
index 4043255b58c..de8c89a4928 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/EmailDetails.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/EmailDetails.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber.email;
+package ca.uhn.fhir.jpa.subscription.process.deliver.email;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/IEmailSender.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/IEmailSender.java
similarity index 92%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/IEmailSender.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/IEmailSender.java
index ff6d3a9dafb..f6f08d17f8b 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/IEmailSender.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/IEmailSender.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber.email;
+package ca.uhn.fhir.jpa.subscription.process.deliver.email;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/JavaMailEmailSender.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/JavaMailEmailSender.java
similarity index 98%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/JavaMailEmailSender.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/JavaMailEmailSender.java
index df826fa80ff..31f8aaeec6d 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/JavaMailEmailSender.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/JavaMailEmailSender.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber.email;
+package ca.uhn.fhir.jpa.subscription.process.deliver.email;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/SubscriptionDeliveringEmailSubscriber.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/SubscriptionDeliveringEmailSubscriber.java
similarity index 92%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/SubscriptionDeliveringEmailSubscriber.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/SubscriptionDeliveringEmailSubscriber.java
index 79175fd38c6..ce650ccad2f 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/email/SubscriptionDeliveringEmailSubscriber.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/email/SubscriptionDeliveringEmailSubscriber.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber.email;
+package ca.uhn.fhir.jpa.subscription.process.deliver.email;
/*-
* #%L
@@ -22,9 +22,9 @@ package ca.uhn.fhir.jpa.subscription.module.subscriber.email;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.BaseSubscriptionDeliverySubscriber;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.process.deliver.BaseSubscriptionDeliverySubscriber;
+import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
import ca.uhn.fhir.rest.api.EncodingEnum;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionDeliveringRestHookSubscriber.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/resthook/SubscriptionDeliveringRestHookSubscriber.java
similarity index 95%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionDeliveringRestHookSubscriber.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/resthook/SubscriptionDeliveringRestHookSubscriber.java
index b5e3d84170a..d9514007060 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionDeliveringRestHookSubscriber.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/resthook/SubscriptionDeliveringRestHookSubscriber.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
+package ca.uhn.fhir.jpa.subscription.process.deliver.resthook;
/*-
* #%L
@@ -21,9 +21,11 @@ package ca.uhn.fhir.jpa.subscription.module.subscriber;
*/
import ca.uhn.fhir.interceptor.api.HookParams;
-import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
import ca.uhn.fhir.interceptor.api.Pointcut;
+import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
+import ca.uhn.fhir.jpa.subscription.process.deliver.BaseSubscriptionDeliverySubscriber;
+import ca.uhn.fhir.jpa.subscription.process.deliver.IResourceRetriever;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.client.api.*;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/SubscriptionWebsocketHandler.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/websocket/SubscriptionWebsocketHandler.java
similarity index 94%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/SubscriptionWebsocketHandler.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/websocket/SubscriptionWebsocketHandler.java
index 66900c5c271..e628cdce86e 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/SubscriptionWebsocketHandler.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/websocket/SubscriptionWebsocketHandler.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber.websocket;
+package ca.uhn.fhir.jpa.subscription.process.deliver.websocket;
/*
* #%L
@@ -21,10 +21,10 @@ package ca.uhn.fhir.jpa.subscription.module.subscriber.websocket;
*/
import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.jpa.subscription.module.cache.ActiveSubscription;
-import ca.uhn.fhir.jpa.subscription.module.channel.SubscriptionChannelRegistry;
-import ca.uhn.fhir.jpa.subscription.module.channel.SubscriptionChannelWithHandlers;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage;
+import ca.uhn.fhir.jpa.subscription.process.registry.ActiveSubscription;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelRegistry;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelWithHandlers;
+import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.IdType;
import org.slf4j.Logger;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/WebsocketConnectionValidator.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/websocket/WebsocketConnectionValidator.java
similarity index 85%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/WebsocketConnectionValidator.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/websocket/WebsocketConnectionValidator.java
index 85ed070204e..0442db66a03 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/WebsocketConnectionValidator.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/websocket/WebsocketConnectionValidator.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber.websocket;
+package ca.uhn.fhir.jpa.subscription.process.deliver.websocket;
/*-
* #%L
@@ -20,17 +20,15 @@ package ca.uhn.fhir.jpa.subscription.module.subscriber.websocket;
* #L%
*/
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscriptionChannelType;
-import ca.uhn.fhir.jpa.subscription.module.cache.ActiveSubscription;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType;
+import ca.uhn.fhir.jpa.subscription.process.registry.ActiveSubscription;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionRegistry;
import com.sun.istack.NotNull;
import org.hl7.fhir.r4.model.IdType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-@Service
public class WebsocketConnectionValidator {
private static Logger ourLog = LoggerFactory.getLogger(WebsocketConnectionValidator.class);
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/WebsocketValidationResponse.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/websocket/WebsocketValidationResponse.java
similarity index 92%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/WebsocketValidationResponse.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/websocket/WebsocketValidationResponse.java
index b0112a83ee5..483143e8d3d 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/WebsocketValidationResponse.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/deliver/websocket/WebsocketValidationResponse.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber.websocket;
+package ca.uhn.fhir.jpa.subscription.process.deliver.websocket;
/*-
* #%L
@@ -20,7 +20,7 @@ package ca.uhn.fhir.jpa.subscription.module.subscriber.websocket;
* #L%
*/
-import ca.uhn.fhir.jpa.subscription.module.cache.ActiveSubscription;
+import ca.uhn.fhir.jpa.subscription.process.registry.ActiveSubscription;
public class WebsocketValidationResponse {
private final boolean myValid;
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/dbmatcher/CompositeInMemoryDaoSubscriptionMatcher.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/CompositeInMemoryDaoSubscriptionMatcher.java
similarity index 85%
rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/dbmatcher/CompositeInMemoryDaoSubscriptionMatcher.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/CompositeInMemoryDaoSubscriptionMatcher.java
index 6d885a07416..ae13ef2ad0a 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/dbmatcher/CompositeInMemoryDaoSubscriptionMatcher.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/CompositeInMemoryDaoSubscriptionMatcher.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.dbmatcher;
+package ca.uhn.fhir.jpa.subscription.process.matcher.matching;
/*-
* #%L
@@ -20,12 +20,10 @@ package ca.uhn.fhir.jpa.subscription.dbmatcher;
* #L%
*/
-import ca.uhn.fhir.jpa.dao.DaoConfig;
+import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.module.matcher.ISubscriptionMatcher;
-import ca.uhn.fhir.jpa.subscription.module.matcher.InMemorySubscriptionMatcher;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+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-base/src/main/java/ca/uhn/fhir/jpa/subscription/dbmatcher/DaoSubscriptionMatcher.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/DaoSubscriptionMatcher.java
similarity index 90%
rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/dbmatcher/DaoSubscriptionMatcher.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/DaoSubscriptionMatcher.java
index b8bcb6dd972..8299ca9c8fe 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/dbmatcher/DaoSubscriptionMatcher.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/DaoSubscriptionMatcher.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.dbmatcher;
+package ca.uhn.fhir.jpa.subscription.process.matcher.matching;
/*-
* #%L
@@ -22,14 +22,13 @@ package ca.uhn.fhir.jpa.subscription.dbmatcher;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
-import ca.uhn.fhir.jpa.dao.DaoRegistry;
-import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
+import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
+import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
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.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.module.matcher.ISubscriptionMatcher;
+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 org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/IResourceModifiedConsumer.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/IResourceModifiedConsumer.java
similarity index 85%
rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/IResourceModifiedConsumer.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/IResourceModifiedConsumer.java
index 40924bdfbf0..047649909b3 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/IResourceModifiedConsumer.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/IResourceModifiedConsumer.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription;
+package ca.uhn.fhir.jpa.subscription.process.matcher.matching;
/*-
* #%L
@@ -20,7 +20,7 @@ package ca.uhn.fhir.jpa.subscription;
* #L%
*/
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
public interface IResourceModifiedConsumer {
void submitResourceModified(ResourceModifiedMessage theMsg);
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/ISubscriptionMatcher.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/ISubscriptionMatcher.java
similarity index 81%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/ISubscriptionMatcher.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/ISubscriptionMatcher.java
index 15337a26e21..7545ef16db6 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/ISubscriptionMatcher.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/ISubscriptionMatcher.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.matcher;
+package ca.uhn.fhir.jpa.subscription.process.matcher.matching;
/*-
* #%L
@@ -21,8 +21,8 @@ package ca.uhn.fhir.jpa.subscription.module.matcher;
*/
import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
public interface ISubscriptionMatcher {
InMemoryMatchResult match(CanonicalSubscription subscription, ResourceModifiedMessage msg);
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcher.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/InMemorySubscriptionMatcher.java
similarity index 90%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcher.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/InMemorySubscriptionMatcher.java
index ca6d3d8e0dd..f81d23a7e98 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcher.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/InMemorySubscriptionMatcher.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.matcher;
+package ca.uhn.fhir.jpa.subscription.process.matcher.matching;
/*-
* #%L
@@ -23,8 +23,8 @@ package ca.uhn.fhir.jpa.subscription.module.matcher;
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.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
+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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionMatchingStrategy.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/SubscriptionMatchingStrategy.java
similarity index 94%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionMatchingStrategy.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/SubscriptionMatchingStrategy.java
index f49b7996b63..63303994d9d 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionMatchingStrategy.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/SubscriptionMatchingStrategy.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.matcher;
+package ca.uhn.fhir.jpa.subscription.process.matcher.matching;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionStrategyEvaluator.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/SubscriptionStrategyEvaluator.java
similarity index 92%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionStrategyEvaluator.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/SubscriptionStrategyEvaluator.java
index 3c805b537b0..04239f38839 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionStrategyEvaluator.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/matching/SubscriptionStrategyEvaluator.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.matcher;
+package ca.uhn.fhir.jpa.subscription.process.matcher.matching;
/*-
* #%L
@@ -23,9 +23,7 @@ package ca.uhn.fhir.jpa.subscription.module.matcher;
import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult;
import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryResourceMatcher;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-@Service
public class SubscriptionStrategyEvaluator {
@Autowired
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/BaseSubscriberForSubscriptionResources.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/BaseSubscriberForSubscriptionResources.java
new file mode 100644
index 00000000000..79e207a281f
--- /dev/null
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/BaseSubscriberForSubscriptionResources.java
@@ -0,0 +1,21 @@
+package ca.uhn.fhir.jpa.subscription.process.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 org.hl7.fhir.instance.model.api.IIdType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.messaging.MessageHandler;
+
+public abstract class BaseSubscriberForSubscriptionResources implements MessageHandler {
+
+ @Autowired
+ protected FhirContext myFhirContext;
+
+ protected boolean isSubscription(ResourceModifiedMessage theNewResource) {
+ IIdType payloadId = theNewResource.getId(myFhirContext);
+ String payloadIdType = payloadId.getResourceType();
+ return payloadIdType.equals(ResourceTypeEnum.SUBSCRIPTION.getCode());
+ }
+
+}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/MatchingQueueSubscriberLoader.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/MatchingQueueSubscriberLoader.java
new file mode 100644
index 00000000000..a4b7d6ef9cf
--- /dev/null
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/MatchingQueueSubscriberLoader.java
@@ -0,0 +1,71 @@
+package ca.uhn.fhir.jpa.subscription.process.matcher.subscriber;
+
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.messaging.MessageHandler;
+import org.springframework.messaging.SubscribableChannel;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+/*-
+ * #%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 class MatchingQueueSubscriberLoader {
+ private Logger ourLog = LoggerFactory.getLogger(MatchingQueueSubscriberLoader.class);
+ public static final String SUBSCRIPTION_MATCHING_CHANNEL_NAME = "subscription-matching";
+
+ @Autowired
+ private SubscriptionMatchingSubscriber mySubscriptionMatchingSubscriber;
+ @Autowired
+ private SubscriptionChannelFactory mySubscriptionChannelFactory;
+ @Autowired
+ private SubscriptionRegisteringSubscriber mySubscriptionRegisteringSubscriber;
+ @Autowired
+ private SubscriptionActivatingSubscriber mySubscriptionActivatingSubscriber;
+
+ protected SubscribableChannel myMatchingChannel;
+
+ @PostConstruct
+ public void start() {
+ if (myMatchingChannel == null) {
+ myMatchingChannel = mySubscriptionChannelFactory.newMatchingReceivingChannel(SUBSCRIPTION_MATCHING_CHANNEL_NAME);
+ }
+ if (myMatchingChannel != null) {
+ myMatchingChannel.subscribe(mySubscriptionMatchingSubscriber);
+ myMatchingChannel.subscribe(mySubscriptionActivatingSubscriber);
+ myMatchingChannel.subscribe(mySubscriptionRegisteringSubscriber);
+ ourLog.info("Subscription Matching Subscriber subscribed to Matching Channel {} with name {}", myMatchingChannel.getClass().getName(), SUBSCRIPTION_MATCHING_CHANNEL_NAME);
+ }
+ }
+
+ @SuppressWarnings("unused")
+ @PreDestroy
+ public void stop() {
+ if (myMatchingChannel != null) {
+ myMatchingChannel.unsubscribe(mySubscriptionMatchingSubscriber);
+ myMatchingChannel.unsubscribe(mySubscriptionActivatingSubscriber);
+ myMatchingChannel.unsubscribe(mySubscriptionRegisteringSubscriber);
+ }
+ }
+
+}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionActivatingInterceptor.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/SubscriptionActivatingSubscriber.java
similarity index 51%
rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionActivatingInterceptor.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/SubscriptionActivatingSubscriber.java
index 421c5b195d5..a1f1dbfb49e 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionActivatingInterceptor.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/SubscriptionActivatingSubscriber.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription;
+package ca.uhn.fhir.jpa.subscription.process.matcher.subscriber;
/*-
* #%L
@@ -20,24 +20,19 @@ package ca.uhn.fhir.jpa.subscription;
* #L%
*/
-import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
-import ca.uhn.fhir.interceptor.api.Hook;
-import ca.uhn.fhir.interceptor.api.Interceptor;
-import ca.uhn.fhir.interceptor.api.Pointcut;
-import ca.uhn.fhir.jpa.api.IDaoRegistry;
-import ca.uhn.fhir.jpa.config.BaseConfig;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
-import ca.uhn.fhir.jpa.dao.DaoRegistry;
-import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscriptionChannelType;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionCanonicalizer;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionConstants;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
-import ca.uhn.fhir.jpa.subscription.module.matcher.SubscriptionMatchingStrategy;
-import ca.uhn.fhir.jpa.subscription.module.matcher.SubscriptionStrategyEvaluator;
+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.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionCanonicalizer;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionConstants;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionRegistry;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.SubscriptionMatchingStrategy;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.SubscriptionStrategyEvaluator;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.api.EncodingEnum;
@@ -45,16 +40,15 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.util.SubscriptionUtil;
import com.google.common.annotations.VisibleForTesting;
-import org.hl7.fhir.dstu2.model.Subscription;
import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Lazy;
import org.springframework.core.task.AsyncTaskExecutor;
-import org.springframework.stereotype.Service;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.MessageHandler;
+import org.springframework.messaging.MessagingException;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
@@ -74,23 +68,20 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
*
* Also validates criteria. If invalid, rejects the subscription without persisting the subscription.
*/
-@Lazy
-@Interceptor
-public class SubscriptionActivatingInterceptor {
+public class SubscriptionActivatingSubscriber extends BaseSubscriberForSubscriptionResources implements MessageHandler {
private static boolean ourWaitForSubscriptionActivationSynchronouslyForUnitTest;
- private Logger ourLog = LoggerFactory.getLogger(SubscriptionActivatingInterceptor.class);
+ private Logger ourLog = LoggerFactory.getLogger(SubscriptionActivatingSubscriber.class);
@Autowired
private PlatformTransactionManager myTransactionManager;
+ // FIXME: use constant if this is still needed
@Autowired
- @Qualifier(BaseConfig.TASK_EXECUTOR_NAME)
+ @Qualifier("hapiJpaTaskExecutor")
private AsyncTaskExecutor myTaskExecutor;
@Autowired
private SubscriptionRegistry mySubscriptionRegistry;
@Autowired
private DaoRegistry myDaoRegistry;
@Autowired
- private FhirContext myFhirContext;
- @Autowired
private SubscriptionCanonicalizer mySubscriptionCanonicalizer;
@Autowired
private DaoConfig myDaoConfig;
@@ -100,10 +91,35 @@ public class SubscriptionActivatingInterceptor {
/**
* Constructor
*/
- public SubscriptionActivatingInterceptor() {
+ public SubscriptionActivatingSubscriber() {
super();
}
+ @Override
+ public void handleMessage(@Nonnull Message> theMessage) throws MessagingException {
+ if (!(theMessage instanceof ResourceModifiedJsonMessage)) {
+ ourLog.warn("Received message of unexpected type on matching channel: {}", theMessage);
+ return;
+ }
+
+ ResourceModifiedMessage payload = ((ResourceModifiedJsonMessage) theMessage).getPayload();
+ if (!isSubscription(payload)) {
+ return;
+ }
+
+ switch (payload.getOperationType()) {
+ case CREATE:
+ case UPDATE:
+ activateAndRegisterSubscriptionIfRequiredInTransaction(payload.getNewPayload(myFhirContext));
+ break;
+ case DELETE:
+ case MANUALLY_TRIGGERED:
+ default:
+ break;
+ }
+
+ }
+
public boolean activateOrRegisterSubscriptionIfRequired(final IBaseResource theSubscription) {
// Grab the value for "Subscription.channel.type" so we can see if this
// subscriber applies..
@@ -171,8 +187,7 @@ public class SubscriptionActivatingInterceptor {
ourLog.info("Activating subscription {} from status {} to {}", subscription.getIdElement().toUnqualified().getValue(), theRequestedStatus, theActiveStatus);
try {
SubscriptionUtil.setStatus(myFhirContext, subscription, theActiveStatus);
- subscription = subscriptionDao.update(subscription).getResource();
- submitResourceModifiedForUpdate(subscription);
+ subscriptionDao.update(subscription);
return true;
} catch (final UnprocessableEntityException e) {
ourLog.info("Changing status of {} to ERROR", subscription.getIdElement());
@@ -183,149 +198,12 @@ public class SubscriptionActivatingInterceptor {
}
}
- void submitResourceModifiedForUpdate(IBaseResource theNewResource) {
- submitResourceModified(theNewResource, ResourceModifiedMessage.OperationTypeEnum.UPDATE);
- }
-
- @Hook(Pointcut.STORAGE_PRECOMMIT_RESOURCE_UPDATED)
- public void resourceUpdatedPreCommit(IBaseResource theOldResource, IBaseResource theNewResource) {
- submitResourceModified(theNewResource, ResourceModifiedMessage.OperationTypeEnum.UPDATE);
- }
-
- @Hook(Pointcut.STORAGE_PRECOMMIT_RESOURCE_CREATED)
- public void resourceCreatedPreCommit(IBaseResource theResource) {
- submitResourceModified(theResource, ResourceModifiedMessage.OperationTypeEnum.CREATE);
- }
-
- @Hook(Pointcut.STORAGE_PRECOMMIT_RESOURCE_DELETED)
- public void resourceDeletedPreCommit(IBaseResource theResource) {
- submitResourceModified(theResource, ResourceModifiedMessage.OperationTypeEnum.DELETE);
- }
-
- @Hook(Pointcut.STORAGE_PRESTORAGE_RESOURCE_CREATED)
- public void resourceCreatedPreStorage(IBaseResource theResource) {
- if (isSubscription(theResource)) {
- validateSubmittedSubscription(theResource);
- }
- }
-
- @Hook(Pointcut.STORAGE_PRESTORAGE_RESOURCE_UPDATED)
- public void resourceUpdatedPreStorage(IBaseResource theOldResource, IBaseResource theNewResource) {
- if (isSubscription(theNewResource)) {
- validateSubmittedSubscription(theNewResource);
- }
- }
-
- @VisibleForTesting
- @SuppressWarnings("WeakerAccess")
- public void setSubscriptionStrategyEvaluatorForUnitTest(SubscriptionStrategyEvaluator theSubscriptionStrategyEvaluator) {
- mySubscriptionStrategyEvaluator = theSubscriptionStrategyEvaluator;
- }
-
- @SuppressWarnings("WeakerAccess")
- public void validateSubmittedSubscription(IBaseResource theSubscription) {
-
- CanonicalSubscription subscription = mySubscriptionCanonicalizer.canonicalize(theSubscription);
- boolean finished = false;
- if (subscription.getStatus() == null) {
- throw new UnprocessableEntityException("Can not process submitted Subscription - Subscription.status must be populated on this server");
- }
-
- switch (subscription.getStatus()) {
- case REQUESTED:
- case ACTIVE:
- break;
- case ERROR:
- case OFF:
- case NULL:
- finished = true;
- break;
- }
-
- mySubscriptionCanonicalizer.setMatchingStrategyTag(theSubscription, null);
-
- if (!finished) {
-
- String query = subscription.getCriteriaString();
- if (isBlank(query)) {
- throw new UnprocessableEntityException("Subscription.criteria must be populated");
- }
-
- int sep = query.indexOf('?');
- if (sep <= 1) {
- throw new UnprocessableEntityException("Subscription.criteria must be in the form \"{Resource Type}?[params]\"");
- }
-
- String resType = query.substring(0, sep);
- if (resType.contains("/")) {
- throw new UnprocessableEntityException("Subscription.criteria must be in the form \"{Resource Type}?[params]\"");
- }
-
- if (subscription.getChannelType() == null) {
- throw new UnprocessableEntityException("Subscription.channel.type must be populated");
- } else if (subscription.getChannelType() == CanonicalSubscriptionChannelType.RESTHOOK) {
- validateChannelPayload(subscription);
- validateChannelEndpoint(subscription);
- }
-
- if (!myDaoRegistry.isResourceTypeSupported(resType)) {
- throw new UnprocessableEntityException("Subscription.criteria contains invalid/unsupported resource type: " + resType);
- }
-
- try {
- SubscriptionMatchingStrategy strategy = mySubscriptionStrategyEvaluator.determineStrategy(query);
- mySubscriptionCanonicalizer.setMatchingStrategyTag(theSubscription, strategy);
- } catch (InvalidRequestException | DataFormatException e) {
- throw new UnprocessableEntityException("Invalid subscription criteria submitted: " + query + " " + e.getMessage());
- }
-
- if (subscription.getChannelType() == null) {
- throw new UnprocessableEntityException("Subscription.channel.type must be populated on this server");
- }
-
- }
- }
-
- @SuppressWarnings("WeakerAccess")
- protected void validateChannelEndpoint(CanonicalSubscription theResource) {
- if (isBlank(theResource.getEndpointUrl())) {
- throw new UnprocessableEntityException("Rest-hook subscriptions must have Subscription.channel.endpoint defined");
- }
- }
-
- @SuppressWarnings("WeakerAccess")
- protected void validateChannelPayload(CanonicalSubscription theResource) {
- if (!isBlank(theResource.getPayloadString()) && EncodingEnum.forContentType(theResource.getPayloadString()) == null) {
- throw new UnprocessableEntityException("Invalid value for Subscription.channel.payload: " + theResource.getPayloadString());
- }
- }
-
- private void submitResourceModified(IBaseResource theNewResource, ResourceModifiedMessage.OperationTypeEnum theOperationType) {
- if (isSubscription(theNewResource)) {
- submitResourceModified(new ResourceModifiedMessage(myFhirContext, theNewResource, theOperationType));
- }
- }
private boolean isSubscription(IBaseResource theNewResource) {
RuntimeResourceDefinition resourceDefinition = myFhirContext.getResourceDefinition(theNewResource);
return ResourceTypeEnum.SUBSCRIPTION.getCode().equals(resourceDefinition.getName());
}
- private void submitResourceModified(final ResourceModifiedMessage theMsg) {
- switch (theMsg.getOperationType()) {
- case DELETE:
- mySubscriptionRegistry.unregisterSubscription(theMsg.getId(myFhirContext).getIdPart());
- break;
- case CREATE:
- case UPDATE:
- activateAndRegisterSubscriptionIfRequiredInTransaction(theMsg.getNewPayload(myFhirContext));
- break;
- case MANUALLY_TRIGGERED:
- default:
- break;
- }
- }
-
private void activateAndRegisterSubscriptionIfRequiredInTransaction(IBaseResource theSubscription) {
TransactionTemplate txTemplate = new TransactionTemplate(myTransactionManager);
txTemplate.execute(new TransactionCallbackWithoutResult() {
@@ -336,19 +214,6 @@ public class SubscriptionActivatingInterceptor {
});
}
- @SuppressWarnings("WeakerAccess")
- @VisibleForTesting
- public void setSubscriptionCanonicalizerForUnitTest(SubscriptionCanonicalizer theSubscriptionCanonicalizer) {
- mySubscriptionCanonicalizer = theSubscriptionCanonicalizer;
- }
-
- @SuppressWarnings("WeakerAccess")
- @VisibleForTesting
- public void setDaoRegistryForUnitTest(DaoRegistry theDaoRegistry) {
- myDaoRegistry = theDaoRegistry;
- }
-
-
@VisibleForTesting
public static void setWaitForSubscriptionActivationSynchronouslyForUnitTest(boolean theWaitForSubscriptionActivationSynchronouslyForUnitTest) {
ourWaitForSubscriptionActivationSynchronouslyForUnitTest = theWaitForSubscriptionActivationSynchronouslyForUnitTest;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionMatchingSubscriber.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/SubscriptionMatchingSubscriber.java
similarity index 89%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionMatchingSubscriber.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/SubscriptionMatchingSubscriber.java
index 0401be75496..2f8ff1632a8 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionMatchingSubscriber.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/SubscriptionMatchingSubscriber.java
@@ -1,17 +1,19 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
+package ca.uhn.fhir.jpa.subscription.process.matcher.subscriber;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.interceptor.api.HookParams;
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.module.cache.ActiveSubscription;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
-import ca.uhn.fhir.jpa.subscription.module.channel.SubscriptionChannelRegistry;
-import ca.uhn.fhir.jpa.subscription.module.matcher.ISubscriptionMatcher;
-import ca.uhn.fhir.rest.api.Constants;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelRegistry;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.process.registry.ActiveSubscription;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionRegistry;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.ISubscriptionMatcher;
+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.rest.api.EncodingEnum;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IBaseResource;
@@ -23,8 +25,8 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
-import org.springframework.stereotype.Service;
+import javax.annotation.Nonnull;
import java.util.Collection;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
@@ -50,9 +52,9 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
* #L%
*/
-@Service
public class SubscriptionMatchingSubscriber implements MessageHandler {
private Logger ourLog = LoggerFactory.getLogger(SubscriptionMatchingSubscriber.class);
+ public static final String SUBSCRIPTION_MATCHING_CHANNEL_NAME = "subscription-matching";
@Autowired
private ISubscriptionMatcher mySubscriptionMatcher;
@@ -65,8 +67,9 @@ public class SubscriptionMatchingSubscriber implements MessageHandler {
@Autowired
private SubscriptionChannelRegistry mySubscriptionChannelRegistry;
+
@Override
- public void handleMessage(Message> theMessage) throws MessagingException {
+ public void handleMessage(@Nonnull Message> theMessage) throws MessagingException {
ourLog.trace("Handling resource modified message: {}", theMessage);
if (!(theMessage instanceof ResourceModifiedJsonMessage)) {
@@ -109,7 +112,6 @@ public class SubscriptionMatchingSubscriber implements MessageHandler {
private void doMatchActiveSubscriptionsAndDeliver(ResourceModifiedMessage theMsg) {
IIdType resourceId = theMsg.getId(myFhirContext);
- Boolean isText = false;
Collection subscriptions = mySubscriptionRegistry.getAll();
@@ -147,7 +149,6 @@ public class SubscriptionMatchingSubscriber implements MessageHandler {
EncodingEnum encoding = null;
if (subscription.getPayloadString() != null && !subscription.getPayloadString().isEmpty()) {
encoding = EncodingEnum.forContentType(subscription.getPayloadString());
- isText = subscription.getPayloadString().equals(Constants.CT_TEXT);
}
encoding = defaultIfNull(encoding, EncodingEnum.JSON);
@@ -179,16 +180,16 @@ public class SubscriptionMatchingSubscriber implements MessageHandler {
}
private boolean sendToDeliveryChannel(ActiveSubscription nextActiveSubscription, ResourceDeliveryMessage theDeliveryMsg) {
- boolean retval = false;
+ boolean retVal = false;
ResourceDeliveryJsonMessage wrappedMsg = new ResourceDeliveryJsonMessage(theDeliveryMsg);
MessageChannel deliveryChannel = mySubscriptionChannelRegistry.get(nextActiveSubscription.getChannelName()).getChannel();
if (deliveryChannel != null) {
- retval = true;
+ retVal = true;
trySendToDeliveryChannel(wrappedMsg, deliveryChannel);
} else {
ourLog.warn("Do not have delivery channel for subscription {}", nextActiveSubscription.getId());
}
- return retval;
+ return retVal;
}
private void trySendToDeliveryChannel(ResourceDeliveryJsonMessage theWrappedMsg, MessageChannel theDeliveryChannel) {
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/SubscriptionRegisteringSubscriber.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/SubscriptionRegisteringSubscriber.java
new file mode 100644
index 00000000000..1273ad8e8a8
--- /dev/null
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/matcher/subscriber/SubscriptionRegisteringSubscriber.java
@@ -0,0 +1,84 @@
+package ca.uhn.fhir.jpa.subscription.process.matcher.subscriber;
+
+/*-
+ * #%L
+ * HAPI FHIR JPA 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.jpa.subscription.model.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionRegistry;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.MessageHandler;
+import org.springframework.messaging.MessagingException;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Responsible for transitioning subscription resources from REQUESTED to ACTIVE
+ * Once activated, the subscription is added to the SubscriptionRegistry.
+ *
+ * Also validates criteria. If invalid, rejects the subscription without persisting the subscription.
+ */
+public class SubscriptionRegisteringSubscriber extends BaseSubscriberForSubscriptionResources implements MessageHandler {
+ private Logger ourLog = LoggerFactory.getLogger(SubscriptionRegisteringSubscriber.class);
+ @Autowired
+ private FhirContext myFhirContext;
+ @Autowired
+ private SubscriptionRegistry mySubscriptionRegistry;
+
+ /**
+ * Constructor
+ */
+ public SubscriptionRegisteringSubscriber() {
+ super();
+ }
+
+ @Override
+ public void handleMessage(@Nonnull Message> theMessage) throws MessagingException {
+ if (!(theMessage instanceof ResourceModifiedJsonMessage)) {
+ ourLog.warn("Received message of unexpected type on matching channel: {}", theMessage);
+ return;
+ }
+
+ ResourceModifiedMessage payload = ((ResourceModifiedJsonMessage) theMessage).getPayload();
+
+ if (!isSubscription(payload)) {
+ return;
+ }
+
+ switch (payload.getOperationType()) {
+ case DELETE:
+ mySubscriptionRegistry.unregisterSubscription(payload.getId(myFhirContext).getIdPart());
+ break;
+ case CREATE:
+ case UPDATE:
+ mySubscriptionRegistry.registerSubscriptionUnlessAlreadyRegistered(payload.getNewPayload(myFhirContext));
+ break;
+ case MANUALLY_TRIGGERED:
+ default:
+ break;
+ }
+
+ }
+
+}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/ActiveSubscription.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/ActiveSubscription.java
similarity index 90%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/ActiveSubscription.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/ActiveSubscription.java
index cdacb3401f5..1ea5160ac6d 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/ActiveSubscription.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/ActiveSubscription.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
+package ca.uhn.fhir.jpa.subscription.process.registry;
/*-
* #%L
@@ -20,8 +20,8 @@ package ca.uhn.fhir.jpa.subscription.module.cache;
* #L%
*/
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscriptionChannelType;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/ActiveSubscriptionCache.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/ActiveSubscriptionCache.java
similarity index 97%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/ActiveSubscriptionCache.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/ActiveSubscriptionCache.java
index 305a1889161..d21161f5370 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/ActiveSubscriptionCache.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/ActiveSubscriptionCache.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
+package ca.uhn.fhir.jpa.subscription.process.registry;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/dbcache/DaoSubscriptionProvider.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/DaoSubscriptionProvider.java
similarity index 77%
rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/dbcache/DaoSubscriptionProvider.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/DaoSubscriptionProvider.java
index 6931bfd99e9..ad75c98df8e 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/dbcache/DaoSubscriptionProvider.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/DaoSubscriptionProvider.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.dbcache;
+package ca.uhn.fhir.jpa.subscription.process.registry;
/*-
* #%L
@@ -20,22 +20,20 @@ package ca.uhn.fhir.jpa.subscription.dbcache;
* #L%
*/
-import ca.uhn.fhir.jpa.dao.DaoRegistry;
-import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
+import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
+import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
-import ca.uhn.fhir.jpa.subscription.SubscriptionActivatingInterceptor;
-import ca.uhn.fhir.jpa.subscription.module.cache.ISubscriptionProvider;
+import ca.uhn.fhir.jpa.subscription.process.matcher.subscriber.SubscriptionActivatingSubscriber;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-@Service
public class DaoSubscriptionProvider implements ISubscriptionProvider {
+
@Autowired
DaoRegistry myDaoRegistry;
@Autowired
- private SubscriptionActivatingInterceptor mySubscriptionActivatingInterceptor;
+ private SubscriptionActivatingSubscriber mySubscriptionActivatingInterceptor;
@Override
public IBundleProvider search(SearchParameterMap theMap) {
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/ISubscriptionProvider.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/ISubscriptionProvider.java
similarity index 94%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/ISubscriptionProvider.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/ISubscriptionProvider.java
index 1f254e919b3..a8afb1ccde4 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/ISubscriptionProvider.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/ISubscriptionProvider.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
+package ca.uhn.fhir.jpa.subscription.process.registry;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionCanonicalizer.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionCanonicalizer.java
similarity index 97%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionCanonicalizer.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionCanonicalizer.java
index a1229b456a5..bd8d75f3cf2 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionCanonicalizer.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionCanonicalizer.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
+package ca.uhn.fhir.jpa.subscription.process.registry;
/*-
* #%L
@@ -23,21 +23,23 @@ package ca.uhn.fhir.jpa.subscription.module.cache;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.model.util.JpaConstants;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscriptionChannelType;
-import ca.uhn.fhir.jpa.subscription.module.matcher.SubscriptionMatchingStrategy;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.SubscriptionMatchingStrategy;
import ca.uhn.fhir.model.dstu2.resource.Subscription;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.exceptions.FHIRException;
-import org.hl7.fhir.instance.model.api.*;
+import org.hl7.fhir.instance.model.api.IBaseMetaType;
+import org.hl7.fhir.instance.model.api.IBaseReference;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.hl7.fhir.r4.model.Extension;
import org.hl7.fhir.r5.model.Coding;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -49,7 +51,6 @@ import java.util.stream.Collectors;
import static java.util.stream.Collectors.mapping;
import static java.util.stream.Collectors.toList;
-@Service
public class SubscriptionCanonicalizer {
private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionCanonicalizer.class);
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionConstants.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionConstants.java
similarity index 96%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionConstants.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionConstants.java
index 4c3822cd420..e4f9254c845 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionConstants.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionConstants.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
+package ca.uhn.fhir.jpa.subscription.process.registry;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionLoader.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionLoader.java
similarity index 97%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionLoader.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionLoader.java
index 8a7d09abca2..59e66b77696 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionLoader.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionLoader.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
+package ca.uhn.fhir.jpa.subscription.process.registry;
/*-
* #%L
@@ -37,8 +37,6 @@ import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.HashSet;
@@ -47,8 +45,6 @@ import java.util.Set;
import java.util.concurrent.Semaphore;
-@Service
-@Lazy
public class SubscriptionLoader {
private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionLoader.class);
private static final int MAX_RETRIES = 60; // 60 * 5 seconds = 5 minutes
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionRegistry.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionRegistry.java
similarity index 94%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionRegistry.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionRegistry.java
index f507e980034..26edf6f9a44 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionRegistry.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/process/registry/SubscriptionRegistry.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
+package ca.uhn.fhir.jpa.subscription.process.registry;
/*-
* #%L
@@ -23,9 +23,9 @@ package ca.uhn.fhir.jpa.subscription.module.cache;
import ca.uhn.fhir.interceptor.api.HookParams;
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.interceptor.api.Pointcut;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.channel.ISubscriptionDeliveryChannelNamer;
-import ca.uhn.fhir.jpa.subscription.module.channel.SubscriptionChannelRegistry;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.ISubscriptionDeliveryChannelNamer;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelRegistry;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
@@ -33,7 +33,6 @@ import org.hl7.fhir.r4.model.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
import javax.annotation.PreDestroy;
import java.util.Collection;
@@ -47,8 +46,6 @@ import java.util.Optional;
* handlers are all caches in this registry so they can be removed it the subscription is deleted.
*/
-// TODO KHS Does jpa need a subscription registry if matching is disabled?
-@Component
public class SubscriptionRegistry {
private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionRegistry.class);
private final ActiveSubscriptionCache myActiveSubscriptionCache = new ActiveSubscriptionCache();
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/config/SubscriptionSubmitterConfig.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/config/SubscriptionSubmitterConfig.java
new file mode 100644
index 00000000000..eab841e50b2
--- /dev/null
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/config/SubscriptionSubmitterConfig.java
@@ -0,0 +1,31 @@
+package ca.uhn.fhir.jpa.subscription.submit.config;
+
+import ca.uhn.fhir.jpa.subscription.submit.interceptor.SubscriptionMatcherInterceptor;
+import ca.uhn.fhir.jpa.subscription.submit.interceptor.SubmitInterceptorLoader;
+import ca.uhn.fhir.jpa.subscription.submit.interceptor.SubscriptionValidatingInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * This Spring config should be imported by a system that submits resources to the
+ * matching queue for processing
+ */
+@Configuration
+public class SubscriptionSubmitterConfig {
+
+ @Bean
+ public SubscriptionMatcherInterceptor subscriptionMatcherInterceptor() {
+ return new SubscriptionMatcherInterceptor();
+ }
+
+ @Bean
+ public SubscriptionValidatingInterceptor subscriptionValidatingInterceptor() {
+ return new SubscriptionValidatingInterceptor();
+ }
+
+ @Bean
+ public SubmitInterceptorLoader subscriptionMatcherInterceptorLoader() {
+ return new SubmitInterceptorLoader();
+ }
+
+}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionInterceptorLoader.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubmitInterceptorLoader.java
similarity index 77%
rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionInterceptorLoader.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubmitInterceptorLoader.java
index ba75e082ee9..af3c7030410 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionInterceptorLoader.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubmitInterceptorLoader.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription;
+package ca.uhn.fhir.jpa.subscription.submit.interceptor;
/*-
* #%L
@@ -21,28 +21,27 @@ package ca.uhn.fhir.jpa.subscription;
*/
import ca.uhn.fhir.interceptor.api.IInterceptorService;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionLoader;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
-import ca.uhn.fhir.jpa.subscription.module.channel.SubscriptionChannelRegistry;
+import ca.uhn.fhir.jpa.api.config.DaoConfig;
+import ca.uhn.fhir.jpa.subscription.process.matcher.subscriber.SubscriptionActivatingSubscriber;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionLoader;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionRegistry;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelRegistry;
import com.google.common.annotations.VisibleForTesting;
import org.hl7.fhir.dstu2.model.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
-import org.springframework.stereotype.Service;
import java.util.Set;
-@Service
-public class SubscriptionInterceptorLoader {
- private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionInterceptorLoader.class);
+public class SubmitInterceptorLoader {
+ private static final Logger ourLog = LoggerFactory.getLogger(SubmitInterceptorLoader.class);
@Autowired
private SubscriptionMatcherInterceptor mySubscriptionMatcherInterceptor;
@Autowired
- private SubscriptionActivatingInterceptor mySubscriptionActivatingInterceptor;
+ private SubscriptionValidatingInterceptor mySubscriptionValidatingInterceptor;
@Autowired
DaoConfig myDaoConfig;
@Autowired
@@ -61,14 +60,14 @@ public class SubscriptionInterceptorLoader {
ourLog.info("Subscriptions are disabled on this server. Subscriptions will not be activated and incoming resources will not be matched against subscriptions.");
} else {
loadSubscriptions();
- ourLog.info("Registering subscription activating interceptor");
- myInterceptorRegistry.registerInterceptor(mySubscriptionActivatingInterceptor);
if (myDaoConfig.isSubscriptionMatchingEnabled()) {
mySubscriptionMatcherInterceptor.start();
ourLog.info("Registering subscription matcher interceptor");
myInterceptorRegistry.registerInterceptor(mySubscriptionMatcherInterceptor);
}
}
+
+ myInterceptorRegistry.registerInterceptor(mySubscriptionValidatingInterceptor);
}
private void loadSubscriptions() {
@@ -81,9 +80,8 @@ public class SubscriptionInterceptorLoader {
}
@VisibleForTesting
- void unregisterInterceptorsForUnitTest() {
- myInterceptorRegistry.unregisterInterceptor(mySubscriptionActivatingInterceptor);
+ public void unregisterInterceptorsForUnitTest() {
myInterceptorRegistry.unregisterInterceptor(mySubscriptionMatcherInterceptor);
- mySubscriptionMatcherInterceptor.preDestroy();
+ myInterceptorRegistry.unregisterInterceptor(mySubscriptionValidatingInterceptor);
}
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionMatcherInterceptor.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionMatcherInterceptor.java
similarity index 74%
rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionMatcherInterceptor.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionMatcherInterceptor.java
index 7f20e410e30..2d88a34a5de 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionMatcherInterceptor.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionMatcherInterceptor.java
@@ -1,12 +1,13 @@
-package ca.uhn.fhir.jpa.subscription;
+package ca.uhn.fhir.jpa.subscription.submit.interceptor;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.interceptor.api.*;
-import ca.uhn.fhir.jpa.subscription.module.LinkedBlockingQueueSubscribableChannel;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.module.channel.SubscriptionChannelFactory;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.SubscriptionMatchingSubscriber;
+import ca.uhn.fhir.jpa.subscription.channel.queue.LinkedBlockingQueueChannel;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelFactory;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.IResourceModifiedConsumer;
+import ca.uhn.fhir.jpa.subscription.process.matcher.subscriber.SubscriptionMatchingSubscriber;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
import ca.uhn.fhir.jpa.util.JpaInterceptorBroadcaster;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import com.google.common.annotations.VisibleForTesting;
@@ -15,13 +16,11 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
import org.springframework.messaging.SubscribableChannel;
-import org.springframework.stereotype.Component;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager;
-import javax.annotation.PreDestroy;
+import javax.annotation.PostConstruct;
/*-
* #%L
@@ -43,14 +42,8 @@ import javax.annotation.PreDestroy;
* #L%
*/
-@Component
-@Lazy
-@Interceptor()
+@Interceptor
public class SubscriptionMatcherInterceptor implements IResourceModifiedConsumer {
- public static final String SUBSCRIPTION_MATCHING_CHANNEL_NAME = "subscription-matching";
- protected SubscribableChannel myMatchingChannel;
- @Autowired
- protected SubscriptionChannelFactory mySubscriptionChannelFactory;
private Logger ourLog = LoggerFactory.getLogger(SubscriptionMatcherInterceptor.class);
@Autowired
private FhirContext myFhirContext;
@@ -58,6 +51,10 @@ public class SubscriptionMatcherInterceptor implements IResourceModifiedConsumer
private SubscriptionMatchingSubscriber mySubscriptionMatchingSubscriber;
@Autowired
private IInterceptorBroadcaster myInterceptorBroadcaster;
+ @Autowired
+ private SubscriptionChannelFactory mySubscriptionChannelFactory;
+
+ private SubscribableChannel myMatchingChannel;
/**
* Constructor
@@ -66,22 +63,9 @@ public class SubscriptionMatcherInterceptor implements IResourceModifiedConsumer
super();
}
+ @PostConstruct
public void start() {
- if (myMatchingChannel == null) {
- myMatchingChannel = mySubscriptionChannelFactory.newMatchingChannel(SUBSCRIPTION_MATCHING_CHANNEL_NAME);
- }
- myMatchingChannel.subscribe(mySubscriptionMatchingSubscriber);
- ourLog.info("Subscription Matching Subscriber subscribed to Matching Channel {} with name {}", myMatchingChannel.getClass().getName(), SUBSCRIPTION_MATCHING_CHANNEL_NAME);
-
- }
-
- @SuppressWarnings("unused")
- @PreDestroy
- public void preDestroy() {
-
- if (myMatchingChannel != null) {
- myMatchingChannel.unsubscribe(mySubscriptionMatchingSubscriber);
- }
+ myMatchingChannel = mySubscriptionChannelFactory.newMatchingSendingChannel(SubscriptionMatchingSubscriber.SUBSCRIPTION_MATCHING_CHANNEL_NAME);
}
@Hook(Pointcut.STORAGE_PRECOMMIT_RESOURCE_CREATED)
@@ -101,6 +85,7 @@ public class SubscriptionMatcherInterceptor implements IResourceModifiedConsumer
private void submitResourceModified(IBaseResource theNewResource, ResourceModifiedMessage.OperationTypeEnum theOperationType, RequestDetails theRequest) {
ResourceModifiedMessage msg = new ResourceModifiedMessage(myFhirContext, theNewResource, theOperationType);
+
// Interceptor call: SUBSCRIPTION_RESOURCE_MODIFIED
HookParams params = new HookParams()
.add(ResourceModifiedMessage.class, msg);
@@ -150,7 +135,7 @@ public class SubscriptionMatcherInterceptor implements IResourceModifiedConsumer
}
@VisibleForTesting
- LinkedBlockingQueueSubscribableChannel getProcessingChannelForUnitTest() {
- return (LinkedBlockingQueueSubscribableChannel) myMatchingChannel;
+ public LinkedBlockingQueueChannel getProcessingChannelForUnitTest() {
+ return (LinkedBlockingQueueChannel) myMatchingChannel;
}
}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionValidatingInterceptor.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionValidatingInterceptor.java
new file mode 100644
index 00000000000..efcb902e39d
--- /dev/null
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionValidatingInterceptor.java
@@ -0,0 +1,144 @@
+package ca.uhn.fhir.jpa.subscription.submit.interceptor;
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.interceptor.api.Hook;
+import ca.uhn.fhir.interceptor.api.Interceptor;
+import ca.uhn.fhir.interceptor.api.Pointcut;
+import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.SubscriptionMatchingStrategy;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.SubscriptionStrategyEvaluator;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionCanonicalizer;
+import ca.uhn.fhir.parser.DataFormatException;
+import ca.uhn.fhir.rest.api.EncodingEnum;
+import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
+import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
+import com.google.common.annotations.VisibleForTesting;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static org.apache.commons.lang3.StringUtils.isBlank;
+
+@Interceptor
+public class SubscriptionValidatingInterceptor {
+
+ @Autowired
+ private SubscriptionCanonicalizer mySubscriptionCanonicalizer;
+ @Autowired
+ private DaoRegistry myDaoRegistry;
+ @Autowired
+ private SubscriptionStrategyEvaluator mySubscriptionStrategyEvaluator;
+ @Autowired
+ private FhirContext myFhirContext;
+
+ @Hook(Pointcut.STORAGE_PRESTORAGE_RESOURCE_CREATED)
+ public void resourcePreCreate(IBaseResource theResource) {
+ validateSubmittedSubscription(theResource);
+ }
+
+ @Hook(Pointcut.STORAGE_PRESTORAGE_RESOURCE_UPDATED)
+ public void resourcePreCreate(IBaseResource theOldResource, IBaseResource theResource) {
+ validateSubmittedSubscription(theResource);
+ }
+
+ public void validateSubmittedSubscription(IBaseResource theSubscription) {
+ if (!"Subscription".equals(myFhirContext.getResourceDefinition(theSubscription).getName())) {
+ return;
+ }
+
+ CanonicalSubscription subscription = mySubscriptionCanonicalizer.canonicalize(theSubscription);
+ boolean finished = false;
+ if (subscription.getStatus() == null) {
+ throw new UnprocessableEntityException("Can not process submitted Subscription - Subscription.status must be populated on this server");
+ }
+
+ switch (subscription.getStatus()) {
+ case REQUESTED:
+ case ACTIVE:
+ break;
+ case ERROR:
+ case OFF:
+ case NULL:
+ finished = true;
+ break;
+ }
+
+ mySubscriptionCanonicalizer.setMatchingStrategyTag(theSubscription, null);
+
+ if (!finished) {
+
+ String query = subscription.getCriteriaString();
+ if (isBlank(query)) {
+ throw new UnprocessableEntityException("Subscription.criteria must be populated");
+ }
+
+ int sep = query.indexOf('?');
+ if (sep <= 1) {
+ throw new UnprocessableEntityException("Subscription.criteria must be in the form \"{Resource Type}?[params]\"");
+ }
+
+ String resType = query.substring(0, sep);
+ if (resType.contains("/")) {
+ throw new UnprocessableEntityException("Subscription.criteria must be in the form \"{Resource Type}?[params]\"");
+ }
+
+ if (subscription.getChannelType() == null) {
+ throw new UnprocessableEntityException("Subscription.channel.type must be populated");
+ } else if (subscription.getChannelType() == CanonicalSubscriptionChannelType.RESTHOOK) {
+ validateChannelPayload(subscription);
+ validateChannelEndpoint(subscription);
+ }
+
+ if (!myDaoRegistry.isResourceTypeSupported(resType)) {
+ throw new UnprocessableEntityException("Subscription.criteria contains invalid/unsupported resource type: " + resType);
+ }
+
+ try {
+ SubscriptionMatchingStrategy strategy = mySubscriptionStrategyEvaluator.determineStrategy(query);
+ mySubscriptionCanonicalizer.setMatchingStrategyTag(theSubscription, strategy);
+ } catch (InvalidRequestException | DataFormatException e) {
+ throw new UnprocessableEntityException("Invalid subscription criteria submitted: " + query + " " + e.getMessage());
+ }
+
+ if (subscription.getChannelType() == null) {
+ throw new UnprocessableEntityException("Subscription.channel.type must be populated on this server");
+ }
+
+ }
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ protected void validateChannelEndpoint(CanonicalSubscription theResource) {
+ if (isBlank(theResource.getEndpointUrl())) {
+ throw new UnprocessableEntityException("Rest-hook subscriptions must have Subscription.channel.endpoint defined");
+ }
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ protected void validateChannelPayload(CanonicalSubscription theResource) {
+ if (!isBlank(theResource.getPayloadString()) && EncodingEnum.forContentType(theResource.getPayloadString()) == null) {
+ throw new UnprocessableEntityException("Invalid value for Subscription.channel.payload: " + theResource.getPayloadString());
+ }
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ @VisibleForTesting
+ public void setSubscriptionCanonicalizerForUnitTest(SubscriptionCanonicalizer theSubscriptionCanonicalizer) {
+ mySubscriptionCanonicalizer = theSubscriptionCanonicalizer;
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ @VisibleForTesting
+ public void setDaoRegistryForUnitTest(DaoRegistry theDaoRegistry) {
+ myDaoRegistry = theDaoRegistry;
+ }
+
+
+ @VisibleForTesting
+ @SuppressWarnings("WeakerAccess")
+ public void setSubscriptionStrategyEvaluatorForUnitTest(SubscriptionStrategyEvaluator theSubscriptionStrategyEvaluator) {
+ mySubscriptionStrategyEvaluator = theSubscriptionStrategyEvaluator;
+ }
+
+}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/ISubscriptionTriggeringSvc.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/ISubscriptionTriggeringSvc.java
similarity index 95%
rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/ISubscriptionTriggeringSvc.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/ISubscriptionTriggeringSvc.java
index 3fdbfd869a0..ac972e543f6 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/ISubscriptionTriggeringSvc.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/ISubscriptionTriggeringSvc.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription;
+package ca.uhn.fhir.jpa.subscription.triggering;
/*-
* #%L
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionTriggeringSvcImpl.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java
similarity index 96%
rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionTriggeringSvcImpl.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java
index 49506449095..721fe15e588 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionTriggeringSvcImpl.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription;
+package ca.uhn.fhir.jpa.subscription.triggering;
/*-
* #%L
@@ -22,18 +22,18 @@ package ca.uhn.fhir.jpa.subscription;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
-import ca.uhn.fhir.jpa.dao.DaoRegistry;
-import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
+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.jpa.model.cross.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.provider.SubscriptionTriggeringProvider;
-import ca.uhn.fhir.jpa.search.ISearchCoordinatorSvc;
import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
+import ca.uhn.fhir.jpa.subscription.process.matcher.matching.IResourceModifiedConsumer;
import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.api.CacheControlDirective;
@@ -59,7 +59,6 @@ import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
@@ -75,13 +74,12 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-import static ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider.RESOURCE_ID;
+import static ca.uhn.fhir.jpa.model.util.JpaConstants.SUBSCRIPTION_TRIGGERING_PARAM_RESOURCE_ID;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
-@Service
public class SubscriptionTriggeringSvcImpl implements ISubscriptionTriggeringSvc {
- private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionTriggeringProvider.class);
+ private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionTriggeringSvcImpl.class);
private static final int DEFAULT_MAX_SUBMIT = 10000;
private final List myActiveJobs = new ArrayList<>();
@Autowired
@@ -129,8 +127,8 @@ public class SubscriptionTriggeringSvcImpl implements ISubscriptionTriggeringSvc
// Resource URLs must be compete
for (IPrimitiveType next : resourceIds) {
IdType resourceId = new IdType(next.getValue());
- ValidateUtil.isTrueOrThrowInvalidRequest(resourceId.hasResourceType(), RESOURCE_ID + " parameter must have resource type");
- ValidateUtil.isTrueOrThrowInvalidRequest(resourceId.hasIdPart(), RESOURCE_ID + " parameter must have resource ID part");
+ ValidateUtil.isTrueOrThrowInvalidRequest(resourceId.hasResourceType(), SUBSCRIPTION_TRIGGERING_PARAM_RESOURCE_ID + " parameter must have resource type");
+ ValidateUtil.isTrueOrThrowInvalidRequest(resourceId.hasIdPart(), SUBSCRIPTION_TRIGGERING_PARAM_RESOURCE_ID + " parameter must have resource ID part");
}
// Search URLs must be valid
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/interceptor/SubscriptionDebugLogInterceptor.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java
similarity index 94%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/interceptor/SubscriptionDebugLogInterceptor.java
rename to hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java
index 4baef540493..288ad03b2d5 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/interceptor/SubscriptionDebugLogInterceptor.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.interceptor;
+package ca.uhn.fhir.jpa.subscription.util;
/*-
* #%L
@@ -24,9 +24,9 @@ import ca.uhn.fhir.interceptor.api.Hook;
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.module.CanonicalSubscriptionChannelType;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage;
+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.util.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,7 +43,7 @@ import java.util.function.Function;
* This interceptor loges each step in the processing pipeline with a
* different event code, using the event codes itemized in
* {@link EventCodeEnum}. By default these are each placed in a logger with
- * a different name (e.g. ca.uhn.fhir.jpa.subscription.module.interceptor.SubscriptionDebugLogInterceptor.SUBS20
+ * a different name (e.g. ca.uhn.fhir.jpa.subscription.util.SubscriptionDebugLogInterceptor.SUBS20
* in order to facilitate fine-grained logging controls where some codes are omitted and
* some are not.
*
@@ -63,7 +63,7 @@ public class SubscriptionDebugLogInterceptor {
private final EnumMap myLoggers;
/**
- * Constructor that logs at INFO level to the logger ca.uhn.fhir.jpa.subscription.module.interceptor.SubscriptionDebugLogInterceptor
+ * Constructor that logs at INFO level to the logger ca.uhn.fhir.jpa.subscription.util.SubscriptionDebugLogInterceptor
*/
public SubscriptionDebugLogInterceptor() {
this(defaultLogFactory(), Level.INFO);
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/BaseSubscriptionDstu3Test.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/BaseSubscriptionDstu3Test.java
deleted file mode 100644
index f74460fa338..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/BaseSubscriptionDstu3Test.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module;
-
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
-import ca.uhn.fhir.jpa.subscription.module.channel.SubscriptionChannelRegistry;
-import ca.uhn.fhir.jpa.subscription.module.config.TestSubscriptionDstu3Config;
-import ca.uhn.fhir.util.StopWatch;
-import org.hl7.fhir.dstu3.model.Subscription;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-@ContextConfiguration(classes = {TestSubscriptionDstu3Config.class})
-public abstract class BaseSubscriptionDstu3Test extends BaseSubscriptionTest {
- @Autowired
- protected SubscriptionRegistry mySubscriptionRegistry;
- @Autowired
- protected SubscriptionChannelRegistry mySubscriptionChannelRegistry;
-
- private final SubscriptionTestHelper mySubscriptionTestHelper = new SubscriptionTestHelper();
-
- public static void waitForSize(int theTarget, List> theList) {
- StopWatch sw = new StopWatch();
- while (theList.size() != theTarget && sw.getMillis() <= 16000) {
- try {
- Thread.sleep(50);
- } catch (InterruptedException theE) {
- throw new Error(theE);
- }
- }
- if (sw.getMillis() >= 16000) {
- String describeResults = theList
- .stream()
- .map(t -> {
- if (t == null) {
- return "null";
- }
- if (t instanceof IBaseResource) {
- return ((IBaseResource) t).getIdElement().getValue();
- }
- return t.toString();
- })
- .collect(Collectors.joining(", "));
- fail("Size " + theList.size() + " is != target " + theTarget + " - Got: " + describeResults);
- }
- }
-
- protected long nextId() {
- return mySubscriptionTestHelper.nextId();
- }
-
- protected Subscription makeActiveSubscription(String theCriteria, String thePayload, String theEndpoint) {
- return mySubscriptionTestHelper.makeActiveSubscription(theCriteria, thePayload, theEndpoint);
- }
-
- protected Subscription makeSubscriptionWithStatus(String theCriteria, String thePayload, String theEndpoint, Subscription.SubscriptionStatus status) {
- return mySubscriptionTestHelper.makeSubscriptionWithStatus(theCriteria, thePayload, theEndpoint, status);
- }
-
- protected void clearRegistry() {
- mySubscriptionRegistry.unregisterAllSubscriptions();
- await().until(this::registryEmpty);
- }
-
- private boolean registryEmpty() {
- return mySubscriptionRegistry.size() == 0 && mySubscriptionChannelRegistry.size() == 0;
- }
-
- protected void assertRegistrySize(int theSize) {
- assertRegistrySize(theSize, theSize);
- }
-
- protected void assertRegistrySize(int theSubscriptionRegistrySize, int theSubscriptionChannelRegistrySize) {
- assertEquals(theSubscriptionRegistrySize, mySubscriptionRegistry.size());
- assertEquals(theSubscriptionChannelRegistrySize, mySubscriptionChannelRegistry.size());
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/BaseSubscriptionTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/BaseSubscriptionTest.java
deleted file mode 100644
index b0730ecff71..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/BaseSubscriptionTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module;
-
-import ca.uhn.fhir.interceptor.api.IInterceptorService;
-import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionLoader;
-import ca.uhn.fhir.jpa.subscription.module.config.MockFhirClientSearchParamProvider;
-import ca.uhn.fhir.jpa.subscription.module.config.MockFhirClientSubscriptionProvider;
-import ca.uhn.fhir.rest.api.server.IBundleProvider;
-import org.junit.After;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-public abstract class BaseSubscriptionTest {
-
- @Autowired
- MockFhirClientSubscriptionProvider myMockFhirClientSubscriptionProvider;
-
- @Autowired
- ISearchParamRegistry mySearchParamRegistry;
-
- @Autowired
- MockFhirClientSearchParamProvider myMockFhirClientSearchParamProvider;
-
- @Autowired
- protected
- IInterceptorService myInterceptorRegistry;
-
- @After
- public void afterClearAnonymousLambdas() {
- myInterceptorRegistry.unregisterAllInterceptors();
- }
-
- public void initSearchParamRegistry(IBundleProvider theBundleProvider) {
- myMockFhirClientSearchParamProvider.setBundleProvider(theBundleProvider);
- mySearchParamRegistry.forceRefresh();
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/CanonicalSubscriptionTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/CanonicalSubscriptionTest.java
index a67ede950c6..d2823865868 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/CanonicalSubscriptionTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/CanonicalSubscriptionTest.java
@@ -1,9 +1,10 @@
package ca.uhn.fhir.jpa.subscription.module;
import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionCanonicalizer;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryJsonMessage;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionCanonicalizer;
+import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryJsonMessage;
+import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.assertj.core.util.Lists;
import org.hamcrest.Matchers;
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 36969daf1c7..0d3534384eb 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,6 +1,7 @@
package ca.uhn.fhir.jpa.subscription.module;
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import org.hl7.fhir.r4.model.Organization;
import org.junit.Test;
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/config/SubscriptionConfig.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/SubscriptionConfig.java
similarity index 69%
rename from hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/config/SubscriptionConfig.java
rename to hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/SubscriptionConfig.java
index e375d9996b4..2e3589d9116 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/module/config/SubscriptionConfig.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/SubscriptionConfig.java
@@ -1,4 +1,4 @@
-package ca.uhn.fhir.jpa.subscription.module.config;
+package ca.uhn.fhir.jpa.subscription.module;
/*-
* #%L
@@ -23,15 +23,13 @@ package ca.uhn.fhir.jpa.subscription.module.config;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.jpa.searchparam.config.SearchParamConfig;
-import ca.uhn.fhir.jpa.subscription.module.cache.LinkedBlockingQueueSubscribableChannelFactory;
-import ca.uhn.fhir.jpa.subscription.module.channel.ISubscribableChannelFactory;
-import ca.uhn.fhir.jpa.subscription.module.channel.SubscriptionChannelFactory;
+import ca.uhn.fhir.jpa.subscription.channel.queue.LinkedBlockingQueueChannelFactory;
+import ca.uhn.fhir.jpa.subscription.channel.queue.IQueueChannelFactory;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelFactory;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.EnableScheduling;
@@ -39,12 +37,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@Configuration
@Import({SearchParamConfig.class})
@EnableScheduling
-@ComponentScan(
- basePackages = {"ca.uhn.fhir.jpa.subscription.module"},
- excludeFilters = {
- @ComponentScan.Filter(type = FilterType.REGEX, pattern = "ca.uhn.fhir.jpa.subscription.module.standalone.*")
- }
-)
public class SubscriptionConfig {
@Autowired
@@ -57,8 +49,8 @@ public class SubscriptionConfig {
}
@Bean
- public ISubscribableChannelFactory subscribableChannelFactory() {
- return new LinkedBlockingQueueSubscribableChannelFactory();
+ public IQueueChannelFactory subscribableChannelFactory() {
+ return new LinkedBlockingQueueChannelFactory();
}
@Bean
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/BaseSubscriptionRegistryTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/BaseSubscriptionRegistryTest.java
deleted file mode 100644
index 7931f0864dd..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/BaseSubscriptionRegistryTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
-
-import ca.uhn.fhir.jpa.subscription.module.BaseSubscriptionDstu3Test;
-import org.hl7.fhir.dstu3.model.Subscription;
-import org.junit.After;
-
-public abstract class BaseSubscriptionRegistryTest extends BaseSubscriptionDstu3Test {
- public static final String SUBSCRIPTION_ID = "1";
- public static final String ORIG_CRITERIA = "Patient?";
- public static final String NEW_CRITERIA = "Observation?";
-
- @After
- public void clearRegistryAfter() {
- super.clearRegistry();
- }
-
- protected Subscription createSubscription() {
- Subscription subscription = new Subscription();
- subscription.setId(SUBSCRIPTION_ID);
- subscription.setCriteria(ORIG_CRITERIA);
- subscription.setStatus(Subscription.SubscriptionStatus.ACTIVE);
- setChannel(subscription, Subscription.SubscriptionChannelType.RESTHOOK);
- return subscription;
- }
-
- protected void setChannel(Subscription theSubscription, Subscription.SubscriptionChannelType theResthook) {
- Subscription.SubscriptionChannelComponent channel = new Subscription.SubscriptionChannelComponent();
- channel.setType(theResthook);
- channel.setPayload("application/json");
- channel.setEndpoint("http://unused.test.endpoint/");
- theSubscription.setChannel(channel);
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionLoaderTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionLoaderTest.java
deleted file mode 100755
index f7e3e55ad72..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionLoaderTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
-
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionLoader;
-import ca.uhn.fhir.jpa.subscription.module.config.MockFhirClientSubscriptionProvider;
-import ca.uhn.fhir.jpa.subscription.module.standalone.BaseBlockingQueueSubscribableChannelDstu3Test;
-import org.hl7.fhir.dstu3.model.Subscription;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.assertEquals;
-
-public class SubscriptionLoaderTest extends BaseBlockingQueueSubscribableChannelDstu3Test {
- private static final int MOCK_FHIR_CLIENT_FAILURES = 3;
- @Autowired
- private MockFhirClientSubscriptionProvider myMockFhirClientSubscriptionProvider;
-
- @Before
- public void setFailCount() {
- myMockFhirClientSubscriptionProvider.setFailCount(MOCK_FHIR_CLIENT_FAILURES);
- }
-
- @After
- public void restoreFailCount() {
- myMockFhirClientSubscriptionProvider.setFailCount(0);
- }
-
- @Test
- public void testSubscriptionLoaderFhirClientDown() throws Exception {
- String payload = "application/fhir+json";
-
- String criteria1 = "Observation?code=SNOMED-CT|" + myCode + "&_format=xml";
- String criteria2 = "Observation?code=SNOMED-CT|" + myCode + "111&_format=xml";
-
- List subs = new ArrayList<>();
- subs.add(makeActiveSubscription(criteria1, payload, ourListenerServerBase));
- subs.add(makeActiveSubscription(criteria2, payload, ourListenerServerBase));
-
- mySubscriptionActivatedPost.setExpectedCount(2);
- initSubscriptionLoader(subs, "uuid");
- mySubscriptionActivatedPost.awaitExpected();
- assertEquals(0, myMockFhirClientSubscriptionProvider.getFailCount());
- }
-
-
- @Test
- public void testMultipleThreadsDontBlock() throws InterruptedException {
- SubscriptionLoader svc = new SubscriptionLoader();
- CountDownLatch latch = new CountDownLatch(1);
- new Thread(()->{
- try {
- svc.acquireSemaphoreForUnitTest();
- latch.countDown();
- } catch (InterruptedException theE) {
- // ignore
- }
- }).start();
-
- latch.await(10, TimeUnit.SECONDS);
- svc.syncSubscriptions();
- }
-
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionRegistrySharedTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionRegistrySharedTest.java
deleted file mode 100644
index 0c5924b0651..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionRegistrySharedTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
-
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.channel.ISubscriptionDeliveryChannelNamer;
-import org.hl7.fhir.dstu3.model.Subscription;
-import org.junit.Test;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-import org.springframework.test.annotation.DirtiesContext;
-
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
-public class SubscriptionRegistrySharedTest extends BaseSubscriptionRegistryTest {
-
- private static final String OTHER_ID = "OTHER_ID";
-
- @Configuration
- public static class SpringConfig {
- @Primary
- @Bean
- ISubscriptionDeliveryChannelNamer subscriptionDeliveryChannelNamer() {
- return new SharedNamer();
- }
-
- private class SharedNamer implements ISubscriptionDeliveryChannelNamer {
- @Override
- public String nameFromSubscription(CanonicalSubscription theCanonicalSubscription) {
- return "shared";
- }
- }
- }
-
- @Test
- public void testTwoSubscriptionsOneChannel() {
- Subscription subscription = createSubscription();
- assertRegistrySize(0);
- mySubscriptionRegistry.registerSubscriptionUnlessAlreadyRegistered(subscription);
- assertRegistrySize(1);
- Subscription otherSubscription = createSubscription();
- otherSubscription.setId(OTHER_ID);
- mySubscriptionRegistry.registerSubscriptionUnlessAlreadyRegistered(otherSubscription);
- assertRegistrySize(2, 1);
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionRegistryTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionRegistryTest.java
deleted file mode 100644
index 12c37ff025e..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/SubscriptionRegistryTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
-
-import org.hl7.fhir.dstu3.model.Subscription;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class SubscriptionRegistryTest extends BaseSubscriptionRegistryTest {
- @Test
- public void updateSubscriptionReusesActiveSubscription() {
- Subscription subscription = createSubscription();
- assertRegistrySize(0);
- mySubscriptionRegistry.registerSubscriptionUnlessAlreadyRegistered(subscription);
- assertRegistrySize(1);
- ActiveSubscription origActiveSubscription = mySubscriptionRegistry.get(SUBSCRIPTION_ID);
- assertEquals(ORIG_CRITERIA, origActiveSubscription.getCriteriaString());
-
- subscription.setCriteria(NEW_CRITERIA);
- assertEquals(ORIG_CRITERIA, origActiveSubscription.getCriteriaString());
- mySubscriptionRegistry.registerSubscriptionUnlessAlreadyRegistered(subscription);
- assertRegistrySize(1);
- ActiveSubscription newActiveSubscription = mySubscriptionRegistry.get(SUBSCRIPTION_ID);
- assertEquals(NEW_CRITERIA, newActiveSubscription.getCriteriaString());
- // The same object
- assertTrue(newActiveSubscription == origActiveSubscription);
- }
-
- @Test
- public void updateSubscriptionDoesntReusesActiveSubscriptionWhenChannelChanges() {
- Subscription subscription = createSubscription();
- assertRegistrySize(0);
- mySubscriptionRegistry.registerSubscriptionUnlessAlreadyRegistered(subscription);
- assertRegistrySize(1);
-
- ActiveSubscription origActiveSubscription = mySubscriptionRegistry.get(SUBSCRIPTION_ID);
- assertEquals(ORIG_CRITERIA, origActiveSubscription.getCriteriaString());
-
- setChannel(subscription, Subscription.SubscriptionChannelType.EMAIL);
-
- assertEquals(ORIG_CRITERIA, origActiveSubscription.getCriteriaString());
- mySubscriptionRegistry.registerSubscriptionUnlessAlreadyRegistered(subscription);
- assertRegistrySize(1);
-
- ActiveSubscription newActiveSubscription = mySubscriptionRegistry.get(SUBSCRIPTION_ID);
- // A new object
- assertFalse(newActiveSubscription == origActiveSubscription);
- }
-
- @Test
- public void updateRemove() {
- Subscription subscription = createSubscription();
- assertRegistrySize(0);
- mySubscriptionRegistry.registerSubscriptionUnlessAlreadyRegistered(subscription);
- assertRegistrySize(1);
- mySubscriptionRegistry.unregisterSubscription(subscription.getId());
- assertRegistrySize(0);
- }
-
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/channel/SubscriptionChannelRegistryTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/channel/SubscriptionChannelRegistryTest.java
index 3871d77ef3f..0fb9edac08d 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/channel/SubscriptionChannelRegistryTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/channel/SubscriptionChannelRegistryTest.java
@@ -1,8 +1,11 @@
package ca.uhn.fhir.jpa.subscription.module.channel;
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.cache.ActiveSubscription;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.process.registry.ActiveSubscription;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelFactory;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelRegistry;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionDeliveryHandlerFactory;
import ca.uhn.fhir.model.primitive.IdDt;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/MockFhirClientSearchParamProvider.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/MockFhirClientSearchParamProvider.java
deleted file mode 100644
index 14e0f8834d6..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/MockFhirClientSearchParamProvider.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.config;
-
-import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
-import ca.uhn.fhir.jpa.subscription.module.standalone.FhirClientSearchParamProvider;
-import ca.uhn.fhir.rest.api.server.IBundleProvider;
-
-public class MockFhirClientSearchParamProvider extends FhirClientSearchParamProvider {
- private final MockProvider myMockProvider = new MockProvider();
-
- public MockFhirClientSearchParamProvider() {
- super(null);
- }
-
- public void setBundleProvider(IBundleProvider theBundleProvider) { myMockProvider.setBundleProvider(theBundleProvider); }
- public void setFailCount(int theFailCount) { myMockProvider.setFailCount(theFailCount); }
- public int getFailCount() { return myMockProvider.getFailCount(); }
-
- @Override
- public IBundleProvider search(SearchParameterMap theParams) { return myMockProvider.search(theParams); }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/MockFhirClientSubscriptionProvider.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/MockFhirClientSubscriptionProvider.java
deleted file mode 100644
index fba2470251d..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/MockFhirClientSubscriptionProvider.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.config;
-
-import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
-import ca.uhn.fhir.jpa.subscription.module.standalone.FhirClientSubscriptionProvider;
-import ca.uhn.fhir.rest.api.server.IBundleProvider;
-
-public class MockFhirClientSubscriptionProvider extends FhirClientSubscriptionProvider {
- private final MockProvider myMockProvider = new MockProvider();
-
- public MockFhirClientSubscriptionProvider() {
- super(null);
- }
-
- public void setBundleProvider(IBundleProvider theBundleProvider) { myMockProvider.setBundleProvider(theBundleProvider); }
- public void setFailCount(int theFailCount) { myMockProvider.setFailCount(theFailCount); }
- public int getFailCount() { return myMockProvider.getFailCount(); }
-
- @Override
- public IBundleProvider search(SearchParameterMap theParams) { return myMockProvider.search(theParams); }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/MockProvider.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/MockProvider.java
deleted file mode 100644
index 2ce9230b9f1..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/MockProvider.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.config;
-
-import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
-import ca.uhn.fhir.rest.api.server.IBundleProvider;
-import ca.uhn.fhir.rest.server.SimpleBundleProvider;
-
-public class MockProvider {
- private IBundleProvider myBundleProvider = new SimpleBundleProvider();
- private int myFailCount = 0;
-
- public void setBundleProvider(IBundleProvider theBundleProvider) {
- myBundleProvider = theBundleProvider;
- }
-
- public IBundleProvider search(SearchParameterMap theParams) {
- if (myFailCount > 0) {
- --myFailCount;
- throw new RuntimeException("Mock Search Failed");
- }
- return myBundleProvider;
- }
-
- public void setFailCount(int theFailCount) {
- myFailCount = theFailCount;
- }
-
- public int getFailCount() {
- return myFailCount;
- }
-
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/TestSubscriptionConfig.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/TestSubscriptionConfig.java
deleted file mode 100644
index bab13ab95eb..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/TestSubscriptionConfig.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.config;
-
-import ca.uhn.fhir.interceptor.executor.InterceptorService;
-import ca.uhn.fhir.jpa.model.entity.ModelConfig;
-import ca.uhn.fhir.jpa.subscription.module.matcher.ISubscriptionMatcher;
-import ca.uhn.fhir.jpa.subscription.module.matcher.InMemorySubscriptionMatcher;
-import ca.uhn.fhir.jpa.subscription.module.standalone.StandaloneSubscriptionConfig;
-import ca.uhn.fhir.rest.client.api.IGenericClient;
-import org.mockito.Mockito;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import org.springframework.test.context.TestPropertySource;
-
-@Configuration
-@TestPropertySource(properties = {
- "scheduling_disabled=true"
-})
-@Import(StandaloneSubscriptionConfig.class)
-public class TestSubscriptionConfig extends SubscriptionConfig {
-
- @Bean
- public ModelConfig modelConfig() {
- return new ModelConfig();
- }
-
- @Bean
- public IGenericClient fhirClient() {
- return Mockito.mock(IGenericClient.class);
- };
-
- @Bean
- public ISubscriptionMatcher inMemorySubscriptionMatcher() {
- return new InMemorySubscriptionMatcher();
- }
-
- @Bean
- public InterceptorService interceptorRegistry() {
- return new InterceptorService("hapi-fhir-jpa-subscription");
- }
-
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/TestSubscriptionDstu3Config.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/TestSubscriptionDstu3Config.java
deleted file mode 100644
index fe7bf69ac1b..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/TestSubscriptionDstu3Config.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.config;
-
-import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.jpa.api.IDaoRegistry;
-import ca.uhn.fhir.jpa.model.sched.ISchedulerService;
-import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamProvider;
-import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry;
-import ca.uhn.fhir.jpa.searchparam.registry.SearchParamRegistryImpl;
-import ca.uhn.fhir.jpa.subscription.module.cache.ISubscriptionProvider;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import org.springframework.context.annotation.Primary;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@Configuration
-public class TestSubscriptionDstu3Config extends TestSubscriptionConfig {
-
- @Bean
- public FhirContext fhirContext() {
- return FhirContext.forDstu3();
- }
-
- @Bean
- @Primary
- public ISearchParamProvider searchParamProvider() {
- return new MockFhirClientSearchParamProvider();
- }
-
- @Bean
- @Primary
- public ISubscriptionProvider subscriptionProvider() {
- return new MockFhirClientSubscriptionProvider();
- }
-
- @Bean
- public IDaoRegistry daoRegistry() {
- IDaoRegistry retVal = mock(IDaoRegistry.class);
- when(retVal.isResourceTypeSupported(any())).thenReturn(true);
- return retVal;
- }
-
- @Bean
- public ISchedulerService schedulerService() {
- return mock(ISchedulerService.class);
- }
-
-}
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
deleted file mode 100644
index 82c9384d4de..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java
+++ /dev/null
@@ -1,645 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.matcher;
-
-import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.jpa.model.entity.ModelConfig;
-import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult;
-import ca.uhn.fhir.jpa.searchparam.matcher.SearchParamMatcher;
-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 org.hl7.fhir.dstu3.model.*;
-import org.hl7.fhir.dstu3.model.codesystems.MedicationRequestCategory;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.hl7.fhir.instance.model.api.IIdType;
-import org.junit.After;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.junit.Assert.*;
-
-public class InMemorySubscriptionMatcherR3Test extends BaseSubscriptionDstu3Test {
- @Autowired
- SubscriptionStrategyEvaluator mySubscriptionStrategyEvaluator;
- @Autowired
- SearchParamMatcher mySearchParamMatcher;
- @Autowired
- ModelConfig myModelConfig;
- @Autowired
- FhirContext myFhirContext;
-
- private void assertUnsupported(IBaseResource resource, String criteria) {
- assertFalse(mySearchParamMatcher.match(criteria, resource, null).supported());
- assertEquals(SubscriptionMatchingStrategy.DATABASE, mySubscriptionStrategyEvaluator.determineStrategy(criteria));
- }
-
- private void assertMatched(IBaseResource resource, String criteria) {
- InMemoryMatchResult result = mySearchParamMatcher.match(criteria, resource, null);
-
- assertTrue(result.supported());
- assertTrue(result.matched());
- assertEquals(SubscriptionMatchingStrategy.IN_MEMORY, mySubscriptionStrategyEvaluator.determineStrategy(criteria));
- }
-
- private void assertNotMatched(IBaseResource resource, String criteria) {
- assertNotMatched(resource, criteria, SubscriptionMatchingStrategy.IN_MEMORY);
- }
-
- private void assertNotMatched(IBaseResource resource, String criteria, SubscriptionMatchingStrategy theSubscriptionMatchingStrategy) {
- InMemoryMatchResult result = mySearchParamMatcher.match(criteria, resource, null);
-
- assertTrue(result.supported());
- assertFalse(result.matched());
-
- assertEquals(theSubscriptionMatchingStrategy, mySubscriptionStrategyEvaluator.determineStrategy(criteria));
- }
-
- @After
- public void after() {
- myModelConfig.setTreatBaseUrlsAsLocal(new ModelConfig().getTreatBaseUrlsAsLocal());
- }
-
- /**
- * Technically this is an invalid reference in most cases, but this shouldn't choke
- * the matcher in the case that it gets used.
- */
- @Test
- public void testPlaceholderIdInReference() {
-
- ProcedureRequest pr = new ProcedureRequest();
- pr.setId("ProcedureRequest/123");
- pr.setIntent(ProcedureRequest.ProcedureRequestIntent.ORIGINALORDER);
-
- pr.setSubject(new Reference("urn:uuid:aaaaaaaaaa"));
- assertMatched(pr, "ProcedureRequest?intent=original-order");
- assertNotMatched(pr, "ProcedureRequest?subject=Patient/123");
-
- pr.setSubject(new Reference("Foo/123"));
- assertMatched(pr, "ProcedureRequest?intent=original-order");
- assertNotMatched(pr, "ProcedureRequest?subject=Patient/123");
-
- pr.setSubject(new Reference("Patient/"));
- assertMatched(pr, "ProcedureRequest?intent=original-order");
- assertNotMatched(pr, "ProcedureRequest?subject=Patient/123");
-
- }
-
-
- @Test
- public void testResourceById() {
-
- ProcedureRequest pr = new ProcedureRequest();
- pr.setId("ProcedureRequest/123");
- pr.setIntent(ProcedureRequest.ProcedureRequestIntent.ORIGINALORDER);
-
- assertMatched(pr, "ProcedureRequest?_id=123");
- assertMatched(pr, "ProcedureRequest?_id=ProcedureRequest/123");
- assertMatched(pr, "ProcedureRequest?_id=ProcedureRequest/123,ProcedureRequest/999");
- assertMatched(pr, "ProcedureRequest?_id=ProcedureRequest/123&_id=ProcedureRequest/123");
- assertNotMatched(pr, "ProcedureRequest?_id=ProcedureRequest/888");
- assertNotMatched(pr, "ProcedureRequest?_id=ProcedureRequest/888,ProcedureRequest/999");
- assertNotMatched(pr, "ProcedureRequest?_id=ProcedureRequest/123&_id=ProcedureRequest/888");
-
- }
-
-
- /*
- The following tests are copied from an e-mail from a site using HAPI FHIR
- */
-
- @Test
- public void testQuestionnaireResponse() {
- String criteria = "QuestionnaireResponse?questionnaire=HomeAbsenceHospitalizationRecord,ARIncenterAbsRecord";
-
- {
- QuestionnaireResponse qr = new QuestionnaireResponse();
- qr.getQuestionnaire().setReference("Questionnaire/HomeAbsenceHospitalizationRecord");
- assertMatched(qr, criteria);
- }
- {
- QuestionnaireResponse qr = new QuestionnaireResponse();
- qr.getQuestionnaire().setReference("Questionnaire/Other");
- assertNotMatched(qr, criteria);
- }
- {
- QuestionnaireResponse qr = new QuestionnaireResponse();
- qr.getQuestionnaire().setDisplay("Questionnaire/HomeAbsenceHospitalizationRecord");
- assertNotMatched(qr, criteria);
- }
- }
-
- @Test
- public void testCommunicationRequest() {
- String criteria = "CommunicationRequest?occurrence==2018-10-17";
-
- {
- CommunicationRequest cr = new CommunicationRequest();
- cr.setOccurrence(new DateTimeType("2018-10-17"));
- assertMatched(cr, criteria);
- }
- {
- CommunicationRequest cr = new CommunicationRequest();
- cr.setOccurrence(new DateTimeType("2018-10-16"));
- assertNotMatched(cr, criteria);
- }
- {
- CommunicationRequest cr = new CommunicationRequest();
- cr.setOccurrence(new DateTimeType("2018-10-16"));
- assertNotMatched(cr, criteria);
- }
- }
-
- @Test
- public void testProcedureRequest() {
- String criteria = "ProcedureRequest?intent=original-order";
-
- {
- ProcedureRequest pr = new ProcedureRequest();
- pr.setIntent(ProcedureRequest.ProcedureRequestIntent.ORIGINALORDER);
- assertMatched(pr, criteria);
- }
- {
- ProcedureRequest pr = new ProcedureRequest();
- pr.setIntent(ProcedureRequest.ProcedureRequestIntent.ORDER);
- assertNotMatched(pr, criteria);
- }
- }
-
- @Test
- public void testObservationContextTypeUnsupported() {
- String criteria = "Observation?code=17861-6&context.type=IHD";
- {
- Observation obs = new Observation();
- obs.getCode().addCoding().setCode("XXX");
- assertNotMatched(obs, criteria, SubscriptionMatchingStrategy.DATABASE);
- }
- {
- Observation obs = new Observation();
- obs.getCode().addCoding().setCode("17861-6");
- assertUnsupported(obs, criteria);
- }
- }
-
- // Check that it still fails fast even if the chained parameter is first
- @Test
- public void testObservationContextTypeUnsupportedReverse() {
- String criteria = "Observation?context.type=IHD&code=17861-6";
- {
- Observation obs = new Observation();
- obs.getCode().addCoding().setCode("XXX");
- assertNotMatched(obs, criteria, SubscriptionMatchingStrategy.DATABASE);
- }
- {
- Observation obs = new Observation();
- obs.getCode().addCoding().setCode("17861-6");
- assertUnsupported(obs, criteria);
- }
- }
-
- @Test
- public void medicationRequestOutpatient() {
- // Note the date== evaluates to date=eq which is a legacy format supported by hapi fhir
- String criteria = "MedicationRequest?intent=instance-order&category=outpatient&date==2018-10-19";
-
- {
- MedicationRequest mr = new MedicationRequest();
- mr.setIntent(MedicationRequest.MedicationRequestIntent.INSTANCEORDER);
- mr.getCategory().addCoding().setCode(MedicationRequestCategory.OUTPATIENT.toCode());
- Dosage dosage = new Dosage();
- Timing timing = new Timing();
- timing.getEvent().add(new DateTimeType("2018-10-19"));
- dosage.setTiming(timing);
- mr.getDosageInstruction().add(dosage);
- assertMatched(mr, criteria);
- }
-
- {
- MedicationRequest mr = new MedicationRequest();
- mr.setIntent(MedicationRequest.MedicationRequestIntent.INSTANCEORDER);
- mr.getCategory().addCoding().setCode(MedicationRequestCategory.INPATIENT.toCode());
- Dosage dosage = new Dosage();
- Timing timing = new Timing();
- timing.getEvent().add(new DateTimeType("2018-10-19"));
- dosage.setTiming(timing);
- mr.getDosageInstruction().add(dosage);
- assertNotMatched(mr, criteria);
- }
-
- {
- MedicationRequest mr = new MedicationRequest();
- mr.setIntent(MedicationRequest.MedicationRequestIntent.INSTANCEORDER);
- mr.getCategory().addCoding().setCode(MedicationRequestCategory.OUTPATIENT.toCode());
- Dosage dosage = new Dosage();
- Timing timing = new Timing();
- timing.getEvent().add(new DateTimeType("2018-10-20"));
- dosage.setTiming(timing);
- mr.getDosageInstruction().add(dosage);
- assertNotMatched(mr, criteria);
- }
- }
-
- @Test
- public void testMedicationRequestStatuses() {
- String criteria = "MedicationRequest?intent=plan&category=outpatient&status=suspended,entered-in-error,cancelled,stopped";
-
- // Note suspended is an invalid status and will never match
- {
- MedicationRequest mr = new MedicationRequest();
- mr.setIntent(MedicationRequest.MedicationRequestIntent.PLAN);
- mr.getCategory().addCoding().setCode(MedicationRequestCategory.OUTPATIENT.toCode());
- mr.setStatus(MedicationRequest.MedicationRequestStatus.ENTEREDINERROR);
- assertMatched(mr, criteria);
- }
- {
- MedicationRequest mr = new MedicationRequest();
- mr.setIntent(MedicationRequest.MedicationRequestIntent.PLAN);
- mr.getCategory().addCoding().setCode(MedicationRequestCategory.OUTPATIENT.toCode());
- mr.setStatus(MedicationRequest.MedicationRequestStatus.CANCELLED);
- assertMatched(mr, criteria);
- }
- {
- MedicationRequest mr = new MedicationRequest();
- mr.setIntent(MedicationRequest.MedicationRequestIntent.PLAN);
- mr.getCategory().addCoding().setCode(MedicationRequestCategory.OUTPATIENT.toCode());
- mr.setStatus(MedicationRequest.MedicationRequestStatus.STOPPED);
- assertMatched(mr, criteria);
- }
- {
- MedicationRequest mr = new MedicationRequest();
- mr.setIntent(MedicationRequest.MedicationRequestIntent.PLAN);
- mr.getCategory().addCoding().setCode(MedicationRequestCategory.OUTPATIENT.toCode());
- mr.setStatus(MedicationRequest.MedicationRequestStatus.ACTIVE);
- assertNotMatched(mr, criteria);
- }
- }
-
- @Test
- public void testBloodTest() {
- String criteria = "Observation?code=FR_Org1Blood2nd,FR_Org1Blood3rd,FR_Org%201BldCult,FR_Org2Blood2nd,FR_Org2Blood3rd,FR_Org%202BldCult,FR_Org3Blood2nd,FR_Org3Blood3rd,FR_Org3BldCult,FR_Org4Blood2nd,FR_Org4Blood3rd,FR_Org4BldCult,FR_Org5Blood2nd,FR_Org5Blood3rd,FR_Org%205BldCult,FR_Org6Blood2nd,FR_Org6Blood3rd,FR_Org6BldCult,FR_Org7Blood2nd,FR_Org7Blood3rd,FR_Org7BldCult,FR_Org8Blood2nd,FR_Org8Blood3rd,FR_Org8BldCult,FR_Org9Blood2nd,FR_Org9Blood3rd,FR_Org9BldCult,FR_Bld2ndCulture,FR_Bld3rdCulture,FR_Blood%20Culture,FR_Com1Bld3rd,FR_Com1BldCult,FR_Com2Bld2nd,FR_Com2Bld3rd,FR_Com2BldCult,FR_CultureBld2nd,FR_CultureBld3rd,FR_CultureBldCul,FR_GmStainBldCul,FR_GramStain2Bld,FR_GramStain3Bld,FR_GramStNegBac&context.type=IHD";
-
- {
- Observation obs = new Observation();
- obs.getCode().addCoding().setCode("FR_Org1Blood2nd");
- assertUnsupported(obs, criteria);
- }
- {
- Observation obs = new Observation();
- obs.getCode().addCoding().setCode("XXX");
- assertNotMatched(obs, criteria, SubscriptionMatchingStrategy.DATABASE);
- }
- }
-
- @Test
- public void testProcedureHemodialysis() {
- String criteria = "Procedure?category=Hemodialysis";
-
- {
- Procedure proc = new Procedure();
- proc.getCategory().addCoding().setCode("Hemodialysis");
- assertMatched(proc, criteria);
- }
- {
- Procedure proc = new Procedure();
- proc.getCategory().addCoding().setCode("XXX");
- assertNotMatched(proc, criteria);
- }
- }
-
- @Test
- public void testProcedureHDStandard() {
- String criteria = "Procedure?code=HD_Standard&status=completed&location=Lab123";
-
- {
- Procedure proc = new Procedure();
- proc.getCode().addCoding().setCode("HD_Standard");
- proc.setStatus(Procedure.ProcedureStatus.COMPLETED);
- IIdType locId = new IdType("Location", "Lab123");
- proc.getLocation().setReference(locId.getValue());
- assertMatched(proc, criteria);
- }
- {
- Procedure proc = new Procedure();
- proc.getCode().addCoding().setCode("HD_Standard");
- proc.setStatus(Procedure.ProcedureStatus.COMPLETED);
- IIdType locId = new IdType("Location", "XXX");
- proc.getLocation().setReference(locId.getValue());
- assertNotMatched(proc, criteria);
- }
- {
- Procedure proc = new Procedure();
- proc.getCode().addCoding().setCode("XXX");
- proc.setStatus(Procedure.ProcedureStatus.COMPLETED);
- IIdType locId = new IdType("Location", "Lab123");
- proc.getLocation().setReference(locId.getValue());
- assertNotMatched(proc, criteria);
- }
- }
-
- @Test
- public void testProvenance() {
- String criteria = "Provenance?activity=http://hl7.org/fhir/v3/DocumentCompletion%7CAU";
-
- SearchParameter sp = new SearchParameter();
- sp.addBase("Provenance");
- sp.setCode("activity");
- sp.setType(Enumerations.SearchParamType.TOKEN);
- sp.setExpression("Provenance.activity");
- sp.setXpathUsage(SearchParameter.XPathUsageType.NORMAL);
- sp.setStatus(Enumerations.PublicationStatus.ACTIVE);
-
- IBundleProvider bundle = new SimpleBundleProvider(Collections.singletonList(sp), "uuid");
- initSearchParamRegistry(bundle);
-
- {
- Provenance prov = new Provenance();
- prov.setActivity(new Coding().setSystem("http://hl7.org/fhir/v3/DocumentCompletion").setCode("AU"));
- assertMatched(prov, criteria);
- }
- {
- Provenance prov = new Provenance();
- assertNotMatched(prov, criteria);
- }
- {
- Provenance prov = new Provenance();
- prov.setActivity(new Coding().setCode("XXX"));
- assertNotMatched(prov, criteria);
- }
-
- }
-
- @Test
- public void testBodySite() {
- String criteria = "BodySite?accessType=Catheter,PD%20Catheter";
-
- SearchParameter sp = new SearchParameter();
- sp.addBase("BodySite");
- sp.setCode("accessType");
- sp.setType(Enumerations.SearchParamType.TOKEN);
- sp.setExpression("BodySite.extension('BodySite#accessType')");
- sp.setXpathUsage(SearchParameter.XPathUsageType.NORMAL);
- sp.setStatus(Enumerations.PublicationStatus.ACTIVE);
-
- IBundleProvider bundle = new SimpleBundleProvider(Collections.singletonList(sp), "uuid");
- initSearchParamRegistry(bundle);
-
- {
- BodySite bodySite = new BodySite();
- bodySite.addExtension().setUrl("BodySite#accessType").setValue(new Coding().setCode("Catheter"));
- assertMatched(bodySite, criteria);
- }
- {
- BodySite bodySite = new BodySite();
- bodySite.addExtension().setUrl("BodySite#accessType").setValue(new Coding().setCode("PD Catheter"));
- assertMatched(bodySite, criteria);
- }
- {
- BodySite bodySite = new BodySite();
- assertNotMatched(bodySite, criteria);
- }
- {
- BodySite bodySite = new BodySite();
- bodySite.addExtension().setUrl("BodySite#accessType").setValue(new Coding().setCode("XXX"));
- assertNotMatched(bodySite, criteria);
- }
-
- }
-
- @Test
- public void testProcedureAnyLocation() {
- String criteria = "Procedure?code=HD_Standard&status=completed";
- {
- Procedure proc = new Procedure();
- proc.getCode().addCoding().setCode("HD_Standard");
- proc.setStatus(Procedure.ProcedureStatus.COMPLETED);
- IIdType locId = new IdType("Location", "Lab456");
- proc.getLocation().setReference(locId.getValue());
- assertMatched(proc, criteria);
- }
- {
- Procedure proc = new Procedure();
- proc.getCode().addCoding().setCode("HD_Standard");
- proc.setStatus(Procedure.ProcedureStatus.ABORTED);
- assertNotMatched(proc, criteria);
- }
- {
- Procedure proc = new Procedure();
- proc.getCode().addCoding().setCode("XXX");
- proc.setStatus(Procedure.ProcedureStatus.COMPLETED);
- assertNotMatched(proc, criteria);
- }
- }
-
- @Test
- public void testQuestionnaireResponseLong() {
- String criteria = "QuestionnaireResponse?questionnaire=HomeAbsenceHospitalizationRecord,ARIncenterAbsRecord,FMCSWDepressionSymptomsScreener,FMCAKIComprehensiveSW,FMCSWIntensiveScreener,FMCESRDComprehensiveSW,FMCNutritionProgressNote,FMCAKIComprehensiveRN";
-
- {
- QuestionnaireResponse qr = new QuestionnaireResponse();
- qr.getQuestionnaire().setReference("Questionnaire/HomeAbsenceHospitalizationRecord");
- assertMatched(qr, criteria);
- }
- {
- QuestionnaireResponse qr = new QuestionnaireResponse();
- qr.getQuestionnaire().setReference("Questionnaire/FMCSWIntensiveScreener");
- assertMatched(qr, criteria);
- }
- {
- QuestionnaireResponse qr = new QuestionnaireResponse();
- qr.getQuestionnaire().setReference("Questionnaire/FMCAKIComprehensiveRN");
- assertMatched(qr, criteria);
- }
- {
- QuestionnaireResponse qr = new QuestionnaireResponse();
- assertNotMatched(qr, criteria);
- }
- {
- QuestionnaireResponse qr = new QuestionnaireResponse();
- qr.getQuestionnaire().setReference("Questionnaire/FMCAKIComprehensiveRM");
- assertNotMatched(qr, criteria);
- }
- }
-
- @Test
- public void testProcedureRequestCategory() {
- String criteria = "ProcedureRequest?intent=instance-order&category=Laboratory,Ancillary%20Orders,Hemodialysis&occurrence==2018-10-19";
-
- SearchParameter sp = new SearchParameter();
- sp.addBase("ProcedureRequest");
- sp.setCode("category");
- sp.setType(Enumerations.SearchParamType.TOKEN);
- sp.setExpression("ProcedureRequest.category");
- sp.setXpathUsage(SearchParameter.XPathUsageType.NORMAL);
- sp.setStatus(Enumerations.PublicationStatus.ACTIVE);
-
- IBundleProvider bundle = new SimpleBundleProvider(Collections.singletonList(sp), "uuid");
- initSearchParamRegistry(bundle);
-
- {
- ProcedureRequest pr = new ProcedureRequest();
- pr.setIntent(ProcedureRequest.ProcedureRequestIntent.INSTANCEORDER);
- CodeableConcept code = new CodeableConcept();
- code.addCoding().setCode("Laboratory");
- pr.getCategory().add(code);
- pr.setOccurrence(new DateTimeType("2018-10-19"));
- assertMatched(pr, criteria);
- }
- {
- ProcedureRequest pr = new ProcedureRequest();
- pr.setIntent(ProcedureRequest.ProcedureRequestIntent.INSTANCEORDER);
- CodeableConcept code = new CodeableConcept();
- code.addCoding().setCode("Ancillary Orders");
- pr.getCategory().add(code);
- pr.setOccurrence(new DateTimeType("2018-10-19"));
- assertMatched(pr, criteria);
- }
- {
- ProcedureRequest pr = new ProcedureRequest();
- pr.setIntent(ProcedureRequest.ProcedureRequestIntent.INSTANCEORDER);
- CodeableConcept code = new CodeableConcept();
- code.addCoding().setCode("Hemodialysis");
- pr.getCategory().add(code);
- pr.setOccurrence(new DateTimeType("2018-10-19"));
- assertMatched(pr, criteria);
- }
- {
- ProcedureRequest pr = new ProcedureRequest();
- pr.setIntent(ProcedureRequest.ProcedureRequestIntent.INSTANCEORDER);
- pr.setOccurrence(new DateTimeType("2018-10-19"));
- assertNotMatched(pr, criteria);
- }
- {
- ProcedureRequest pr = new ProcedureRequest();
- CodeableConcept code = new CodeableConcept();
- code.addCoding().setCode("Hemodialysis");
- pr.getCategory().add(code);
- pr.setOccurrence(new DateTimeType("2018-10-19"));
- assertNotMatched(pr, criteria);
- }
- {
- ProcedureRequest pr = new ProcedureRequest();
- pr.setIntent(ProcedureRequest.ProcedureRequestIntent.INSTANCEORDER);
- CodeableConcept code = new CodeableConcept();
- code.addCoding().setCode("Hemodialysis");
- pr.getCategory().add(code);
- assertNotMatched(pr, criteria);
- }
- {
- ProcedureRequest pr = new ProcedureRequest();
- pr.setIntent(ProcedureRequest.ProcedureRequestIntent.INSTANCEORDER);
- CodeableConcept code = new CodeableConcept();
- code.addCoding().setCode("XXX");
- pr.getCategory().add(code);
- pr.setOccurrence(new DateTimeType("2018-10-19"));
- assertNotMatched(pr, criteria);
- }
- }
-
- @Test
- public void testEposideOfCare() {
- String criteria = "EpisodeOfCare?status=active";
- {
- EpisodeOfCare eoc = new EpisodeOfCare();
- eoc.setStatus(EpisodeOfCare.EpisodeOfCareStatus.ACTIVE);
- assertMatched(eoc, criteria);
- }
- {
- EpisodeOfCare eoc = new EpisodeOfCare();
- assertNotMatched(eoc, criteria);
- }
- {
- EpisodeOfCare eoc = new EpisodeOfCare();
- eoc.setStatus(EpisodeOfCare.EpisodeOfCareStatus.CANCELLED);
- assertNotMatched(eoc, criteria);
- }
- }
-
- @Test
- public void testCommunicationRequestWithRefAndDate() {
- String criteria = "CommunicationRequest?requester=O1271,O1276&occurrence=ge2019-02-08T00:00:00-05:00&occurrence=le2019-02-09T00:00:00-05:00";
- CommunicationRequest cr = new CommunicationRequest();
- cr.getRequester().getAgent().setReference("Organization/O1276");
- cr.setOccurrence(new DateTimeType("2019-02-08T00:01:00-05:00"));
- assertMatched(cr, criteria);
- }
-
-
- @Test
- public void testCommunicationRequestWithRef() {
- String criteria = "CommunicationRequest?requester=O1271,O1276";
- CommunicationRequest cr = new CommunicationRequest();
- cr.getRequester().getAgent().setReference("Organization/O1276");
- assertMatched(cr, criteria);
- }
-
- @Test
- public void testSystemWithNullValue() {
- String criteria = "Observation?code=17861-6";
- Observation observation = new Observation();
- CodeableConcept code = new CodeableConcept();
- observation.getCode().addCoding().setSystem("http://loinc.org");
-
- assertNotMatched(observation, criteria);
- }
-
- @Test
- public void testNullSystemNotNullValue() {
- String criteria = "Observation?code=17861-6";
- Observation observation = new Observation();
- CodeableConcept code = new CodeableConcept();
- observation.getCode().addCoding().setCode("look ma no system");
-
- assertNotMatched(observation, criteria);
- }
-
- @Test
- public void testExternalReferenceMatches() {
- String goodReference = "http://example.com/base/Organization/FOO";
- String goodCriteria = "Patient?organization=" + UrlUtil.escapeUrlParam(goodReference);
-
- String badReference1 = "http://example.com/bad/Organization/FOO";
- String badCriteria1 = "Patient?organization=" + UrlUtil.escapeUrlParam(badReference1);
-
- String badReference2 = "http://example.org/base/Organization/FOO";
- String badCriteria2 = "Patient?organization=" + UrlUtil.escapeUrlParam(badReference2);
-
- String badReference3 = "https://example.com/base/Organization/FOO";
- String badCriteria3 = "Patient?organization=" + UrlUtil.escapeUrlParam(badReference3);
-
- String badReference4 = "http://example.com/base/Organization/GOO";
- String badCriteria4 = "Patient?organization=" + UrlUtil.escapeUrlParam(badReference4);
-
- Set urls = new HashSet<>();
- urls.add("http://example.com/base/");
- myModelConfig.setTreatBaseUrlsAsLocal(urls);
-
- Patient patient = new Patient();
- patient.getManagingOrganization().setReference("Organization/FOO");
-
- assertMatched(patient, goodCriteria);
- assertNotMatched(patient, badCriteria1);
- assertNotMatched(patient, badCriteria2);
- assertNotMatched(patient, badCriteria3);
- assertNotMatched(patient, badCriteria4);
- }
-
- @Test
- public void testLocationPositionNotSupported() {
- Location loc = new Location();
- double latitude = 30.0;
- double longitude = 40.0;
- Location.LocationPositionComponent position = new Location.LocationPositionComponent().setLatitude(latitude).setLongitude(longitude);
- loc.setPosition(position);
- double bigEnoughDistance = 100.0;
- String badCriteria =
- "Location?" +
- Location.SP_NEAR + "=" + latitude + ":" + longitude +
- "&" +
- Location.SP_NEAR_DISTANCE + "=" + bigEnoughDistance + "|http://unitsofmeasure.org|km";
-
- assertUnsupported(loc, badCriteria);
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionStrategyEvaluatorTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionStrategyEvaluatorTest.java
deleted file mode 100644
index 1dbbc3159f7..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionStrategyEvaluatorTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.matcher;
-
-import ca.uhn.fhir.jpa.subscription.module.BaseSubscriptionDstu3Test;
-import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
-public class SubscriptionStrategyEvaluatorTest extends BaseSubscriptionDstu3Test {
- @Autowired
- SubscriptionStrategyEvaluator mySubscriptionStrategyEvaluator;
-
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
- @Test
- public void testInMemory() {
- assertInMemory("Observation?");
- assertInMemory("QuestionnaireResponse?questionnaire=HomeAbsenceHospitalizationRecord,ARIncenterAbsRecord");
- assertInMemory("CommunicationRequest?occurrence==2018-10-17");
- assertInMemory("ProcedureRequest?intent=original-order");
- assertInMemory("MedicationRequest?intent=instance-order&category=outpatient&date==2018-10-19");
- assertInMemory("MedicationRequest?intent=plan&category=outpatient&status=suspended,entered-in-error,cancelled,stopped");
- assertDatabase("Observation?code=FR_Org1Blood2nd,FR_Org1Blood3rd,FR_Org%201BldCult,FR_Org2Blood2nd,FR_Org2Blood3rd,FR_Org%202BldCult,FR_Org3Blood2nd,FR_Org3Blood3rd,FR_Org3BldCult,FR_Org4Blood2nd,FR_Org4Blood3rd,FR_Org4BldCult,FR_Org5Blood2nd,FR_Org5Blood3rd,FR_Org%205BldCult,FR_Org6Blood2nd,FR_Org6Blood3rd,FR_Org6BldCult,FR_Org7Blood2nd,FR_Org7Blood3rd,FR_Org7BldCult,FR_Org8Blood2nd,FR_Org8Blood3rd,FR_Org8BldCult,FR_Org9Blood2nd,FR_Org9Blood3rd,FR_Org9BldCult,FR_Bld2ndCulture,FR_Bld3rdCulture,FR_Blood%20Culture,FR_Com1Bld3rd,FR_Com1BldCult,FR_Com2Bld2nd,FR_Com2Bld3rd,FR_Com2BldCult,FR_CultureBld2nd,FR_CultureBld3rd,FR_CultureBldCul,FR_GmStainBldCul,FR_GramStain2Bld,FR_GramStain3Bld,FR_GramStNegBac&context.type=IHD");
- assertInMemory("Procedure?category=Hemodialysis");
- assertInMemory("Procedure?code=HD_Standard&status=completed&location=Lab123");
- assertInMemory("Procedure?code=HD_Standard&status=completed");
- assertInMemory("QuestionnaireResponse?questionnaire=HomeAbsenceHospitalizationRecord,ARIncenterAbsRecord,FMCSWDepressionSymptomsScreener,FMCAKIComprehensiveSW,FMCSWIntensiveScreener,FMCESRDComprehensiveSW,FMCNutritionProgressNote,FMCAKIComprehensiveRN");
- assertInMemory("EpisodeOfCare?status=active");
- assertInMemory("Observation?code=111111111&_format=xml");
- assertInMemory("Observation?code=SNOMED-CT|123&_format=xml");
-
- assertDatabase("Observation?code=17861-6&context.type=IHD");
- assertDatabase("Observation?context.type=IHD&code=17861-6");
-
- exception.expect(InvalidRequestException.class);
- exception.expectMessage(containsString("Resource type Observation does not have a parameter with name: codeee"));
- assertInMemory("Observation?codeee=SNOMED-CT|123&_format=xml");
- }
-
- private void assertDatabase(String theCriteria) {
- assertEquals(SubscriptionMatchingStrategy.DATABASE, mySubscriptionStrategyEvaluator.determineStrategy(theCriteria));
- }
-
- private void assertInMemory(String theCriteria) {
- assertEquals(SubscriptionMatchingStrategy.IN_MEMORY, mySubscriptionStrategyEvaluator.determineStrategy(theCriteria));
- }
-}
-
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
deleted file mode 100644
index 75a5c6c0fb1..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/BaseBlockingQueueSubscribableChannelDstu3Test.java
+++ /dev/null
@@ -1,215 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.standalone;
-
-import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.interceptor.api.HookParams;
-import ca.uhn.fhir.interceptor.api.IInterceptorService;
-import ca.uhn.fhir.interceptor.api.Pointcut;
-import ca.uhn.test.concurrency.IPointcutLatch;
-import ca.uhn.test.concurrency.PointcutLatch;
-import ca.uhn.fhir.jpa.subscription.module.BaseSubscriptionDstu3Test;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscriptionChannelType;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionLoader;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
-import ca.uhn.fhir.jpa.subscription.module.channel.ISubscriptionDeliveryChannelNamer;
-import ca.uhn.fhir.jpa.subscription.module.channel.SubscriptionChannelFactory;
-import ca.uhn.fhir.jpa.subscription.module.config.MockFhirClientSubscriptionProvider;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.SubscriptionMatchingSubscriberTest;
-import ca.uhn.fhir.model.primitive.IdDt;
-import ca.uhn.fhir.rest.annotation.Create;
-import ca.uhn.fhir.rest.annotation.ResourceParam;
-import ca.uhn.fhir.rest.annotation.Update;
-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.SimpleBundleProvider;
-import ca.uhn.fhir.test.utilities.JettyUtil;
-import com.google.common.collect.Lists;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jetty.servlet.ServletHolder;
-import org.hl7.fhir.dstu3.model.*;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.messaging.SubscribableChannel;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public abstract class BaseBlockingQueueSubscribableChannelDstu3Test extends BaseSubscriptionDstu3Test {
- private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionMatchingSubscriberTest.class);
- protected static ObservationListener ourObservationListener;
-
- @Autowired
- FhirContext myFhirContext;
- @Autowired
- StandaloneSubscriptionMessageHandler myStandaloneSubscriptionMessageHandler;
- @Autowired
- SubscriptionChannelFactory mySubscriptionChannelFactory;
- @Autowired
- IInterceptorService myInterceptorRegistry;
- @Autowired
- protected SubscriptionRegistry mySubscriptionRegistry;
- @Autowired
- private MockFhirClientSubscriptionProvider myMockFhirClientSubscriptionProvider;
- @Autowired
- private SubscriptionLoader mySubscriptionLoader;
- @Autowired
- private ISubscriptionDeliveryChannelNamer mySubscriptionDeliveryChannelNamer;
-
- protected String myCode = "1000000050";
-
- private static int ourListenerPort;
- private static RestfulServer ourListenerRestServer;
- private static Server ourListenerServer;
- protected static String ourListenerServerBase;
- protected static final List ourCreatedObservations = Collections.synchronizedList(Lists.newArrayList());
- protected static final List ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList());
- protected static final List ourContentTypes = Collections.synchronizedList(new ArrayList<>());
- private static SubscribableChannel ourSubscribableChannel;
- protected final PointcutLatch mySubscriptionMatchingPost = new PointcutLatch(Pointcut.SUBSCRIPTION_AFTER_PERSISTED_RESOURCE_CHECKED);
- protected final PointcutLatch mySubscriptionActivatedPost = new PointcutLatch(Pointcut.SUBSCRIPTION_AFTER_ACTIVE_SUBSCRIPTION_REGISTERED);
-
- @Before
- public void beforeReset() {
- ourCreatedObservations.clear();
- ourUpdatedObservations.clear();
- ourContentTypes.clear();
- CanonicalSubscription canonicalSubscription = new CanonicalSubscription();
- canonicalSubscription.setIdElement(new IdDt("test"));
- canonicalSubscription.setChannelType(CanonicalSubscriptionChannelType.RESTHOOK);
- mySubscriptionRegistry.unregisterAllSubscriptions();
- ourSubscribableChannel = mySubscriptionChannelFactory.newDeliveryChannel(mySubscriptionDeliveryChannelNamer.nameFromSubscription(canonicalSubscription));
- ourSubscribableChannel.subscribe(myStandaloneSubscriptionMessageHandler);
- myInterceptorRegistry.registerAnonymousInterceptor(Pointcut.SUBSCRIPTION_AFTER_PERSISTED_RESOURCE_CHECKED, mySubscriptionMatchingPost);
- myInterceptorRegistry.registerAnonymousInterceptor(Pointcut.SUBSCRIPTION_AFTER_ACTIVE_SUBSCRIPTION_REGISTERED, mySubscriptionActivatedPost);
- }
-
- @After
- public void cleanup() {
- myInterceptorRegistry.unregisterAllInterceptors();
- mySubscriptionMatchingPost.clear();
- mySubscriptionActivatedPost.clear();
- ourObservationListener.clear();
- super.clearRegistry();
- }
-
- public T sendResource(T theResource) throws InterruptedException {
- ResourceModifiedMessage msg = new ResourceModifiedMessage(myFhirContext, theResource, ResourceModifiedMessage.OperationTypeEnum.CREATE);
- ResourceModifiedJsonMessage message = new ResourceModifiedJsonMessage(msg);
- mySubscriptionMatchingPost.setExpectedCount(1);
- ourSubscribableChannel.send(message);
- mySubscriptionMatchingPost.awaitExpected();
- return theResource;
- }
-
- protected void initSubscriptionLoader(List subscriptions, String uuid) throws InterruptedException {
- myMockFhirClientSubscriptionProvider.setBundleProvider(new SimpleBundleProvider(new ArrayList<>(subscriptions), uuid));
- mySubscriptionLoader.doSyncSubscriptionsForUnitTest();
- }
-
- protected Subscription sendSubscription(String theCriteria, String thePayload, String theEndpoint) throws InterruptedException {
- Subscription subscription = makeActiveSubscription(theCriteria, thePayload, theEndpoint);
- mySubscriptionActivatedPost.setExpectedCount(1);
- Subscription retval = sendResource(subscription);
- mySubscriptionActivatedPost.awaitExpected();
- return retval;
- }
-
- protected Observation sendObservation(String code, String system) throws InterruptedException {
- Observation observation = new Observation();
- IdType id = new IdType("Observation", nextId());
- observation.setId(id);
-
- CodeableConcept codeableConcept = new CodeableConcept();
- observation.setCode(codeableConcept);
- Coding coding = codeableConcept.addCoding();
- coding.setCode(code);
- coding.setSystem(system);
-
- observation.setStatus(Observation.ObservationStatus.FINAL);
-
- return sendResource(observation);
- }
-
- @BeforeClass
- public static void startListenerServer() throws Exception {
- ourListenerRestServer = new RestfulServer(FhirContext.forDstu3());
-
- ourObservationListener = new ObservationListener();
- ourListenerRestServer.setResourceProviders(ourObservationListener);
-
- ourListenerServer = new Server(0);
-
- ServletContextHandler proxyHandler = new ServletContextHandler();
- proxyHandler.setContextPath("/");
-
- ServletHolder servletHolder = new ServletHolder();
- servletHolder.setServlet(ourListenerRestServer);
- proxyHandler.addServlet(servletHolder, "/fhir/context/*");
-
- ourListenerServer.setHandler(proxyHandler);
- JettyUtil.startServer(ourListenerServer);
- ourListenerPort = JettyUtil.getPortForStartedServer(ourListenerServer);
- ourListenerServerBase = "http://localhost:" + ourListenerPort + "/fhir/context";
- FhirContext context = ourListenerRestServer.getFhirContext();
- //Preload structure definitions so the load doesn't happen during the test (first load can be a little slow)
- context.getValidationSupport().fetchAllStructureDefinitions();
- }
-
- @AfterClass
- public static void stopListenerServer() throws Exception {
- JettyUtil.closeServer(ourListenerServer);
- }
-
- public static class ObservationListener implements IResourceProvider, IPointcutLatch {
-
- private final PointcutLatch updateLatch = new PointcutLatch("Observation Update");
-
- @Create
- public MethodOutcome create(@ResourceParam Observation theObservation, HttpServletRequest theRequest) {
- ourLog.info("Received Listener Create");
- ourContentTypes.add(theRequest.getHeader(ca.uhn.fhir.rest.api.Constants.HEADER_CONTENT_TYPE).replaceAll(";.*", ""));
- ourCreatedObservations.add(theObservation);
- return new MethodOutcome(new IdType("Observation/1"), true);
- }
-
- @Override
- public Class extends IBaseResource> getResourceType() {
- return Observation.class;
- }
-
- @Update
- public MethodOutcome update(@ResourceParam Observation theObservation, HttpServletRequest theRequest) {
- ourContentTypes.add(theRequest.getHeader(Constants.HEADER_CONTENT_TYPE).replaceAll(";.*", ""));
- ourUpdatedObservations.add(theObservation);
- updateLatch.invoke(null, new HookParams().add(Observation.class, theObservation));
- ourLog.info("Received Listener Update (now have {} updates)", ourUpdatedObservations.size());
- return new MethodOutcome(new IdType("Observation/1"), false);
- }
-
- @Override
- public void setExpectedCount(int count) {
- updateLatch.setExpectedCount(count);
- }
-
- @Override
- public List awaitExpected() throws InterruptedException {
- return updateLatch.awaitExpected();
- }
-
- @Override
- public void clear() { updateLatch.clear();}
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/SearchParamLoaderTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/SearchParamLoaderTest.java
deleted file mode 100755
index 24c58bc8e5b..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/SearchParamLoaderTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.standalone;
-
-import ca.uhn.fhir.jpa.searchparam.registry.SearchParamRegistryImpl;
-import ca.uhn.fhir.jpa.subscription.module.config.MockFhirClientSearchParamProvider;
-import ca.uhn.fhir.rest.api.server.IBundleProvider;
-import ca.uhn.fhir.rest.server.SimpleBundleProvider;
-import org.hl7.fhir.dstu3.model.Enumerations;
-import org.hl7.fhir.dstu3.model.SearchParameter;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Collections;
-
-import static org.junit.Assert.assertEquals;
-
-public class SearchParamLoaderTest extends BaseBlockingQueueSubscribableChannelDstu3Test {
- private static final int MOCK_FHIR_CLIENT_FAILURES = 3;
- @Autowired
- private MockFhirClientSearchParamProvider myMockFhirClientSearchParamProvider;
- @Autowired
- private SearchParamRegistryImpl mySearchParamRegistry;
-
- @Before
- public void setFailCount() {
- myMockFhirClientSearchParamProvider.setFailCount(MOCK_FHIR_CLIENT_FAILURES);
- }
-
- @After
- public void restoreFailCount() {
- myMockFhirClientSearchParamProvider.setFailCount(0);
- }
-
- @Test
- public void testSubscriptionLoaderFhirClientDown() {
- String criteria = "BodySite?accessType=Catheter,PD%20Catheter";
-
- SearchParameter sp = new SearchParameter();
- sp.addBase("BodySite");
- sp.setCode("accessType");
- sp.setType(Enumerations.SearchParamType.TOKEN);
- sp.setExpression("BodySite.extension('BodySite#accessType')");
- sp.setXpathUsage(SearchParameter.XPathUsageType.NORMAL);
- sp.setStatus(Enumerations.PublicationStatus.ACTIVE);
-
- IBundleProvider bundle = new SimpleBundleProvider(Collections.singletonList(sp), "uuid");
- initSearchParamRegistry(bundle);
- assertEquals(0, myMockFhirClientSearchParamProvider.getFailCount());
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/StandaloneSubscriptionMessageHandlerTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/StandaloneSubscriptionMessageHandlerTest.java
deleted file mode 100644
index 31c859d1cb9..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/StandaloneSubscriptionMessageHandlerTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.standalone;
-
-import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.jpa.subscription.module.BaseSubscriptionDstu3Test;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceModifiedJsonMessage;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.SubscriptionMatchingSubscriber;
-import org.hl7.fhir.dstu3.model.Subscription;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.mock.mockito.MockBean;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.never;
-
-public class StandaloneSubscriptionMessageHandlerTest extends BaseSubscriptionDstu3Test {
-
- @Autowired
- StandaloneSubscriptionMessageHandler myStandaloneSubscriptionMessageHandler;
- @Autowired
- FhirContext myFhirContext;
- @MockBean
- SubscriptionMatchingSubscriber mySubscriptionMatchingSubscriber;
- @MockBean
- SubscriptionRegistry mySubscriptionRegistry;
-
- @Test
- public void activeSubscriptionIsRegistered() {
- Subscription subscription = makeActiveSubscription("testCriteria", "testPayload", "testEndpoint");
- ResourceModifiedMessage message = new ResourceModifiedMessage(myFhirContext, subscription, ResourceModifiedMessage.OperationTypeEnum.CREATE);
- ResourceModifiedJsonMessage jsonMessage = new ResourceModifiedJsonMessage(message);
- myStandaloneSubscriptionMessageHandler.handleMessage(jsonMessage);
- Mockito.verify(mySubscriptionRegistry, never()).unregisterSubscription(any());
- Mockito.verify(mySubscriptionRegistry).registerSubscriptionUnlessAlreadyRegistered(any());
- Mockito.verify(mySubscriptionMatchingSubscriber).matchActiveSubscriptionsAndDeliver(any());
- }
-
- @Test
- public void requestedSubscriptionNotRegistered() {
- Subscription subscription = makeSubscriptionWithStatus("testCriteria", "testPayload", "testEndpoint", Subscription.SubscriptionStatus.REQUESTED);
- ResourceModifiedMessage message = new ResourceModifiedMessage(myFhirContext, subscription, ResourceModifiedMessage.OperationTypeEnum.CREATE);
- ResourceModifiedJsonMessage jsonMessage = new ResourceModifiedJsonMessage(message);
- myStandaloneSubscriptionMessageHandler.handleMessage(jsonMessage);
- Mockito.verify(mySubscriptionRegistry, never()).unregisterSubscription(any());
- Mockito.verify(mySubscriptionRegistry, never()).registerSubscriptionUnlessAlreadyRegistered(any());
- Mockito.verify(mySubscriptionMatchingSubscriber).matchActiveSubscriptionsAndDeliver(any());
- }
-
- @Test
- public void deleteSubscription() {
- Subscription subscription = makeSubscriptionWithStatus("testCriteria", "testPayload", "testEndpoint", Subscription.SubscriptionStatus.REQUESTED);
- ResourceModifiedMessage message = new ResourceModifiedMessage(myFhirContext, subscription, ResourceModifiedMessage.OperationTypeEnum.DELETE);
- ResourceModifiedJsonMessage jsonMessage = new ResourceModifiedJsonMessage(message);
- myStandaloneSubscriptionMessageHandler.handleMessage(jsonMessage);
- Mockito.verify(mySubscriptionRegistry).unregisterSubscription(any());
- Mockito.verify(mySubscriptionRegistry, never()).registerSubscriptionUnlessAlreadyRegistered(any());
- Mockito.verify(mySubscriptionMatchingSubscriber, never()).matchActiveSubscriptionsAndDeliver(any());
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/SubscriptionLoaderFhirClientTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/SubscriptionLoaderFhirClientTest.java
deleted file mode 100644
index 100f219de9f..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/standalone/SubscriptionLoaderFhirClientTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.standalone;
-
-import ca.uhn.fhir.rest.api.Constants;
-import org.hl7.fhir.dstu3.model.Subscription;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-public class SubscriptionLoaderFhirClientTest extends BaseBlockingQueueSubscribableChannelDstu3Test {
-
- @Test
- public void testSubscriptionLoaderFhirClient() throws InterruptedException {
- String payload = "application/fhir+json";
-
- String criteria1 = "Observation?code=SNOMED-CT|" + myCode + "&_format=xml";
- String criteria2 = "Observation?code=SNOMED-CT|" + myCode + "111&_format=xml";
-
- List subs = new ArrayList<>();
- subs.add(makeActiveSubscription(criteria1, payload, ourListenerServerBase));
- subs.add(makeActiveSubscription(criteria2, payload, ourListenerServerBase));
-
- mySubscriptionActivatedPost.setExpectedCount(2);
- initSubscriptionLoader(subs, "uuid");
- mySubscriptionActivatedPost.awaitExpected();
-
- ourObservationListener.setExpectedCount(1);
- sendObservation(myCode, "SNOMED-CT");
- ourObservationListener.awaitExpected();
-
- waitForSize(0, ourCreatedObservations);
- waitForSize(1, ourUpdatedObservations);
- assertEquals(Constants.CT_FHIR_JSON_NEW, ourContentTypes.get(0));
- }
-
- @Test
- public void testSubscriptionLoaderFhirClientSubscriptionNotActive() throws InterruptedException {
- String payload = "application/fhir+json";
-
- String criteria1 = "Observation?code=SNOMED-CT|" + myCode + "&_format=xml";
- String criteria2 = "Observation?code=SNOMED-CT|" + myCode + "111&_format=xml";
-
- List subs = new ArrayList<>();
- subs.add(makeActiveSubscription(criteria1, payload, ourListenerServerBase).setStatus(Subscription.SubscriptionStatus.REQUESTED));
- subs.add(makeActiveSubscription(criteria2, payload, ourListenerServerBase).setStatus(Subscription.SubscriptionStatus.REQUESTED));
-
- initSubscriptionLoader(subs, "uuid");
-
- sendObservation(myCode, "SNOMED-CT");
-
- waitForSize(0, ourCreatedObservations);
- waitForSize(0, ourUpdatedObservations);
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryMessageTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryMessageTest.java
index 008489a162d..73eaf13ad11 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryMessageTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/ResourceDeliveryMessageTest.java
@@ -1,5 +1,6 @@
package ca.uhn.fhir.jpa.subscription.module.subscriber;
+import ca.uhn.fhir.jpa.subscription.model.ResourceDeliveryMessage;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionCheckingSubscriberTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionCheckingSubscriberTest.java
deleted file mode 100644
index 791d28b5c39..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionCheckingSubscriberTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
-
-import ca.uhn.fhir.jpa.subscription.module.standalone.BaseBlockingQueueSubscribableChannelDstu3Test;
-import ca.uhn.fhir.rest.api.Constants;
-import org.hl7.fhir.dstu3.model.CodeableConcept;
-import org.hl7.fhir.dstu3.model.Coding;
-import org.hl7.fhir.dstu3.model.IdType;
-import org.hl7.fhir.dstu3.model.Observation;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests copied from jpa.subscription.resthook.RestHookTestDstu3Test
- */
-public class SubscriptionCheckingSubscriberTest extends BaseBlockingQueueSubscribableChannelDstu3Test {
- private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionCheckingSubscriberTest.class);
-
- @Test
- public void testRestHookSubscriptionApplicationFhirJson() throws Exception {
- String payload = "application/fhir+json";
-
- String code = "1000000050";
- String criteria1 = "Observation?code=SNOMED-CT|" + code + "&_format=xml";
- String criteria2 = "Observation?code=SNOMED-CT|" + code + "111&_format=xml";
-
- sendSubscription(criteria1, payload, ourListenerServerBase);
- sendSubscription(criteria2, payload, ourListenerServerBase);
-
- assertEquals(2, mySubscriptionRegistry.size());
-
- ourObservationListener.setExpectedCount(1);
- sendObservation(code, "SNOMED-CT");
- ourObservationListener.awaitExpected();
-
- assertEquals(1, ourContentTypes.size());
- assertEquals(Constants.CT_FHIR_JSON_NEW, ourContentTypes.get(0));
- }
-
- @Test
- public void testRestHookSubscriptionApplicationXmlJson() throws Exception {
- String payload = "application/fhir+xml";
-
- String code = "1000000050";
- String criteria1 = "Observation?code=SNOMED-CT|" + code + "&_format=xml";
- String criteria2 = "Observation?code=SNOMED-CT|" + code + "111&_format=xml";
-
- sendSubscription(criteria1, payload, ourListenerServerBase);
- sendSubscription(criteria2, payload, ourListenerServerBase);
-
- assertEquals(2, mySubscriptionRegistry.size());
-
- ourObservationListener.setExpectedCount(1);
- sendObservation(code, "SNOMED-CT");
- ourObservationListener.awaitExpected();
-
- assertEquals(1, ourContentTypes.size());
- assertEquals(Constants.CT_FHIR_XML_NEW, ourContentTypes.get(0));
- }
-
- @Test
- public void testRestHookSubscriptionWithoutPayload() throws Exception {
- String payload = "";
-
- String code = "1000000050";
- String criteria1 = "Observation?code=SNOMED-CT|" + code;
- String criteria2 = "Observation?code=SNOMED-CT|" + code + "111";
-
- sendSubscription(criteria1, payload, ourListenerServerBase);
- sendSubscription(criteria2, payload, ourListenerServerBase);
-
- assertEquals(2, mySubscriptionRegistry.size());
-
- ourObservationListener.setExpectedCount(0);
- sendObservation(code, "SNOMED-CT");
- ourObservationListener.clear();
-
- assertEquals(0, ourContentTypes.size());
- }
-
- @Test
- public void testReferenceWithDisplayOnly() throws Exception {
- String payload = "application/fhir+json";
-
- String code = "1000000050";
- String criteria1 = "Observation?code=SNOMED-CT|" + code + "&_format=xml";
- String criteria2 = "Observation?code=SNOMED-CT|" + code + "111&_format=xml";
-
- sendSubscription(criteria1, payload, ourListenerServerBase);
- sendSubscription(criteria2, payload, ourListenerServerBase);
-
- assertEquals(2, mySubscriptionRegistry.size());
-
- ourObservationListener.setExpectedCount(1);
- Observation observation = new Observation();
- IdType id = new IdType("Observation", nextId());
- observation.setId(id);
-
- // Reference has display only!
- observation.getSubject().setDisplay("Mr Jones");
-
- CodeableConcept codeableConcept = new CodeableConcept();
- observation.setCode(codeableConcept);
- Coding coding = codeableConcept.addCoding();
- coding.setCode(code);
- coding.setSystem("SNOMED-CT");
-
- observation.setStatus(Observation.ObservationStatus.FINAL);
-
- sendResource(observation);
- ourObservationListener.awaitExpected();
-
- assertEquals(1, ourContentTypes.size());
- assertEquals(Constants.CT_FHIR_JSON_NEW, ourContentTypes.get(0));
- }
-
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionMatchingSubscriberTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionMatchingSubscriberTest.java
deleted file mode 100644
index b50fab8e0c2..00000000000
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/SubscriptionMatchingSubscriberTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
-
-import ca.uhn.fhir.jpa.subscription.module.standalone.BaseBlockingQueueSubscribableChannelDstu3Test;
-import ca.uhn.fhir.rest.api.Constants;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests copied from jpa.subscription.resthook.RestHookTestDstu3Test
- */
-public class SubscriptionMatchingSubscriberTest extends BaseBlockingQueueSubscribableChannelDstu3Test {
- private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionMatchingSubscriberTest.class);
-
- @Test
- public void testRestHookSubscriptionApplicationFhirJson() throws Exception {
- String payload = "application/fhir+json";
-
- String code = "1000000050";
- String criteria1 = "Observation?code=SNOMED-CT|" + code + "&_format=xml";
- String criteria2 = "Observation?code=SNOMED-CT|" + code + "111&_format=xml";
-
- sendSubscription(criteria1, payload, ourListenerServerBase);
- sendSubscription(criteria2, payload, ourListenerServerBase);
-
- assertEquals(2, mySubscriptionRegistry.size());
-
- ourObservationListener.setExpectedCount(1);
- sendObservation(code, "SNOMED-CT");
- ourObservationListener.awaitExpected();
-
- assertEquals(1, ourContentTypes.size());
- assertEquals(Constants.CT_FHIR_JSON_NEW, ourContentTypes.get(0));
- }
-
- @Test
- public void testRestHookSubscriptionApplicationXmlJson() throws Exception {
- String payload = "application/fhir+xml";
-
- String code = "1000000050";
- String criteria1 = "Observation?code=SNOMED-CT|" + code + "&_format=xml";
- String criteria2 = "Observation?code=SNOMED-CT|" + code + "111&_format=xml";
-
- sendSubscription(criteria1, payload, ourListenerServerBase);
- sendSubscription(criteria2, payload, ourListenerServerBase);
-
- assertEquals(2, mySubscriptionRegistry.size());
-
- ourObservationListener.setExpectedCount(1);
- sendObservation(code, "SNOMED-CT");
- ourObservationListener.awaitExpected();
-
- assertEquals(1, ourContentTypes.size());
- assertEquals(Constants.CT_FHIR_XML_NEW, ourContentTypes.get(0));
- }
-
- @Test
- public void testRestHookSubscriptionWithoutPayload() throws Exception {
- String payload = "";
-
- String code = "1000000050";
- String criteria1 = "Observation?code=SNOMED-CT|" + code;
- String criteria2 = "Observation?code=SNOMED-CT|" + code + "111";
-
- sendSubscription(criteria1, payload, ourListenerServerBase);
- sendSubscription(criteria2, payload, ourListenerServerBase);
-
- assertEquals(2, mySubscriptionRegistry.size());
-
- ourObservationListener.setExpectedCount(0);
- sendObservation(code, "SNOMED-CT");
- ourObservationListener.clear();
-
- assertEquals(0, ourContentTypes.size());
- }
-}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/WebsocketConnectionValidatorTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/WebsocketConnectionValidatorTest.java
index 236fd5f8448..606d15f6cd6 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/WebsocketConnectionValidatorTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/websocket/WebsocketConnectionValidatorTest.java
@@ -1,20 +1,40 @@
package ca.uhn.fhir.jpa.subscription.module.subscriber.websocket;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscriptionChannelType;
-import ca.uhn.fhir.jpa.subscription.module.cache.ActiveSubscription;
-import ca.uhn.fhir.jpa.subscription.module.cache.SubscriptionRegistry;
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
+import ca.uhn.fhir.jpa.api.config.DaoConfig;
+import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
+import ca.uhn.fhir.jpa.model.entity.ModelConfig;
+import ca.uhn.fhir.jpa.model.sched.ISchedulerService;
+import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
+import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryResourceMatcher;
+import ca.uhn.fhir.jpa.searchparam.matcher.SearchParamMatcher;
+import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
+import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelFactory;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType;
+import ca.uhn.fhir.jpa.subscription.process.config.SubscriptionProcessorConfig;
+import ca.uhn.fhir.jpa.subscription.process.deliver.websocket.WebsocketConnectionValidator;
+import ca.uhn.fhir.jpa.subscription.process.deliver.websocket.WebsocketValidationResponse;
+import ca.uhn.fhir.jpa.subscription.process.registry.ActiveSubscription;
+import ca.uhn.fhir.jpa.subscription.process.registry.SubscriptionRegistry;
import org.hl7.fhir.r4.model.IdType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.transaction.PlatformTransactionManager;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(SpringRunner.class)
@@ -23,11 +43,24 @@ public class WebsocketConnectionValidatorTest {
public static String WEBSOCKET_SUBSCRIPTION_ID = "2";
public static String NON_EXISTENT_SUBSCRIPTION_ID = "3";
- @Configuration
- @ComponentScan("ca.uhn.fhir.jpa.subscription.module.subscriber.websocket")
- public static class SpringConfig {
- }
-
+ @MockBean
+ MatchUrlService myMatchUrlService;
+ @MockBean
+ DaoRegistry myDaoRegistry;
+ @MockBean
+ PlatformTransactionManager myPlatformTransactionManager;
+ @MockBean
+ SearchParamMatcher mySearchParamMatcher;
+ @MockBean
+ SubscriptionChannelConfig mySubscriptionChannelConfig;
+ @MockBean
+ SubscriptionChannelFactory mySubscriptionChannelFactory;
+ @MockBean
+ IInterceptorBroadcaster myInterceptorBroadcaster;
+ @MockBean
+ InMemoryResourceMatcher myInMemoryResourceMatcher;
+ @MockBean
+ ISchedulerService mySchedulerService;
@MockBean
SubscriptionRegistry mySubscriptionRegistry;
@@ -71,4 +104,29 @@ public class WebsocketConnectionValidatorTest {
response = myWebsocketConnectionValidator.validate(idType);
assertTrue(response.isValid());
}
+
+ @Configuration
+ public static class SpringConfig extends SubscriptionProcessorConfig {
+
+ @Bean
+ public DaoConfig daoConfig() {
+ return new DaoConfig();
+ }
+
+ @Bean
+ public ModelConfig modelConfig() {
+ return new ModelConfig();
+ }
+
+ @Bean
+ public FhirContext fhirContext() {
+ return FhirContext.forR4();
+ }
+
+ @Bean("hapiJpaTaskExecutor")
+ public AsyncTaskExecutor taskExecutor() {
+ return mock(AsyncTaskExecutor.class);
+ }
+
+ }
}
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseSubscriptionDeliverySubscriberTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/process/deliver/BaseSubscriptionDeliverySubscriberTest.java
similarity index 92%
rename from hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseSubscriptionDeliverySubscriberTest.java
rename to hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/process/deliver/BaseSubscriptionDeliverySubscriberTest.java
index b0e0f9930bf..6b81b9de74b 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/subscriber/BaseSubscriptionDeliverySubscriberTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/process/deliver/BaseSubscriptionDeliverySubscriberTest.java
@@ -1,11 +1,14 @@
-package ca.uhn.fhir.jpa.subscription.module.subscriber;
+package ca.uhn.fhir.jpa.subscription.process.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.module.CanonicalSubscription;
-import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
-import ca.uhn.fhir.jpa.subscription.module.cache.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.process.deliver.resthook.SubscriptionDeliveringRestHookSubscriber;
+import ca.uhn.fhir.jpa.subscription.process.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;
@@ -18,7 +21,6 @@ import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.support.GenericMessage;
diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/ActiveSubscriptionCacheTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/process/registry/ActiveSubscriptionCacheTest.java
similarity index 91%
rename from hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/ActiveSubscriptionCacheTest.java
rename to hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/process/registry/ActiveSubscriptionCacheTest.java
index 52fe9fab7c1..c165297f9d8 100644
--- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/cache/ActiveSubscriptionCacheTest.java
+++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/process/registry/ActiveSubscriptionCacheTest.java
@@ -1,6 +1,6 @@
-package ca.uhn.fhir.jpa.subscription.module.cache;
+package ca.uhn.fhir.jpa.subscription.process.registry;
-import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
+import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription;
import ca.uhn.fhir.model.primitive.IdDt;
import org.junit.Test;
@@ -8,7 +8,11 @@ import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public class ActiveSubscriptionCacheTest {
static final String ID1 = "id1";
diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java
index 4a767f35d5f..52631680497 100644
--- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java
+++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java
@@ -4,8 +4,8 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.jpa.bulk.BulkDataExportProvider;
import ca.uhn.fhir.jpa.config.WebsocketDispatcherConfig;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
-import ca.uhn.fhir.jpa.dao.DaoRegistry;
+import ca.uhn.fhir.jpa.api.config.DaoConfig;
+import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2;
@@ -18,7 +18,7 @@ import ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4;
import ca.uhn.fhir.jpa.provider.r5.JpaConformanceProviderR5;
import ca.uhn.fhir.jpa.provider.r5.JpaSystemProviderR5;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
-import ca.uhn.fhir.jpa.subscription.SubscriptionInterceptorLoader;
+import ca.uhn.fhir.jpa.subscription.submit.interceptor.SubmitInterceptorLoader;
import ca.uhn.fhir.jpa.util.ResourceProviderFactory;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.rest.api.EncodingEnum;
@@ -125,7 +125,7 @@ public class TestRestfulServer extends RestfulServer {
providers.add(myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class));
systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class);
etagSupport = ETagSupportEnum.ENABLED;
- JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class));
+ JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class), theSearchParamRegistry);
confProvider.setImplementationDescription(implDesc);
setServerConformanceProvider(confProvider);
providers.add(myAppCtx.getBean(TerminologyUploaderProvider.class));
@@ -144,7 +144,7 @@ public class TestRestfulServer extends RestfulServer {
providers.add(myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class));
systemDao = myAppCtx.getBean("mySystemDaoR4", IFhirSystemDao.class);
etagSupport = ETagSupportEnum.ENABLED;
- JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(this, systemDao, myAppCtx.getBean(DaoConfig.class));
+ JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(this, systemDao, myAppCtx.getBean(DaoConfig.class), theSearchParamRegistry);
confProvider.setImplementationDescription(implDesc);
setServerConformanceProvider(confProvider);
providers.add(myAppCtx.getBean(TerminologyUploaderProvider.class));
@@ -163,7 +163,7 @@ public class TestRestfulServer extends RestfulServer {
providers.add(myAppCtx.getBean("mySystemProviderR5", JpaSystemProviderR5.class));
systemDao = myAppCtx.getBean("mySystemDaoR5", IFhirSystemDao.class);
etagSupport = ETagSupportEnum.ENABLED;
- JpaConformanceProviderR5 confProvider = new JpaConformanceProviderR5(this, systemDao, myAppCtx.getBean(DaoConfig.class));
+ JpaConformanceProviderR5 confProvider = new JpaConformanceProviderR5(this, systemDao, myAppCtx.getBean(DaoConfig.class), theSearchParamRegistry);
confProvider.setImplementationDescription(implDesc);
setServerConformanceProvider(confProvider);
providers.add(myAppCtx.getBean(TerminologyUploaderProvider.class));
@@ -254,8 +254,8 @@ public class TestRestfulServer extends RestfulServer {
/*
* Register subscription interceptors
*/
- SubscriptionInterceptorLoader subscriptionInterceptorLoader = myAppCtx.getBean(SubscriptionInterceptorLoader.class);
- subscriptionInterceptorLoader.registerInterceptors();
+ SubmitInterceptorLoader submitInterceptorLoader = myAppCtx.getBean(SubmitInterceptorLoader.class);
+ submitInterceptorLoader.registerInterceptors();
/*
* Cascading deletes
diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java
index 72d5a121920..34c7cc8d32d 100644
--- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java
+++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java
@@ -1,7 +1,7 @@
package ca.uhn.fhirtest.config;
import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu2;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
+import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java
index d8bd05032bb..e537cb2cb33 100644
--- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java
+++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java
@@ -1,7 +1,7 @@
package ca.uhn.fhirtest.config;
import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu3;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
+import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR4Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR4Config.java
index 7ccf19daeac..30bce9f1e9b 100644
--- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR4Config.java
+++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR4Config.java
@@ -1,7 +1,7 @@
package ca.uhn.fhirtest.config;
import ca.uhn.fhir.jpa.config.BaseJavaConfigR4;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
+import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR5Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR5Config.java
index b533739fcad..e02427ac6d3 100644
--- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR5Config.java
+++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR5Config.java
@@ -1,7 +1,7 @@
package ca.uhn.fhirtest.config;
import ca.uhn.fhir.jpa.config.BaseJavaConfigR5;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
+import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/main/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfiguration.java b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/main/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfiguration.java
index 82c286be823..1902686f361 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/main/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfiguration.java
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/main/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfiguration.java
@@ -26,7 +26,7 @@ import ca.uhn.fhir.jaxrs.server.AbstractJaxRsProvider;
import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu2;
import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu3;
import ca.uhn.fhir.jpa.config.BaseJavaConfigR4;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
+import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.provider.BaseJpaProvider;
import ca.uhn.fhir.jpa.provider.BaseJpaSystemProvider;
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/test/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfigurationTest.java b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/test/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfigurationTest.java
index 848ae31620b..4dea685810a 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/test/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfigurationTest.java
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/test/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfigurationTest.java
@@ -2,7 +2,7 @@ package ca.uhn.fhir.spring.boot.autoconfigure;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
+import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.okhttp.client.OkHttpRestfulClientFactory;
import ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory;
import ca.uhn.fhir.rest.server.RestfulServer;
diff --git a/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/FhirServerConfig.java b/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/FhirServerConfig.java
index e0a78fd7b41..f2a193932e9 100644
--- a/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/FhirServerConfig.java
+++ b/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/FhirServerConfig.java
@@ -1,26 +1,13 @@
package ca.uhn.fhir.jpa.test;
-import java.util.Properties;
-
//import javax.persistence.EntityManagerFactory;
-import javax.sql.DataSource;
-import org.apache.commons.dbcp2.BasicDataSource;
-import org.apache.commons.lang3.time.DateUtils;
//import org.hibernate.jpa.HibernatePersistenceProvider;
-import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.orm.jpa.JpaTransactionManager;
-import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
+ import org.springframework.transaction.annotation.EnableTransactionManagement;
-import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu2;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
-import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptorDstu2;
-import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
-import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor;
-import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
+ import ca.uhn.fhir.jpa.api.config.DaoConfig;
@Configuration
@EnableTransactionManagement()
diff --git a/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/OverlayTestApp.java b/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/OverlayTestApp.java
index 38e511c6caf..d039fe10247 100644
--- a/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/OverlayTestApp.java
+++ b/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/OverlayTestApp.java
@@ -5,10 +5,7 @@ import java.util.List;
import java.util.Set;
import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.jpa.subscription.module.subscriber.IResourceRetriever;
-import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
-import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.servlet.ServletContextHandler;
diff --git a/hapi-fhir-testpage-overlay/src/test/resources/fhir-jpabase-spring-test-config.xml b/hapi-fhir-testpage-overlay/src/test/resources/fhir-jpabase-spring-test-config.xml
index 65e49701718..e28d7475d5e 100644
--- a/hapi-fhir-testpage-overlay/src/test/resources/fhir-jpabase-spring-test-config.xml
+++ b/hapi-fhir-testpage-overlay/src/test/resources/fhir-jpabase-spring-test-config.xml
@@ -13,7 +13,7 @@
-
+
@@ -47,4 +47,4 @@
-
\ No newline at end of file
+
diff --git a/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm b/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm
index 976ec354e00..60bf24773e0 100644
--- a/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm
+++ b/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm
@@ -7,7 +7,7 @@ import java.util.concurrent.Executors;
import javax.persistence.EntityManager;
import org.springframework.transaction.PlatformTransactionManager;
-import ca.uhn.fhir.jpa.dao.DaoConfig;
+import ca.uhn.fhir.jpa.api.config.DaoConfig;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.context.annotation.Bean;
@@ -21,6 +21,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.rest.server.IResourceProvider;
+import ca.uhn.fhir.jpa.api.dao.*;
import ca.uhn.fhir.jpa.dao.*;
import ca.uhn.fhir.jpa.util.ResourceProviderFactory;
diff --git a/pom.xml b/pom.xml
index b2c8d47459d..33c7d0c852a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2472,6 +2472,7 @@
hapi-fhir-structures-r5
hapi-fhir-validation-resources-r5
hapi-fhir-igpacks
+ hapi-fhir-jpaserver-api
hapi-fhir-jpaserver-model
hapi-fhir-jpaserver-searchparam
hapi-fhir-jpaserver-subscription