From c2004ce0add9e8b4c4bcabdce3dac52650216973 Mon Sep 17 00:00:00 2001 From: Philip Helger Date: Wed, 28 Aug 2024 20:45:27 +0200 Subject: [PATCH] Renamed APIs --- .../AbstractEuCtpPullRequestBuilder.java | 1 - .../phase4/client/AS4ClientSentMessage.java | 12 ++--- .../phase4/client/AbstractAS4Client.java | 48 +++++++++---------- .../AS4RawResponseConsumerWriteToFile.java | 4 +- .../StoringServletMessageProcessorSPI.java | 3 +- .../server/servlet/DropFolderUserMessage.java | 4 +- .../ExampleReceiveMessageProcessorSPI.java | 6 +-- .../client/AS4ClientUserMessageTest.java | 2 +- 8 files changed, 38 insertions(+), 42 deletions(-) diff --git a/phase4-euctp-client/src/main/java/com/helger/phase4/euctp/AbstractEuCtpPullRequestBuilder.java b/phase4-euctp-client/src/main/java/com/helger/phase4/euctp/AbstractEuCtpPullRequestBuilder.java index 53ee34d4a..a3246dcf6 100644 --- a/phase4-euctp-client/src/main/java/com/helger/phase4/euctp/AbstractEuCtpPullRequestBuilder.java +++ b/phase4-euctp-client/src/main/java/com/helger/phase4/euctp/AbstractEuCtpPullRequestBuilder.java @@ -55,7 +55,6 @@ public AbstractEuCtpPullRequestBuilder () signingParams ().setAlgorithmC14N (ECryptoAlgorithmC14N.C14N_EXCL_OMIT_COMMENTS); // Use the BST value type "#X509PKIPathv1" signingParams ().setUseSingleCertificate (false); - } catch (final Exception ex) { diff --git a/phase4-lib/src/main/java/com/helger/phase4/client/AS4ClientSentMessage.java b/phase4-lib/src/main/java/com/helger/phase4/client/AS4ClientSentMessage.java index d7701849c..5f2167675 100644 --- a/phase4-lib/src/main/java/com/helger/phase4/client/AS4ClientSentMessage.java +++ b/phase4-lib/src/main/java/com/helger/phase4/client/AS4ClientSentMessage.java @@ -20,7 +20,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; +import javax.annotation.concurrent.NotThreadSafe; import org.apache.hc.core5.http.message.StatusLine; @@ -39,12 +39,12 @@ * @param * The response type */ -@Immutable +@NotThreadSafe public class AS4ClientSentMessage { private final AS4ClientBuiltMessage m_aBuiltMsg; private final StatusLine m_aResponseStatusLine; - private HttpHeaderMap m_aResponseHeaders; + private final HttpHeaderMap m_aResponseHeaders; private final T m_aResponseContent; private final OffsetDateTime m_aSentDateTime; @@ -159,7 +159,7 @@ public final HttpHeaderMap getResponseHeaders () * @return The response payload. May be null. */ @Nullable - public final T getResponse () + public final T getResponseContent () { return m_aResponseContent; } @@ -168,7 +168,7 @@ public final T getResponse () * @return true if a response payload is present, * false if not. */ - public final boolean hasResponse () + public final boolean hasResponseContent () { return m_aResponseContent != null; } @@ -189,7 +189,7 @@ public String toString () return new ToStringGenerator (this).append ("BuiltMsg", m_aBuiltMsg) .append ("ResponseStatusLine", m_aResponseStatusLine) .append ("ResponseHeaders", m_aResponseHeaders) - .append ("Response", m_aResponseContent) + .append ("ResponseContent", m_aResponseContent) .append ("SentDateTime", m_aSentDateTime) .getToString (); } diff --git a/phase4-lib/src/main/java/com/helger/phase4/client/AbstractAS4Client.java b/phase4-lib/src/main/java/com/helger/phase4/client/AbstractAS4Client.java index 086547783..b56bbdc86 100644 --- a/phase4-lib/src/main/java/com/helger/phase4/client/AbstractAS4Client.java +++ b/phase4-lib/src/main/java/com/helger/phase4/client/AbstractAS4Client.java @@ -140,30 +140,6 @@ public final IAS4CryptoFactory getAS4CryptoFactorySign () return m_aCryptoFactorySign; } - /** - * @return The currently set crypto factory for crypting. null by - * default. - * @since 2.2.0 - */ - @Nullable - public final IAS4CryptoFactory getAS4CryptoFactoryCrypt () - { - return m_aCryptoFactoryCrypt; - } - - /** - * Set all the crypto properties at once. - * - * @param aCryptoFactory - * The crypto factory to be used. May be null. - * @return this for chaining - */ - @Nonnull - public final IMPLTYPE setAS4CryptoFactory (@Nullable final IAS4CryptoFactory aCryptoFactory) - { - return setAS4CryptoFactorySign (aCryptoFactory).setAS4CryptoFactoryCrypt (aCryptoFactory); - } - /** * Set the crypto factory to be used for signing. * @@ -180,6 +156,17 @@ public final IMPLTYPE setAS4CryptoFactorySign (@Nullable final IAS4CryptoFactory return thisAsT (); } + /** + * @return The currently set crypto factory for crypting. null by + * default. + * @since 2.2.0 + */ + @Nullable + public final IAS4CryptoFactory getAS4CryptoFactoryCrypt () + { + return m_aCryptoFactoryCrypt; + } + /** * Set the crypto factory to be used for crypting. * @@ -196,6 +183,19 @@ public final IMPLTYPE setAS4CryptoFactoryCrypt (@Nullable final IAS4CryptoFactor return thisAsT (); } + /** + * Set all the crypto properties at once. + * + * @param aCryptoFactory + * The crypto factory to be used. May be null. + * @return this for chaining + */ + @Nonnull + public final IMPLTYPE setAS4CryptoFactory (@Nullable final IAS4CryptoFactory aCryptoFactory) + { + return setAS4CryptoFactorySign (aCryptoFactory).setAS4CryptoFactoryCrypt (aCryptoFactory); + } + /** * @return The signing algorithm to use. Never null. * @since 0.9.0 diff --git a/phase4-lib/src/main/java/com/helger/phase4/dump/AS4RawResponseConsumerWriteToFile.java b/phase4-lib/src/main/java/com/helger/phase4/dump/AS4RawResponseConsumerWriteToFile.java index f79808a4a..dd6915c2c 100644 --- a/phase4-lib/src/main/java/com/helger/phase4/dump/AS4RawResponseConsumerWriteToFile.java +++ b/phase4-lib/src/main/java/com/helger/phase4/dump/AS4RawResponseConsumerWriteToFile.java @@ -158,7 +158,7 @@ public void handleResponse (@Nonnull final AS4ClientSentMessage aRespo { final boolean bUseStatusLine = isHandleStatusLine () && aResponseEntity.hasResponseStatusLine (); final boolean bUseHttpHeaders = isHandleHttpHeaders () && aResponseEntity.getResponseHeaders ().isNotEmpty (); - final boolean bUseBody = aResponseEntity.hasResponse () && aResponseEntity.getResponse ().length > 0; + final boolean bUseBody = aResponseEntity.hasResponseContent () && aResponseEntity.getResponseContent ().length > 0; if (bUseStatusLine || bUseHttpHeaders || bUseBody) { @@ -208,7 +208,7 @@ public void handleResponse (@Nonnull final AS4ClientSentMessage aRespo if (bUseBody) { // Write the main content - aOS.write (aResponseEntity.getResponse ()); + aOS.write (aResponseEntity.getResponseContent ()); } } else diff --git a/phase4-peppol-server-webapp/src/main/java/com/helger/phase4/peppol/server/spi/StoringServletMessageProcessorSPI.java b/phase4-peppol-server-webapp/src/main/java/com/helger/phase4/peppol/server/spi/StoringServletMessageProcessorSPI.java index c2b670c8b..d5d6ed2ea 100644 --- a/phase4-peppol-server-webapp/src/main/java/com/helger/phase4/peppol/server/spi/StoringServletMessageProcessorSPI.java +++ b/phase4-peppol-server-webapp/src/main/java/com/helger/phase4/peppol/server/spi/StoringServletMessageProcessorSPI.java @@ -68,8 +68,7 @@ private static void _dumpSoap (@Nonnull final IAS4IncomingMessageMetadata aMessa { // Write formatted SOAP { - final Document aSoapDoc = aState.hasDecryptedSoapDocument () ? aState.getDecryptedSoapDocument () : aState - .getOriginalSoapDocument (); + final Document aSoapDoc = aState.getEffectiveDecryptedSoapDocument (); if (aSoapDoc == null) throw new IllegalStateException ("No SOAP Document present"); diff --git a/phase4-server-webapp/src/main/java/com/helger/phase4/server/servlet/DropFolderUserMessage.java b/phase4-server-webapp/src/main/java/com/helger/phase4/server/servlet/DropFolderUserMessage.java index e849a027a..091d55c4a 100644 --- a/phase4-server-webapp/src/main/java/com/helger/phase4/server/servlet/DropFolderUserMessage.java +++ b/phase4-server-webapp/src/main/java/com/helger/phase4/server/servlet/DropFolderUserMessage.java @@ -167,12 +167,12 @@ private static void _send (@Nonnull final IAS4CryptoFactory aCF, final Path aSen aSW.stopAndGetMillis () + " ms"); - if (aResponseEntity.hasResponse ()) + if (aResponseEntity.hasResponseContent ()) { final String sMessageID = aResponseEntity.getMessageID (); final String sFilename = FilenameHelper.getAsSecureValidASCIIFilename (sMessageID) + "-response.xml"; final File aResponseFile = aIncomingDir.resolve (sFilename).toFile (); - if (SimpleFileIO.writeFile (aResponseFile, aResponseEntity.getResponse ()).isSuccess ()) + if (SimpleFileIO.writeFile (aResponseFile, aResponseEntity.getResponseContent ()).isSuccess ()) LOGGER.info ("Response file was written to '" + aResponseFile.getAbsolutePath () + "'"); else LOGGER.error ("Error writing response file to '" + aResponseFile.getAbsolutePath () + "'"); diff --git a/phase4-server-webapp/src/main/java/com/helger/phase4/server/spi/ExampleReceiveMessageProcessorSPI.java b/phase4-server-webapp/src/main/java/com/helger/phase4/server/spi/ExampleReceiveMessageProcessorSPI.java index 522cd870c..88b4b094b 100644 --- a/phase4-server-webapp/src/main/java/com/helger/phase4/server/spi/ExampleReceiveMessageProcessorSPI.java +++ b/phase4-server-webapp/src/main/java/com/helger/phase4/server/spi/ExampleReceiveMessageProcessorSPI.java @@ -67,8 +67,7 @@ private static void _dumpSoap (@Nonnull final IAS4IncomingMessageMetadata aMessa // Write formatted SOAP { final File aFile = StorageHelper.getStorageFile (aMessageMetadata, ".soap"); - final Document aSoapDoc = aState.hasDecryptedSoapDocument () ? aState.getDecryptedSoapDocument () - : aState.getOriginalSoapDocument (); + final Document aSoapDoc = aState.getEffectiveDecryptedSoapDocument (); final byte [] aBytes = XMLWriter.getNodeAsBytes (aSoapDoc, new XMLWriterSettings ().setNamespaceContext (Ebms3NamespaceHandler.getInstance ()) .setIndent (EXMLSerializeIndent.INDENT_AND_ALIGN)); @@ -113,8 +112,7 @@ public AS4MessageProcessorResult processAS4UserMessage (@Nonnull final IAS4Incom { final File aFile = StorageHelper.getStorageFile (aMessageMetadata, "-" + nIndex + ".payload"); if (StreamHelper.copyInputStreamToOutputStream (aIncomingAttachment.getSourceStream (), - FileHelper.getOutputStream (aFile)) - .isFailure ()) + FileHelper.getOutputStream (aFile)).isFailure ()) { LOGGER.error ("Failed to write incoming attachment [" + nIndex + "] to '" + aFile.getAbsolutePath () + "'"); } diff --git a/phase4-test/src/test/java/com/helger/phase4/client/AS4ClientUserMessageTest.java b/phase4-test/src/test/java/com/helger/phase4/client/AS4ClientUserMessageTest.java index e6e85f519..bb053ac25 100644 --- a/phase4-test/src/test/java/com/helger/phase4/client/AS4ClientUserMessageTest.java +++ b/phase4-test/src/test/java/com/helger/phase4/client/AS4ClientUserMessageTest.java @@ -116,7 +116,7 @@ public IMicroDocument sendMessageAndGetMicroDocument (@Nonnull final String sURL new ResponseHandlerMicroDom (), aCallback, aOutgoingDumper, - aRetryCallback).getResponse (); + aRetryCallback).getResponseContent (); AS4HttpDebug.debug ( () -> "SEND-RESPONSE received: " + MicroWriter.getNodeAsString (ret, AS4HttpDebug.getDebugXMLWriterSettings ()));