Merge remote-tracking branch 'remotes/origin/submit-retry-extension' into windows-fixes

This commit is contained in:
Ken Stevens 2019-01-21 20:35:04 -05:00
commit c92cbdd3e2
4 changed files with 43 additions and 12 deletions

View File

@ -295,6 +295,8 @@ public class CanonicalSubscription implements Serializable, Cloneable {
private boolean myStripVersionId;
@JsonProperty("deliverLatestVersion")
private boolean myDeliverLatestVersion;
@JsonProperty("maxRetries")
private int myMaxRetries;
/**
* Constructor
@ -311,6 +313,23 @@ public class CanonicalSubscription implements Serializable, Cloneable {
myDeliverLatestVersion = theDeliverLatestVersion;
}
public boolean isStripVersionId() {
return myStripVersionId;
}
public void setStripVersionId(boolean theStripVersionId) {
myStripVersionId = theStripVersionId;
}
public int getMaxRetries() {
return myMaxRetries;
}
public void setMaxRetries(int theMaxRetries) {
myMaxRetries = theMaxRetries;
}
@Override
public boolean equals(Object theO) {
if (this == theO) return true;
@ -322,6 +341,7 @@ public class CanonicalSubscription implements Serializable, Cloneable {
return new EqualsBuilder()
.append(myStripVersionId, that.myStripVersionId)
.append(myDeliverLatestVersion, that.myDeliverLatestVersion)
.append(myMaxRetries, that.myMaxRetries)
.isEquals();
}
@ -330,17 +350,10 @@ public class CanonicalSubscription implements Serializable, Cloneable {
return new HashCodeBuilder(17, 37)
.append(myStripVersionId)
.append(myDeliverLatestVersion)
.append(myMaxRetries)
.toHashCode();
}
public boolean isStripVersionId() {
return myStripVersionId;
}
public void setStripVersionId(boolean theStripVersionId) {
myStripVersionId = theStripVersionId;
}
}
@JsonInclude(JsonInclude.Include.NON_NULL)

View File

@ -28,6 +28,7 @@ import ca.uhn.fhir.model.api.ExtensionDt;
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
import org.hl7.fhir.dstu3.model.Subscription;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBaseReference;
import org.hl7.fhir.instance.model.api.IBaseResource;
@ -96,10 +97,10 @@ public class SubscriptionCanonicalizer<S extends IBaseResource> {
retVal.setIdElement(subscription.getIdElement());
retVal.setPayloadString(subscription.getChannel().getPayload());
if (retVal.getChannelType() == CanonicalSubscriptionChannelType.EMAIL) {
if (retVal.getChannelType() == CanonicalSubscriptionChannelType.EMAIL) {
String from;
String subjectTemplate;
String bodyTemplate;
try {
from = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_EMAIL_FROM);
subjectTemplate = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_SUBJECT_TEMPLATE);
@ -111,16 +112,22 @@ public class SubscriptionCanonicalizer<S extends IBaseResource> {
}
if (retVal.getChannelType() == CanonicalSubscriptionChannelType.RESTHOOK) {
String stripVersionIds;
String deliverLatestVersion;
String maxRetries;
try {
stripVersionIds = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_STRIP_VERSION_IDS);
deliverLatestVersion = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_DELIVER_LATEST_VERSION);
maxRetries = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_MAX_RETRIES);
} catch (FHIRException theE) {
throw new ConfigurationException("Failed to extract subscription extension(s): " + theE.getMessage(), theE);
}
retVal.getRestHookDetails().setStripVersionId(Boolean.parseBoolean(stripVersionIds));
retVal.getRestHookDetails().setDeliverLatestVersion(Boolean.parseBoolean(deliverLatestVersion));
if (isNotBlank(maxRetries)) {
retVal.getRestHookDetails().setMaxRetries(Integer.parseInt(maxRetries));
}
}
} catch (FHIRException theE) {
@ -239,14 +246,20 @@ public class SubscriptionCanonicalizer<S extends IBaseResource> {
if (retVal.getChannelType() == CanonicalSubscriptionChannelType.RESTHOOK) {
String stripVersionIds;
String deliverLatestVersion;
String maxRetries;
try {
stripVersionIds = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_STRIP_VERSION_IDS);
deliverLatestVersion = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_DELIVER_LATEST_VERSION);
maxRetries = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_MAX_RETRIES);
} catch (FHIRException theE) {
throw new ConfigurationException("Failed to extract subscription extension(s): " + theE.getMessage(), theE);
}
retVal.getRestHookDetails().setStripVersionId(Boolean.parseBoolean(stripVersionIds));
retVal.getRestHookDetails().setDeliverLatestVersion(Boolean.parseBoolean(deliverLatestVersion));
if (isNotBlank(maxRetries)) {
retVal.getRestHookDetails().setMaxRetries(Integer.parseInt(maxRetries));
}
}
List<Extension> topicExts = subscription.getExtensionsByUrl("http://hl7.org/fhir/subscription/topics");

View File

@ -67,6 +67,12 @@ public class SubscriptionConstants {
*/
public static final String EXT_SUBSCRIPTION_RESTHOOK_DELIVER_LATEST_VERSION = "http://hapifhir.io/fhir/StructureDefinition/subscription-resthook-deliver-latest-version";
/**
* This extension URL indicates the maximum number of delivery retries that will be attempted before the subscription delivery is considered to have failed.
*/
public static final String EXT_SUBSCRIPTION_MAX_RETRIES = "http://hapifhir.io/fhir/StructureDefinition/subscription-max-retries";
/**
* The number of threads used in subscription channel processing
*/

View File

@ -101,8 +101,7 @@ public class SubscriptionDeliveringRestHookSubscriber extends BaseSubscriptionDe
try {
operation.execute();
} catch (ResourceNotFoundException e) {
ourLog.error("Cannot reach " + theMsg.getSubscription().getEndpointUrl());
e.printStackTrace();
ourLog.error("Cannot reach " + theMsg.getSubscription().getEndpointUrl(), e);
throw e;
}
}