Merge remote-tracking branch 'remotes/origin/submit-retry-extension' into windows-fixes
This commit is contained in:
commit
c92cbdd3e2
|
@ -295,6 +295,8 @@ public class CanonicalSubscription implements Serializable, Cloneable {
|
||||||
private boolean myStripVersionId;
|
private boolean myStripVersionId;
|
||||||
@JsonProperty("deliverLatestVersion")
|
@JsonProperty("deliverLatestVersion")
|
||||||
private boolean myDeliverLatestVersion;
|
private boolean myDeliverLatestVersion;
|
||||||
|
@JsonProperty("maxRetries")
|
||||||
|
private int myMaxRetries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -311,6 +313,23 @@ public class CanonicalSubscription implements Serializable, Cloneable {
|
||||||
myDeliverLatestVersion = theDeliverLatestVersion;
|
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
|
@Override
|
||||||
public boolean equals(Object theO) {
|
public boolean equals(Object theO) {
|
||||||
if (this == theO) return true;
|
if (this == theO) return true;
|
||||||
|
@ -322,6 +341,7 @@ public class CanonicalSubscription implements Serializable, Cloneable {
|
||||||
return new EqualsBuilder()
|
return new EqualsBuilder()
|
||||||
.append(myStripVersionId, that.myStripVersionId)
|
.append(myStripVersionId, that.myStripVersionId)
|
||||||
.append(myDeliverLatestVersion, that.myDeliverLatestVersion)
|
.append(myDeliverLatestVersion, that.myDeliverLatestVersion)
|
||||||
|
.append(myMaxRetries, that.myMaxRetries)
|
||||||
.isEquals();
|
.isEquals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,17 +350,10 @@ public class CanonicalSubscription implements Serializable, Cloneable {
|
||||||
return new HashCodeBuilder(17, 37)
|
return new HashCodeBuilder(17, 37)
|
||||||
.append(myStripVersionId)
|
.append(myStripVersionId)
|
||||||
.append(myDeliverLatestVersion)
|
.append(myDeliverLatestVersion)
|
||||||
|
.append(myMaxRetries)
|
||||||
.toHashCode();
|
.toHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStripVersionId() {
|
|
||||||
return myStripVersionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStripVersionId(boolean theStripVersionId) {
|
|
||||||
myStripVersionId = theStripVersionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
|
|
@ -28,6 +28,7 @@ import ca.uhn.fhir.model.api.ExtensionDt;
|
||||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
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.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
@ -99,7 +100,7 @@ public class SubscriptionCanonicalizer<S extends IBaseResource> {
|
||||||
if (retVal.getChannelType() == CanonicalSubscriptionChannelType.EMAIL) {
|
if (retVal.getChannelType() == CanonicalSubscriptionChannelType.EMAIL) {
|
||||||
String from;
|
String from;
|
||||||
String subjectTemplate;
|
String subjectTemplate;
|
||||||
String bodyTemplate;
|
|
||||||
try {
|
try {
|
||||||
from = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_EMAIL_FROM);
|
from = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_EMAIL_FROM);
|
||||||
subjectTemplate = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_SUBJECT_TEMPLATE);
|
subjectTemplate = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_SUBJECT_TEMPLATE);
|
||||||
|
@ -111,16 +112,22 @@ public class SubscriptionCanonicalizer<S extends IBaseResource> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retVal.getChannelType() == CanonicalSubscriptionChannelType.RESTHOOK) {
|
if (retVal.getChannelType() == CanonicalSubscriptionChannelType.RESTHOOK) {
|
||||||
|
|
||||||
String stripVersionIds;
|
String stripVersionIds;
|
||||||
String deliverLatestVersion;
|
String deliverLatestVersion;
|
||||||
|
String maxRetries;
|
||||||
try {
|
try {
|
||||||
stripVersionIds = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_STRIP_VERSION_IDS);
|
stripVersionIds = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_STRIP_VERSION_IDS);
|
||||||
deliverLatestVersion = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_DELIVER_LATEST_VERSION);
|
deliverLatestVersion = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_DELIVER_LATEST_VERSION);
|
||||||
|
maxRetries = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_MAX_RETRIES);
|
||||||
} catch (FHIRException theE) {
|
} catch (FHIRException theE) {
|
||||||
throw new ConfigurationException("Failed to extract subscription extension(s): " + theE.getMessage(), theE);
|
throw new ConfigurationException("Failed to extract subscription extension(s): " + theE.getMessage(), theE);
|
||||||
}
|
}
|
||||||
retVal.getRestHookDetails().setStripVersionId(Boolean.parseBoolean(stripVersionIds));
|
retVal.getRestHookDetails().setStripVersionId(Boolean.parseBoolean(stripVersionIds));
|
||||||
retVal.getRestHookDetails().setDeliverLatestVersion(Boolean.parseBoolean(deliverLatestVersion));
|
retVal.getRestHookDetails().setDeliverLatestVersion(Boolean.parseBoolean(deliverLatestVersion));
|
||||||
|
if (isNotBlank(maxRetries)) {
|
||||||
|
retVal.getRestHookDetails().setMaxRetries(Integer.parseInt(maxRetries));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (FHIRException theE) {
|
} catch (FHIRException theE) {
|
||||||
|
@ -239,14 +246,20 @@ public class SubscriptionCanonicalizer<S extends IBaseResource> {
|
||||||
if (retVal.getChannelType() == CanonicalSubscriptionChannelType.RESTHOOK) {
|
if (retVal.getChannelType() == CanonicalSubscriptionChannelType.RESTHOOK) {
|
||||||
String stripVersionIds;
|
String stripVersionIds;
|
||||||
String deliverLatestVersion;
|
String deliverLatestVersion;
|
||||||
|
String maxRetries;
|
||||||
try {
|
try {
|
||||||
stripVersionIds = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_STRIP_VERSION_IDS);
|
stripVersionIds = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_STRIP_VERSION_IDS);
|
||||||
deliverLatestVersion = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_DELIVER_LATEST_VERSION);
|
deliverLatestVersion = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_RESTHOOK_DELIVER_LATEST_VERSION);
|
||||||
|
maxRetries = subscription.getChannel().getExtensionString(SubscriptionConstants.EXT_SUBSCRIPTION_MAX_RETRIES);
|
||||||
|
|
||||||
} catch (FHIRException theE) {
|
} catch (FHIRException theE) {
|
||||||
throw new ConfigurationException("Failed to extract subscription extension(s): " + theE.getMessage(), theE);
|
throw new ConfigurationException("Failed to extract subscription extension(s): " + theE.getMessage(), theE);
|
||||||
}
|
}
|
||||||
retVal.getRestHookDetails().setStripVersionId(Boolean.parseBoolean(stripVersionIds));
|
retVal.getRestHookDetails().setStripVersionId(Boolean.parseBoolean(stripVersionIds));
|
||||||
retVal.getRestHookDetails().setDeliverLatestVersion(Boolean.parseBoolean(deliverLatestVersion));
|
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");
|
List<Extension> topicExts = subscription.getExtensionsByUrl("http://hl7.org/fhir/subscription/topics");
|
||||||
|
|
|
@ -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";
|
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
|
* The number of threads used in subscription channel processing
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -101,8 +101,7 @@ public class SubscriptionDeliveringRestHookSubscriber extends BaseSubscriptionDe
|
||||||
try {
|
try {
|
||||||
operation.execute();
|
operation.execute();
|
||||||
} catch (ResourceNotFoundException e) {
|
} catch (ResourceNotFoundException e) {
|
||||||
ourLog.error("Cannot reach " + theMsg.getSubscription().getEndpointUrl());
|
ourLog.error("Cannot reach " + theMsg.getSubscription().getEndpointUrl(), e);
|
||||||
e.printStackTrace();
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue