Skip to content

Commit

Permalink
Merge pull request #113 from de4a-wp5/iteration2-dev
Browse files Browse the repository at this point in the history
Iteration2 dev
  • Loading branch information
phax authored Jan 10, 2023
2 parents 6922050 + 007dddd commit a2183e6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ private static <T> T _conversionBytesWithCatching (final InputStream obj,
final DE4AMarshaller <T> 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 ());
KafkaClientWrapper.sendError (EFamilyErrorType.CONVERSION_ERROR, ex.getModule (), e.getLinkedException ().getMessage ());
ex.withMessageArg (e.getLinkedException ().getMessage ());
KafkaClientWrapper.sendError (EFamilyErrorType.CONVERSION_ERROR,
ex.getModule (),
e.getLinkedException ().getMessage ());
});

final T returnObj;
Expand All @@ -83,19 +85,19 @@ private static <T> T _conversionBytesWithCatching (final InputStream obj,
}
catch (final Exception e)
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Object received is not valid, check the structure", e);
throw baseEx.withMessageArg (e.getMessage ());
LOGGER.error ("Object received is not valid, check the structure", e);
throw ex.withMessageArg (e.getMessage ());
}
if (returnObj == null)
throw baseEx.withMessageArg (ex.getArgs ());
{
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 <byte []> iteration1LegacyIM (@Valid final InputStream request)
{
// Read the old format
Expand All @@ -119,7 +121,9 @@ private static <T> 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,
Expand Down Expand Up @@ -158,7 +162,9 @@ private static <T> 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);
Expand All @@ -174,7 +180,8 @@ private static <T> 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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<dependency>
<groupId>com.helger.phase4</groupId>
<artifactId>phase4-parent-pom</artifactId>
<version>1.4.1</version>
<version>1.4.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -179,7 +179,7 @@
<dependency>
<groupId>com.helger.dcng</groupId>
<artifactId>dcng-parent-pom</artifactId>
<version>0.2.11</version>
<version>0.2.12</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down

0 comments on commit a2183e6

Please sign in to comment.