diff --git a/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/AS4BPCProfileRegistarSPI.java b/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/AS4BPCProfileRegistarSPI.java index 5a27e606e..fabdab72c 100644 --- a/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/AS4BPCProfileRegistarSPI.java +++ b/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/AS4BPCProfileRegistarSPI.java @@ -16,17 +16,17 @@ */ package com.helger.phase4.profile.bpc; -import java.util.function.Supplier; - import javax.annotation.Nonnull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.helger.commons.annotation.IsSPIImplementation; import com.helger.phase4.model.pmode.IPModeIDProvider; import com.helger.phase4.profile.AS4Profile; import com.helger.phase4.profile.IAS4ProfilePModeProvider; import com.helger.phase4.profile.IAS4ProfileRegistrar; import com.helger.phase4.profile.IAS4ProfileRegistrarSPI; -import com.helger.phase4.profile.IAS4ProfileValidator; /** * Library specific implementation of {@link IAS4ProfileRegistrarSPI}. @@ -36,17 +36,25 @@ @IsSPIImplementation public final class AS4BPCProfileRegistarSPI implements IAS4ProfileRegistrarSPI { - public static final String AS4_PROFILE_ID = "bpc"; - public static final String AS4_PROFILE_NAME = "BPC"; + public static final String AS4_PROFILE_ID = "bpc-mp"; + public static final String AS4_PROFILE_NAME = "BPC Market Pilot"; public static final IPModeIDProvider PMODE_ID_PROVIDER = IPModeIDProvider.DEFAULT_DYNAMIC; + private static final Logger LOGGER = LoggerFactory.getLogger (AS4BPCProfileRegistarSPI.class); + public void registerAS4Profile (@Nonnull final IAS4ProfileRegistrar aRegistrar) { - final Supplier aProfileValidatorProvider = () -> new BPCCompatibilityValidator (); - final IAS4ProfilePModeProvider aDefaultPModeProvider = (i, r, a) -> BPCPMode.createBPCPMode (i, r, a, true); + final IAS4ProfilePModeProvider aDefaultPModeProvider = (i, r, a) -> BPCPMode.createBPCPMode (i, + r, + a, + PMODE_ID_PROVIDER, + true); + + if (LOGGER.isDebugEnabled ()) + LOGGER.debug ("Registering phase4 profile '" + AS4_PROFILE_ID + "'"); final AS4Profile aProfile = new AS4Profile (AS4_PROFILE_ID, AS4_PROFILE_NAME, - aProfileValidatorProvider, + BPCCompatibilityValidator::new, aDefaultPModeProvider, PMODE_ID_PROVIDER, false); diff --git a/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/BPCCompatibilityValidator.java b/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/BPCCompatibilityValidator.java index 88c59895e..d86c07f6e 100644 --- a/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/BPCCompatibilityValidator.java +++ b/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/BPCCompatibilityValidator.java @@ -242,11 +242,21 @@ private static void _checkIfLegIsValid (@Nonnull final ErrorList aErrorList, aErrorList.add (_createError (sFieldPrefix + "ErrorHandling.Report.ProcessErrorNotifyConsumer is missing")); } + if (aErrorHandling.isReportProcessErrorNotifyProducerDefined ()) + { + if (!aErrorHandling.isReportProcessErrorNotifyProducer ()) + aErrorList.add (_createWarn (sFieldPrefix + "ErrorHandling.Report.ProcessErrorNotifyProducer should be 'true'")); + } + else + { + aErrorList.add (_createError (sFieldPrefix + "ErrorHandling.Report.ProcessErrorNotifyProducer is missing")); + } + if (aErrorHandling.isReportDeliveryFailuresNotifyProducerDefined ()) { if (!aErrorHandling.isReportDeliveryFailuresNotifyProducer ()) - aErrorList.add (_createError (sFieldPrefix + - "ErrorHandling.Report.DeliveryFailuresNotifyProducer must be 'true'")); + aErrorList.add (_createWarn (sFieldPrefix + + "ErrorHandling.Report.DeliveryFailuresNotifyProducer should be 'true'")); } else { diff --git a/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/BPCPMode.java b/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/BPCPMode.java index 7d8be2916..3ecf5e3cb 100644 --- a/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/BPCPMode.java +++ b/phase4-profile-bpc/src/main/java/com/helger/phase4/profile/bpc/BPCPMode.java @@ -30,6 +30,7 @@ import com.helger.phase4.mgr.MetaAS4Manager; import com.helger.phase4.model.EMEP; import com.helger.phase4.model.EMEPBinding; +import com.helger.phase4.model.pmode.IPModeIDProvider; import com.helger.phase4.model.pmode.PMode; import com.helger.phase4.model.pmode.PModeParty; import com.helger.phase4.model.pmode.PModePayloadService; @@ -86,6 +87,7 @@ public static PModeLegErrorHandling generatePModeLegErrorHandling () final ETriState eReportAsResponse = ETriState.TRUE; final ETriState eReportProcessErrorNotifyConsumer = ETriState.TRUE; final ETriState eReportProcessErrorNotifyProducer = ETriState.TRUE; + // Called Report.MissingReceiptNotifyProducer in BPC final ETriState eReportDeliveryFailuresNotifyProducer = ETriState.TRUE; return new PModeLegErrorHandling (aReportSenderErrorsTo, aReportReceiverErrorsTo, @@ -112,9 +114,9 @@ public static PModeLegSecurity generatePModeLegSecurity () } @Nonnull - public static PModeLeg generatePModeLeg (@Nullable final String sResponderAddress) + public static PModeLeg generatePModeLeg (@Nullable final String sAddress) { - return new PModeLeg (generatePModeLegProtocol (sResponderAddress), + return new PModeLeg (generatePModeLegProtocol (sAddress), generatePModeLegBusinessInformation (), generatePModeLegErrorHandling (), (PModeLegReliability) null, @@ -147,11 +149,13 @@ public static PModeParty createParty (@Nonnull @Nonempty final String sPartyID, * One-Way Version of the BPC pmode uses one-way push * * @param sInitiatorID - * Initiator ID + * Initiator ID. May neither be null nor empty. * @param sResponderID - * Responder ID - * @param sResponderAddress - * Responder URL + * Responder ID. May neither be null nor empty. + * @param sAddress + * Endpoint address URL. May be null. + * @param aPModeIDProvider + * PMode ID provider. May not be null. * @param bPersist * true to persist the PMode in the PModeManager, * false to have it only in memory. @@ -160,19 +164,20 @@ public static PModeParty createParty (@Nonnull @Nonempty final String sPartyID, @Nonnull public static PMode createBPCPMode (@Nonnull @Nonempty final String sInitiatorID, @Nonnull @Nonempty final String sResponderID, - @Nullable final String sResponderAddress, + @Nullable final String sAddress, + @Nonnull final IPModeIDProvider aPModeIDProvider, final boolean bPersist) { final PModeParty aInitiator = createParty (sInitiatorID, CAS4.DEFAULT_INITIATOR_URL); final PModeParty aResponder = createParty (sResponderID, CAS4.DEFAULT_RESPONDER_URL); - final PMode aPMode = new PMode (aInitiator.getID () + "-" + aResponder.getID (), + final PMode aPMode = new PMode (aPModeIDProvider.getPModeID (sInitiatorID, sResponderID), aInitiator, aResponder, DEFAULT_AGREEMENT_ID, EMEP.ONE_WAY, EMEPBinding.PUSH, - generatePModeLeg (sResponderAddress), + generatePModeLeg (sAddress), (PModeLeg) null, (PModePayloadService) null, generatePModeReceptionAwareness ()); diff --git a/phase4-profile-bpc/src/test/java/com/helger/phase4/profile/bpc/BPCCompatibilityValidatorTest.java b/phase4-profile-bpc/src/test/java/com/helger/phase4/profile/bpc/BPCCompatibilityValidatorTest.java index bc12cc387..e256386ca 100644 --- a/phase4-profile-bpc/src/test/java/com/helger/phase4/profile/bpc/BPCCompatibilityValidatorTest.java +++ b/phase4-profile-bpc/src/test/java/com/helger/phase4/profile/bpc/BPCCompatibilityValidatorTest.java @@ -41,6 +41,7 @@ import com.helger.phase4.messaging.domain.MessageHelperMethods; import com.helger.phase4.model.EMEP; import com.helger.phase4.model.EMEPBinding; +import com.helger.phase4.model.pmode.IPModeIDProvider; import com.helger.phase4.model.pmode.PMode; import com.helger.phase4.model.pmode.leg.EPModeSendReceiptReplyPattern; import com.helger.phase4.model.pmode.leg.PModeLeg; @@ -73,7 +74,11 @@ public final class BPCCompatibilityValidatorTest public void before () { m_aErrorList = new ErrorList (); - m_aPMode = BPCPMode.createBPCPMode ("TestInitiator", "TestResponder", "http://localhost:8080", true); + m_aPMode = BPCPMode.createBPCPMode ("TestInitiator", + "TestResponder", + "http://localhost:8080", + IPModeIDProvider.DEFAULT_DYNAMIC, + true); } @Test diff --git a/phase4-profile-bpc/src/test/java/com/helger/phase4/profile/bpc/BPCPModeTest.java b/phase4-profile-bpc/src/test/java/com/helger/phase4/profile/bpc/BPCPModeTest.java index e41694f76..b6d783e0d 100644 --- a/phase4-profile-bpc/src/test/java/com/helger/phase4/profile/bpc/BPCPModeTest.java +++ b/phase4-profile-bpc/src/test/java/com/helger/phase4/profile/bpc/BPCPModeTest.java @@ -21,6 +21,7 @@ import org.junit.ClassRule; import org.junit.Test; +import com.helger.phase4.model.pmode.IPModeIDProvider; import com.helger.phase4.model.pmode.PMode; import com.helger.photon.app.mock.PhotonAppWebTestRule; @@ -32,12 +33,16 @@ public final class BPCPModeTest { @ClassRule - public static final PhotonAppWebTestRule s_aRule = new PhotonAppWebTestRule (); + public static final PhotonAppWebTestRule RULE = new PhotonAppWebTestRule (); @Test public void testBPCPMode () { - final PMode aPMode = BPCPMode.createBPCPMode ("TestInitiator", "TestResponder", "https://test.example.org", false); + final PMode aPMode = BPCPMode.createBPCPMode ("TestInitiator", + "TestResponder", + "https://test.example.org", + IPModeIDProvider.DEFAULT_DYNAMIC, + false); assertNotNull (aPMode); } } diff --git a/phase4-profile-cef/src/test/java/com/helger/phase4/profile/cef/CEFPModeTest.java b/phase4-profile-cef/src/test/java/com/helger/phase4/profile/cef/CEFPModeTest.java index c43d63f2b..0e4630083 100644 --- a/phase4-profile-cef/src/test/java/com/helger/phase4/profile/cef/CEFPModeTest.java +++ b/phase4-profile-cef/src/test/java/com/helger/phase4/profile/cef/CEFPModeTest.java @@ -16,15 +16,18 @@ */ package com.helger.phase4.profile.cef; +import static org.junit.Assert.assertNotNull; + import org.junit.ClassRule; import org.junit.Test; import com.helger.phase4.model.pmode.IPModeIDProvider; +import com.helger.phase4.model.pmode.PMode; import com.helger.photon.app.mock.PhotonAppWebTestRule; /** * Test class for class {@link CEFPMode}. - * + * * @author Philip Helger */ public final class CEFPModeTest @@ -35,12 +38,22 @@ public final class CEFPModeTest @Test public void testCEFPMode () { - CEFPMode.createCEFPMode ("TestInitiator", "TestResponder", "https://test.example.org", IPModeIDProvider.DEFAULT_DYNAMIC, false); + final PMode aPMode = CEFPMode.createCEFPMode ("TestInitiator", + "TestResponder", + "https://test.example.org", + IPModeIDProvider.DEFAULT_DYNAMIC, + false); + assertNotNull (aPMode); } @Test public void testCEFPModeTwoWay () { - CEFPMode.createCEFPModeTwoWay ("TestInitiator", "TestResponder", "https://test.example.org", IPModeIDProvider.DEFAULT_DYNAMIC, false); + final PMode aPMode = CEFPMode.createCEFPModeTwoWay ("TestInitiator", + "TestResponder", + "https://test.example.org", + IPModeIDProvider.DEFAULT_DYNAMIC, + false); + assertNotNull (aPMode); } } diff --git a/phase4-profile-peppol/src/test/java/com/helger/phase4/profile/peppol/PeppolPModeTest.java b/phase4-profile-peppol/src/test/java/com/helger/phase4/profile/peppol/PeppolPModeTest.java index 964eacd9d..ced0ddd97 100644 --- a/phase4-profile-peppol/src/test/java/com/helger/phase4/profile/peppol/PeppolPModeTest.java +++ b/phase4-profile-peppol/src/test/java/com/helger/phase4/profile/peppol/PeppolPModeTest.java @@ -16,25 +16,33 @@ */ package com.helger.phase4.profile.peppol; +import static org.junit.Assert.assertNotNull; + import org.junit.ClassRule; import org.junit.Test; import com.helger.phase4.model.pmode.IPModeIDProvider; +import com.helger.phase4.model.pmode.PMode; import com.helger.photon.app.mock.PhotonAppWebTestRule; /** * Test class for class {@link PeppolPMode} - * + * * @author Philip Helger */ public final class PeppolPModeTest { @ClassRule - public static final PhotonAppWebTestRule s_aRule = new PhotonAppWebTestRule (); + public static final PhotonAppWebTestRule RULE = new PhotonAppWebTestRule (); @Test public void testCEFPMode () { - PeppolPMode.createPeppolPMode ("TestInitiator", "TestResponder", "https://test.example.org", IPModeIDProvider.DEFAULT_DYNAMIC, false); + final PMode aPMode = PeppolPMode.createPeppolPMode ("TestInitiator", + "TestResponder", + "https://test.example.org", + IPModeIDProvider.DEFAULT_DYNAMIC, + false); + assertNotNull (aPMode); } }