From 962479e4845c59eaec8f301fe3fcbac043d3868e Mon Sep 17 00:00:00 2001 From: "Keith W. Boone" Date: Wed, 4 Dec 2024 10:50:26 -0500 Subject: [PATCH 1/5] Updated IDestination to add default methods for is* methods. --- .../gov/cdc/izgateway/model/IDestination.java | 56 ++++++++++++++++--- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/src/main/java/gov/cdc/izgateway/model/IDestination.java b/src/main/java/gov/cdc/izgateway/model/IDestination.java index 5442841..299d4c7 100644 --- a/src/main/java/gov/cdc/izgateway/model/IDestination.java +++ b/src/main/java/gov/cdc/izgateway/model/IDestination.java @@ -2,18 +2,36 @@ import java.util.Date; +import org.apache.commons.lang3.StringUtils; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonFormat.Shape; import gov.cdc.izgateway.common.Constants; import gov.cdc.izgateway.common.HasDestinationUri; +import io.swagger.v3.oas.annotations.media.Schema; public interface IDestination extends IEndpoint, HasDestinationUri { @SuppressWarnings("serial") static class Map extends MappableEntity {} static String ID_PATTERN = "^[-_\\p{Alnum}]+$"; + /** Version value for IIS endpoints using CDC Schema */ + public static final String IZGW_2011 = "2011"; + /** Version value for IIS endpoints using 2014 Schema (subset of HUB Schema w/o HubHeader) */ + public static final String IZGW_2014 = "2014"; + /** Version value for IIS endpoints using IZGW Hub Schema */ + public static final String IZGW_HUB = "HUB"; + /** Version value for ADS endpoints using DEX 1.0 Schema */ + public static final String IZGW_ADS_VERSION1 = "DEX1.0"; + /** Version value for ADS endpoints using DEX 2.0 Schema */ + public static final String IZGW_ADS_VERSION2 = "DEX2.0"; + /** Version value for ADS endpoints using NDLP 1.0 Schema (Azure with v1 Folder Structure) */ + public static final String IZGW_AZURE_VERSION1 = "V2022-12-31"; + /** Version value for ADS endpoints using NDLP 2.0 Schema (Azure with v2 Folder Structure) */ + public static final String IZGW_AZURE_VERSION2 = "V2022-12-31"; + String getFacilityId(); IDestinationId getId(); @@ -84,16 +102,38 @@ static class Map extends MappableEntity {} IDestination safeCopy(); - boolean is2011(); - - boolean is2014(); - - boolean isHub(); + @JsonIgnore + @Schema(description = "True if this destination supports the original CDC 2011 Protocol", hidden=true) + default boolean is2011() { + return IZGW_2011.equals(getDestVersion()); + } - boolean isDex(); + @JsonIgnore + @Schema(description = "True if this destination supports the IZ Gateway 2014 Protocol", hidden=true) + default boolean is2014() { + String destVersion = getDestVersion(); + return StringUtils.isEmpty(destVersion) || IZGW_2014.equals(destVersion); + } + + @JsonIgnore + @Schema(description = "True if this destination supports the IZ Gateway Hub Protocol", hidden=true) + default boolean isHub() { + return IZGW_HUB.equalsIgnoreCase(getDestVersion()); + } + + @JsonIgnore + @Schema(description = "True if this destination supports the CDC DEX Protocol", hidden=true) + default boolean isDex() { + String destVersion = getDestVersion(); + return IZGW_ADS_VERSION1.equals(destVersion) || IZGW_ADS_VERSION2.equals(destVersion); + } + + @JsonIgnore + @Schema(description = "True if this destination supports the Azure Blob Storage Protocol", hidden=true) + default boolean isAzure() { + return IZGW_AZURE_VERSION1.equals(getDestVersion()); + } - boolean isAzure(); - String getDestinationUri(); } \ No newline at end of file From 4ab2b588227d634defff2cba8215dc21da1378a1 Mon Sep 17 00:00:00 2001 From: "Keith W. Boone" Date: Thu, 5 Dec 2024 15:25:17 -0500 Subject: [PATCH 2/5] Reporting fault originalBody as response body on HubClientFault. --- .../java/gov/cdc/izgateway/logging/event/TransactionData.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/gov/cdc/izgateway/logging/event/TransactionData.java b/src/main/java/gov/cdc/izgateway/logging/event/TransactionData.java index c7856af..7936a1e 100644 --- a/src/main/java/gov/cdc/izgateway/logging/event/TransactionData.java +++ b/src/main/java/gov/cdc/izgateway/logging/event/TransactionData.java @@ -18,6 +18,7 @@ import gov.cdc.izgateway.logging.markers.Markers2; import gov.cdc.izgateway.soap.fault.Fault; import gov.cdc.izgateway.soap.fault.FaultSupport; +import gov.cdc.izgateway.soap.fault.HubClientFault; import gov.cdc.izgateway.soap.fault.UnexpectedExceptionFault; import gov.cdc.izgateway.soap.fault.UnsupportedOperationFault; import gov.cdc.izgateway.logging.info.SourceInfo; @@ -665,6 +666,9 @@ public void setProcessError(Exception fault) { s = f; } else if (fault instanceof Fault f) { s = f; + if (f instanceof HubClientFault hcf && hcf.getOriginalBody() instanceof String body) { + this.setResponse(body); + } } else { s = new UnexpectedExceptionFault(fault, null); } From df764feb34f3f1507016e8467b4195aaefa93ccb Mon Sep 17 00:00:00 2001 From: "Keith W. Boone" Date: Sat, 7 Dec 2024 09:08:54 -0500 Subject: [PATCH 3/5] Added generic I/O Exception case to DestinationConnectionFault. --- .../soap/fault/DestinationConnectionFault.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/gov/cdc/izgateway/soap/fault/DestinationConnectionFault.java b/src/main/java/gov/cdc/izgateway/soap/fault/DestinationConnectionFault.java index 4cfc125..e11188f 100644 --- a/src/main/java/gov/cdc/izgateway/soap/fault/DestinationConnectionFault.java +++ b/src/main/java/gov/cdc/izgateway/soap/fault/DestinationConnectionFault.java @@ -133,6 +133,14 @@ public class DestinationConnectionFault extends Fault implements HasDestinationU "There was an error establishing a trusted connection between IZ Gateway and the destination endpoint. The destination endpoint does not trust IZ Gateway. This can result from a problem with the destination's" + "acceptance of the IZ Gateway trust parameters including supported protocol versions, encryption suites or the destination certificate.", RetryStrategy.CONTACT_SUPPORT + ), + new MessageSupport( + FAULT_NAME, + "24", + "IO Error At Destination", "Error communicating from/to destination", + "There was an IO Error accessing the destination endpoint. This may indicate a problem with the networking infrastructure between" + + "IZ Gateway and the endpoint.", + RetryStrategy.NORMAL ) }; static { @@ -227,6 +235,9 @@ public static DestinationConnectionFault readError(IDestination routing, IOExcep } return new DestinationConnectionFault(11, routing, ex.getMessage(), ex); } + public static DestinationConnectionFault ioError(IDestination routing, IOException ex) { + return new DestinationConnectionFault(14, routing, ex.getMessage(), ex); + } public static DestinationConnectionFault tlsErrorAtDestination(IDestination routing, TlsFatalAlertReceived tlsErr, long elapsedTimeIIS) { return new DestinationConnectionFault(13, routing, tlsErr.getMessage(), tlsErr); From e99b5e5c0bd0097e32e491a37076f6b09d0bcbab Mon Sep 17 00:00:00 2001 From: "Keith W. Boone" Date: Sat, 7 Dec 2024 10:13:06 -0500 Subject: [PATCH 4/5] Replace cast with null check in setProcessError --- .../java/gov/cdc/izgateway/logging/event/TransactionData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gov/cdc/izgateway/logging/event/TransactionData.java b/src/main/java/gov/cdc/izgateway/logging/event/TransactionData.java index 7936a1e..cc001ee 100644 --- a/src/main/java/gov/cdc/izgateway/logging/event/TransactionData.java +++ b/src/main/java/gov/cdc/izgateway/logging/event/TransactionData.java @@ -666,8 +666,8 @@ public void setProcessError(Exception fault) { s = f; } else if (fault instanceof Fault f) { s = f; - if (f instanceof HubClientFault hcf && hcf.getOriginalBody() instanceof String body) { - this.setResponse(body); + if (f instanceof HubClientFault hcf && hcf.getOriginalBody() != null) { + this.setResponse(hcf.getOriginalBody()); } } else { s = new UnexpectedExceptionFault(fault, null); From 12ded532e317ff32c5cd0a3be56508891fa100d7 Mon Sep 17 00:00:00 2001 From: "Keith W. Boone" Date: Tue, 10 Dec 2024 11:57:40 -0500 Subject: [PATCH 5/5] Fix missing whitespace in Fault message strings. --- .../izgateway/soap/fault/DestinationConnectionFault.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/gov/cdc/izgateway/soap/fault/DestinationConnectionFault.java b/src/main/java/gov/cdc/izgateway/soap/fault/DestinationConnectionFault.java index e11188f..2eb6248 100644 --- a/src/main/java/gov/cdc/izgateway/soap/fault/DestinationConnectionFault.java +++ b/src/main/java/gov/cdc/izgateway/soap/fault/DestinationConnectionFault.java @@ -106,7 +106,7 @@ public class DestinationConnectionFault extends Fault implements HasDestinationU FAULT_NAME, "20", "Write Error", "Error writing message to the destination endpoint", - "There was an IO Error writing to the destination endpoint. This may indicate a problem with the networking infrastructure between" + "There was an IO Error writing to the destination endpoint. This may indicate a problem with the networking infrastructure between " + "IZ Gateway and the endpoint.", RetryStrategy.NORMAL ), @@ -114,7 +114,7 @@ public class DestinationConnectionFault extends Fault implements HasDestinationU FAULT_NAME, "21", "Read Error", "Error reading message from the destination endpoint", - "There was an IO Error reading from the destination endpoint. This may indicate a problem with the networking infrastructure between" + "There was an IO Error reading from the destination endpoint. This may indicate a problem with the networking infrastructure between " + "IZ Gateway and the endpoint.", RetryStrategy.NORMAL ), @@ -138,7 +138,7 @@ public class DestinationConnectionFault extends Fault implements HasDestinationU FAULT_NAME, "24", "IO Error At Destination", "Error communicating from/to destination", - "There was an IO Error accessing the destination endpoint. This may indicate a problem with the networking infrastructure between" + "There was an IO Error accessing the destination endpoint. This may indicate a problem with the networking infrastructure between " + "IZ Gateway and the endpoint.", RetryStrategy.NORMAL )