From 215f0ea673ad27c52e9a7ffdd27e4d01301a6e0a Mon Sep 17 00:00:00 2001 From: Philip Helger Date: Wed, 28 Dec 2022 16:59:38 +0100 Subject: [PATCH 1/4] Simplified --- .../connector/api/controller/ConnectorController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/de4a-connector/src/main/java/eu/de4a/connector/api/controller/ConnectorController.java b/de4a-connector/src/main/java/eu/de4a/connector/api/controller/ConnectorController.java index 01eb8ca1..dfca22c9 100644 --- a/de4a-connector/src/main/java/eu/de4a/connector/api/controller/ConnectorController.java +++ b/de4a-connector/src/main/java/eu/de4a/connector/api/controller/ConnectorController.java @@ -69,10 +69,10 @@ private static T _conversionBytesWithCatching (final InputStream obj, final DE4AMarshaller marshaller, final ConnectorException ex) { - final ConnectorException baseEx = ex.withFamily (EFamilyErrorType.CONVERSION_ERROR).withLayer (ELayerError.INTERNAL_FAILURE); + ex.withFamily (EFamilyErrorType.CONVERSION_ERROR).withLayer (ELayerError.INTERNAL_FAILURE); marshaller.readExceptionCallbacks ().set (e -> { if (e.getLinkedException () != null) - baseEx.withMessageArg (e.getLinkedException ().getMessage ()); + ex.withMessageArg (e.getLinkedException ().getMessage ()); KafkaClientWrapper.sendError (EFamilyErrorType.CONVERSION_ERROR, ex.getModule (), e.getLinkedException ().getMessage ()); }); @@ -85,10 +85,10 @@ private static T _conversionBytesWithCatching (final InputStream obj, { if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Object received is not valid, check the structure", e); - throw baseEx.withMessageArg (e.getMessage ()); + throw ex.withMessageArg (e.getMessage ()); } if (returnObj == null) - throw baseEx.withMessageArg (ex.getArgs ()); + throw ex.withMessageArg (ex.getArgs ()); return returnObj; } From 807dd557a0a53d7c30bedf7700871f524f342b1c Mon Sep 17 00:00:00 2001 From: Philip Helger Date: Wed, 28 Dec 2022 16:59:44 +0100 Subject: [PATCH 2/4] Added comment --- .../eu/de4a/connector/api/manager/MessageExchangeManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/de4a-connector/src/main/java/eu/de4a/connector/api/manager/MessageExchangeManager.java b/de4a-connector/src/main/java/eu/de4a/connector/api/manager/MessageExchangeManager.java index 523cec49..a2f46782 100644 --- a/de4a-connector/src/main/java/eu/de4a/connector/api/manager/MessageExchangeManager.java +++ b/de4a-connector/src/main/java/eu/de4a/connector/api/manager/MessageExchangeManager.java @@ -292,6 +292,7 @@ public void processMessageExchange (@Nonnull final MessageExchangeWrapper messag if (StringHelper.hasText (sIteration1RememberID)) { // This only affects the backwards compatibility layer + // It deals with the synchronous response of sending the legacy IM request final var aOldResponseMarshaller = DE4AMarshaller.doImResponseMarshaller (IDE4ACanonicalEvidenceType.NONE); final ResponseExtractEvidenceType aOldResponse = aOldResponseMarshaller.read (response.getBody ()); final ResponseExtractMultiEvidenceType aNewResponse = LegacyAPIHelper.convertOldToNewResponse (aOldResponse, From 1c5edc671504d772471f6e6a780b91f9e45ff191 Mon Sep 17 00:00:00 2001 From: Philip Helger Date: Wed, 28 Dec 2022 17:20:05 +0100 Subject: [PATCH 3/4] Improved logging --- .../api/controller/ConnectorController.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/de4a-connector/src/main/java/eu/de4a/connector/api/controller/ConnectorController.java b/de4a-connector/src/main/java/eu/de4a/connector/api/controller/ConnectorController.java index dfca22c9..8c76c496 100644 --- a/de4a-connector/src/main/java/eu/de4a/connector/api/controller/ConnectorController.java +++ b/de4a-connector/src/main/java/eu/de4a/connector/api/controller/ConnectorController.java @@ -73,7 +73,9 @@ private static T _conversionBytesWithCatching (final InputStream obj, marshaller.readExceptionCallbacks ().set (e -> { if (e.getLinkedException () != null) ex.withMessageArg (e.getLinkedException ().getMessage ()); - KafkaClientWrapper.sendError (EFamilyErrorType.CONVERSION_ERROR, ex.getModule (), e.getLinkedException ().getMessage ()); + KafkaClientWrapper.sendError (EFamilyErrorType.CONVERSION_ERROR, + ex.getModule (), + e.getLinkedException ().getMessage ()); }); final T returnObj; @@ -83,19 +85,19 @@ private static T _conversionBytesWithCatching (final InputStream obj, } catch (final Exception e) { - if (LOGGER.isDebugEnabled ()) - LOGGER.debug ("Object received is not valid, check the structure", e); + LOGGER.error ("Object received is not valid, check the structure", e); throw ex.withMessageArg (e.getMessage ()); } if (returnObj == null) + { + LOGGER.error ("Object received is not valid but no Exception was thrown"); throw ex.withMessageArg (ex.getArgs ()); + } return returnObj; } - @PostMapping (value = "/requestTransferEvidenceIM", - produces = MediaType.APPLICATION_XML_VALUE, - consumes = MediaType.APPLICATION_XML_VALUE) + @PostMapping (value = "/requestTransferEvidenceIM", produces = MediaType.APPLICATION_XML_VALUE, consumes = MediaType.APPLICATION_XML_VALUE) public ResponseEntity iteration1LegacyIM (@Valid final InputStream request) { // Read the old format @@ -119,7 +121,9 @@ private static T _conversionBytesWithCatching (final InputStream obj, aNewRequest.getRequestEvidenceIMItemAtIndex (0).addAdditionalParameter (addParam); } - final IDocumentTypeIdentifier aNewDocTypeID = DcngConfig.getIdentifierFactory ().parseDocumentTypeIdentifier (aNewRequest.getRequestEvidenceIMItemAtIndex (0).getCanonicalEvidenceTypeId ()); + final IDocumentTypeIdentifier aNewDocTypeID = DcngConfig.getIdentifierFactory () + .parseDocumentTypeIdentifier (aNewRequest.getRequestEvidenceIMItemAtIndex (0) + .getCanonicalEvidenceTypeId ()); final AS4MessageDTO messageDTO = new AS4MessageDTO (aNewRequest.getDataEvaluator ().getAgentUrn (), aNewRequest.getDataOwner ().getAgentUrn (), aNewDocTypeID, @@ -158,7 +162,9 @@ private static T _conversionBytesWithCatching (final InputStream obj, if (aResponseDoc == null) { // Failed to wait - send error message back - final String sErrorMsg = "Failed to wait for synchronous response on legacy IM request. Timeout after " + timeout + " milliseconds."; + final String sErrorMsg = "Failed to wait for synchronous response on legacy IM request. Timeout after " + + timeout + + " milliseconds."; LOGGER.error (sErrorMsg); // Copy as much as possible from the old request aOldResponse = DE4AResponseDocumentHelper.createResponseTransferEvidence (aOldRequest); @@ -174,7 +180,8 @@ private static T _conversionBytesWithCatching (final InputStream obj, if (aNewResponse == null) { LOGGER.warn ("Response received:\n" + - XMLWriter.getNodeAsString (aResponseDoc, new XMLWriterSettings ().setIndent (EXMLSerializeIndent.INDENT_AND_ALIGN))); + XMLWriter.getNodeAsString (aResponseDoc, + new XMLWriterSettings ().setIndent (EXMLSerializeIndent.INDENT_AND_ALIGN))); throw new IllegalStateException ("Failed to interprete Response as ResponseExtractMultiEvidenceType - see log for details"); } From 007dddd6445e03ea2cbcdfce52796d2fabb9eeea Mon Sep 17 00:00:00 2001 From: Philip Helger Date: Tue, 10 Jan 2023 20:15:35 +0100 Subject: [PATCH 4/4] Prepared for release --- README.md | 2 ++ pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 44800a0b..e75c4cd2 100644 --- a/README.md +++ b/README.md @@ -270,6 +270,8 @@ Once you have deployed the `war` file, there are several **checks to ensure that # News and Noteworthy +* v0.3.4 - 2023-01-10 + * Updated to DCNG 0.2.12 fixing the value of `DcngIdentifierFactory.DOCTYPE_SCHEME_CANONICAL_EVENT_CATALOGUE` (`Type` was missing) * v0.3.3 - 2022-12-21 * Fixed an error in determining the `EMessageServiceType` if the source element used an explicit namespace prefix * v0.3.2 - 2022-12-15 diff --git a/pom.xml b/pom.xml index be706353..772667d0 100644 --- a/pom.xml +++ b/pom.xml @@ -98,7 +98,7 @@ com.helger.phase4 phase4-parent-pom - 1.4.1 + 1.4.2 pom import @@ -179,7 +179,7 @@ com.helger.dcng dcng-parent-pom - 0.2.11 + 0.2.12 pom import