Search in sources :

Example 71 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier in project phoss-smp by phax.

the class PageSecureServiceGroupMigrationOutbound method showInputForm.

@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMPParticipantMigration aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bIsFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final ISMPParticipantMigrationManager aParticipantMigrationMgr = SMPMetaManager.getParticipantMigrationMgr();
    // State is filtered below
    final ICommonsList<ISMPParticipantMigration> aExistingOutgoingMigrations = aParticipantMigrationMgr.getAllOutboundParticipantMigrations(null);
    // Get all participant identifiers for which NO new migration can be
    // initiated (because they were already migrated or migration is currently
    // in progress)
    final ICommonsSet<IParticipantIdentifier> aPIDsThatCannotBeUsed = new CommonsHashSet<>();
    aPIDsThatCannotBeUsed.addAllMapped(aExistingOutgoingMigrations, x -> x.getState().preventsNewMigration(), ISMPParticipantMigration::getParticipantIdentifier);
    // Filter out all for which it makes no sense
    final HCServiceGroupSelect aSGSelect = new HCServiceGroupSelect(new RequestField(FIELD_PARTICIPANT_ID), aDisplayLocale, x -> aPIDsThatCannotBeUsed.containsNone(y -> x.getParticipantIdentifier().hasSameContent(y)));
    if (!aSGSelect.containsAnyServiceGroup()) {
        aForm.addChild(warn("No Service Group on this SMP can currently be migrated."));
    } else {
        aForm.addChild(getUIHandler().createActionHeader("Start a Participant Migration from this SMP to another SMP"));
        aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Service Group").setCtrl(aSGSelect).setHelpText("Select the Service Group to migrate to another SMP. Each Service Group can only be migrated once from this SMP. Only Service Groups registered to the SML can be migrated.").setErrorList(aFormErrors.getListOfField(FIELD_PARTICIPANT_ID)));
    }
}
Also used : Locale(java.util.Locale) HCOL(com.helger.html.hc.html.grouping.HCOL) WebPageExecutionContext(com.helger.photon.uicore.page.WebPageExecutionContext) EDefaultIcon(com.helger.photon.uicore.icon.EDefaultIcon) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) LoggerFactory(org.slf4j.LoggerFactory) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) AbstractBootstrapWebPageActionHandlerDelete(com.helger.photon.bootstrap4.pages.handler.AbstractBootstrapWebPageActionHandlerDelete) FormErrorList(com.helger.photon.core.form.FormErrorList) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) ICommonsIterable(com.helger.commons.collection.impl.ICommonsIterable) HCServiceGroupSelect(com.helger.phoss.smp.ui.secure.hc.HCServiceGroupSelect) Nonempty(com.helger.commons.annotation.Nonempty) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) Locale(java.util.Locale) HCA(com.helger.html.hc.html.textlevel.HCA) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) CPageParam(com.helger.photon.uicore.css.CPageParam) ISMPParticipantMigrationManager(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager) SMPCommonUI(com.helger.phoss.smp.ui.SMPCommonUI) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) BootstrapTabBox(com.helger.photon.bootstrap4.nav.BootstrapTabBox) IHCCell(com.helger.html.hc.html.tabular.IHCCell) EWebPageFormAction(com.helger.photon.uicore.page.EWebPageFormAction) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) ICommonsList(com.helger.commons.collection.impl.ICommonsList) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) ICommonsSet(com.helger.commons.collection.impl.ICommonsSet) DataTables(com.helger.photon.uictrls.datatables.DataTables) HCRow(com.helger.html.hc.html.tabular.HCRow) EValidity(com.helger.commons.state.EValidity) AbstractSMPWebPageForm(com.helger.phoss.smp.ui.AbstractSMPWebPageForm) IHCNode(com.helger.html.hc.IHCNode) EParticipantMigrationState(com.helger.phoss.smp.domain.pmigration.EParticipantMigrationState) SMPKeyManager(com.helger.phoss.smp.security.SMPKeyManager) EDTColType(com.helger.photon.uictrls.datatables.column.EDTColType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) ISimpleURL(com.helger.commons.url.ISimpleURL) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapWarnBox(com.helger.photon.bootstrap4.alert.BootstrapWarnBox) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) Logger(org.slf4j.Logger) StringHelper(com.helger.commons.string.StringHelper) ISMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration) HCTable(com.helger.html.hc.html.tabular.HCTable) SMPMetaManager(com.helger.phoss.smp.domain.SMPMetaManager) RequestField(com.helger.photon.core.form.RequestField) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) SMPServerConfiguration(com.helger.phoss.smp.SMPServerConfiguration) ESortOrder(com.helger.commons.compare.ESortOrder) AbstractBootstrapWebPageActionHandlerWithQuery(com.helger.photon.bootstrap4.pages.handler.AbstractBootstrapWebPageActionHandlerWithQuery) ISMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration) HCServiceGroupSelect(com.helger.phoss.smp.ui.secure.hc.HCServiceGroupSelect) ISMPParticipantMigrationManager(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) RequestField(com.helger.photon.core.form.RequestField)

Example 72 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier in project phoss-smp by phax.

the class ISMPBusinessCardManagerFuncTest method testBusinessCard.

@Test
public void testBusinessCard() throws SMPServerException {
    final ISMPBusinessCardManager aBusinessCardMgr = SMPMetaManager.getBusinessCardMgr();
    final String sUserID = CSecurity.USER_ADMINISTRATOR_ID;
    if (SMPMetaManager.getInstance().getBackendConnectionState().isFalse()) {
        // Failed to get DB connection. E.g. MySQL down or misconfigured.
        return;
    }
    final SMPBusinessCardEntity aEntity1 = new SMPBusinessCardEntity();
    aEntity1.names().add(new SMPBusinessCardName("Test entity", null));
    aEntity1.setCountryCode("AT");
    final SMPBusinessCardEntity aEntity2 = new SMPBusinessCardEntity();
    aEntity2.names().add(new SMPBusinessCardName("Test entity2", null));
    aEntity2.setCountryCode("AT");
    aEntity2.setGeographicalInformation("Address here");
    aEntity2.identifiers().add(new SMPBusinessCardIdentifier("gln", "1234567890123"));
    aEntity2.websiteURIs().add("https://www.peppol-directory.org/fake");
    aEntity2.contacts().add(new SMPBusinessCardContact("support", "Unit test support", null, "support@peppol.eu"));
    aEntity2.setAdditionalInformation("Bla foo fasel");
    aEntity2.setRegistrationDate(PDTFactory.getCurrentLocalDate());
    final SMPBusinessCardEntity aEntity3 = new SMPBusinessCardEntity();
    aEntity3.names().add(new SMPBusinessCardName("Test entity3", null));
    aEntity3.setCountryCode("AT");
    aEntity3.setAdditionalInformation("Entity 3");
    final IParticipantIdentifier aPI1 = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:junittest1");
    final IParticipantIdentifier aPI2 = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:junittest2");
    final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPServiceGroup aSG = aSGMgr.createSMPServiceGroup(sUserID, aPI1, null, true);
    assertNotNull(aSG);
    ISMPBusinessCard aBusinessCard = null;
    try {
        final long nBCCount = aBusinessCardMgr.getSMPBusinessCardCount();
        // Create new one
        aBusinessCard = aBusinessCardMgr.createOrUpdateSMPBusinessCard(aPI1, new CommonsArrayList<>(aEntity1));
        assertEquals(aPI1, aBusinessCard.getParticipantIdentifier());
        assertEquals(1, aBusinessCard.getEntityCount());
        assertEquals(nBCCount + 1, aBusinessCardMgr.getSMPBusinessCardCount());
        assertEquals(aBusinessCard, aBusinessCardMgr.getSMPBusinessCardOfServiceGroup(aSG));
        assertEquals(aBusinessCard, aBusinessCardMgr.getSMPBusinessCardOfID(aSG.getParticipantIdentifier()));
        // Update existing
        aBusinessCard = aBusinessCardMgr.createOrUpdateSMPBusinessCard(aPI1, new CommonsArrayList<>(aEntity1, aEntity2));
        assertEquals(aPI1, aBusinessCard.getParticipantIdentifier());
        assertEquals(2, aBusinessCard.getEntityCount());
        // Must not have changed
        assertEquals(nBCCount + 1, aBusinessCardMgr.getSMPBusinessCardCount());
        assertEquals(aBusinessCard, aBusinessCardMgr.getSMPBusinessCardOfServiceGroup(aSG));
        assertEquals(aBusinessCard, aBusinessCardMgr.getSMPBusinessCardOfID(aSG.getParticipantIdentifier()));
        // Add second one
        final ISMPServiceGroup aSG2 = aSGMgr.createSMPServiceGroup(sUserID, aPI2, null, true);
        assertNotNull(aSG2);
        ISMPBusinessCard aBusinessCard2 = null;
        try {
            aBusinessCard2 = aBusinessCardMgr.createOrUpdateSMPBusinessCard(aPI2, new CommonsArrayList<>(aEntity3));
            assertEquals(aPI2, aBusinessCard2.getParticipantIdentifier());
            assertEquals(1, aBusinessCard2.getEntityCount());
            assertEquals(nBCCount + 2, aBusinessCardMgr.getSMPBusinessCardCount());
            assertEquals(aBusinessCard2, aBusinessCardMgr.getSMPBusinessCardOfServiceGroup(aSG2));
            assertEquals(aBusinessCard2, aBusinessCardMgr.getSMPBusinessCardOfID(aSG2.getParticipantIdentifier()));
            // Cleanup
            assertTrue(aBusinessCardMgr.deleteSMPBusinessCard(aBusinessCard2).isChanged());
            assertEquals(nBCCount + 1, aBusinessCardMgr.getSMPBusinessCardCount());
            assertTrue(aBusinessCardMgr.deleteSMPBusinessCard(aBusinessCard).isChanged());
            assertEquals(nBCCount + 0, aBusinessCardMgr.getSMPBusinessCardCount());
            assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI2, true).isChanged());
            assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI1, true).isChanged());
        } finally {
            // Real cleanup
            aBusinessCardMgr.deleteSMPBusinessCard(aBusinessCard2);
            aSGMgr.deleteSMPServiceGroupNoEx(aPI2, true);
        }
    } finally {
        // Real cleanup
        aBusinessCardMgr.deleteSMPBusinessCard(aBusinessCard);
        aSGMgr.deleteSMPServiceGroupNoEx(aPI1, true);
    }
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 73 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier in project phoss-smp by phax.

the class ISMPRedirectManagerFuncTest method testRedirect.

@Test
public void testRedirect() throws SMPServerException {
    final String sUserID = CSecurity.USER_ADMINISTRATOR_ID;
    if (SMPMetaManager.getInstance().getBackendConnectionState().isFalse()) {
        // Failed to get DB connection. E.g. MySQL down or misconfigured.
        return;
    }
    final IParticipantIdentifier aPI1 = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:junittest1");
    final IParticipantIdentifier aPI2 = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:junittest2");
    final IDocumentTypeIdentifier aDocTypeID = PeppolIdentifierFactory.INSTANCE.createDocumentTypeIdentifierWithDefaultScheme("junit::testdoc#ext:1.0");
    final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPServiceGroup aSG = aSGMgr.createSMPServiceGroup(sUserID, aPI1, null, true);
    assertNotNull(aSG);
    try {
        final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
        // Create new one
        ISMPRedirect aRedirect = aRedirectMgr.createOrUpdateSMPRedirect(aSG, aDocTypeID, "target", "suid", null, "<extredirect />");
        assertNotNull(aRedirect);
        assertSame(aSG, aRedirect.getServiceGroup());
        assertTrue(aDocTypeID.hasSameContent(aRedirect.getDocumentTypeIdentifier()));
        assertEquals("target", aRedirect.getTargetHref());
        assertEquals("suid", aRedirect.getSubjectUniqueIdentifier());
        assertEquals("<extredirect />", aRedirect.getFirstExtensionXML().trim());
        final long nCount = aRedirectMgr.getSMPRedirectCount();
        // Update existing
        aRedirect = aRedirectMgr.createOrUpdateSMPRedirect(aSG, aDocTypeID, "target2", "suid2", null, "<extredirect2 />");
        assertNotNull(aRedirect);
        assertSame(aSG, aRedirect.getServiceGroup());
        assertTrue(aDocTypeID.hasSameContent(aRedirect.getDocumentTypeIdentifier()));
        assertEquals("target2", aRedirect.getTargetHref());
        assertEquals("suid2", aRedirect.getSubjectUniqueIdentifier());
        assertEquals("<extredirect2 />", aRedirect.getFirstExtensionXML().trim());
        assertEquals(nCount, aRedirectMgr.getSMPRedirectCount());
        // Add second one
        final ISMPServiceGroup aSG2 = aSGMgr.createSMPServiceGroup(sUserID, aPI2, null, true);
        assertNotNull(aSG2);
        try {
            aRedirect = aRedirectMgr.createOrUpdateSMPRedirect(aSG2, aDocTypeID, "target2", "suid2", null, "<extredirect2 />");
            assertNotNull(aRedirect);
            assertSame(aSG2, aRedirect.getServiceGroup());
            assertTrue(aDocTypeID.hasSameContent(aRedirect.getDocumentTypeIdentifier()));
            assertEquals("target2", aRedirect.getTargetHref());
            assertEquals("suid2", aRedirect.getSubjectUniqueIdentifier());
            assertEquals("<extredirect2 />", aRedirect.getFirstExtensionXML().trim());
            assertEquals(nCount + 1, aRedirectMgr.getSMPRedirectCount());
            // Cleanup
            assertTrue(aRedirectMgr.deleteAllSMPRedirectsOfServiceGroup(aSG2).isChanged());
            assertEquals(nCount, aRedirectMgr.getSMPRedirectCount());
            assertTrue(aRedirectMgr.deleteAllSMPRedirectsOfServiceGroup(aSG).isChanged());
            assertEquals(nCount - 1, aRedirectMgr.getSMPRedirectCount());
            assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI2, true).isChanged());
            assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI1, true).isChanged());
        } finally {
            aSGMgr.deleteSMPServiceGroupNoEx(aPI2, true);
        }
    } finally {
        aSGMgr.deleteSMPServiceGroupNoEx(aPI1, true);
    }
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 74 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier in project phoss-smp by phax.

the class ISMPServiceGroupManagerFuncTest method testBasic.

@Test
public void testBasic() throws SMPServerException {
    final IIdentifierFactory aIDFactory = SMPMetaManager.getIdentifierFactory();
    final IParticipantIdentifier aPI1 = aIDFactory.createParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "9999:junittest1");
    final IParticipantIdentifier aPI2 = aIDFactory.createParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "9999:junittest2");
    final String sSG1 = SMPServiceGroup.createSMPServiceGroupID(aPI1);
    final String sSG2 = SMPServiceGroup.createSMPServiceGroupID(aPI2);
    final String sOwner1ID = CSecurity.USER_ADMINISTRATOR_ID;
    final String sOwner2ID = CSecurity.USER_ADMINISTRATOR_ID + "2";
    final String sExtension = "<ext val=\"a\" />";
    final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
    assertNotNull(aSGMgr);
    try {
        // Check empty state
        final long nCount = aSGMgr.getSMPServiceGroupCount();
        assertEquals(nCount, aSGMgr.getAllSMPServiceGroups().size());
        assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI1));
        assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI2));
        assertNull(aSGMgr.getSMPServiceGroupOfID(aPI1));
        assertNull(aSGMgr.getSMPServiceGroupOfID(aPI2));
        assertEquals(0, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner1ID).size());
        assertEquals(0, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner2ID).size());
        assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI1, true).isUnchanged());
        assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI2, true).isUnchanged());
        assertTrue(aSGMgr.updateSMPServiceGroupNoEx(aPI1, sOwner1ID, sExtension).isUnchanged());
        assertTrue(aSGMgr.updateSMPServiceGroupNoEx(aPI2, sOwner1ID, sExtension).isUnchanged());
        assertTrue(aSGMgr.updateSMPServiceGroupNoEx(aPI1, sOwner2ID, sExtension).isUnchanged());
        assertTrue(aSGMgr.updateSMPServiceGroupNoEx(aPI2, sOwner2ID, sExtension).isUnchanged());
        // Register first and check state
        ISMPServiceGroup aSG1 = aSGMgr.createSMPServiceGroup(sOwner1ID, aPI1, sExtension, true);
        assertNotNull(aSG1);
        assertEquals(aPI1, aSG1.getParticipantIdentifier());
        assertEquals(sSG1, aSG1.getID());
        assertEquals(sOwner1ID, aSG1.getOwnerID());
        assertEquals(sExtension, aSG1.getFirstExtensionXML().trim());
        // Check manager state
        assertEquals(nCount + 1, aSGMgr.getSMPServiceGroupCount());
        assertEquals(nCount + 1, aSGMgr.getAllSMPServiceGroups().size());
        assertTrue(aSGMgr.getAllSMPServiceGroups().contains(aSG1));
        assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI1));
        assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI2));
        assertEquals(aSG1, aSGMgr.getSMPServiceGroupOfID(aPI1));
        assertNull(aSGMgr.getSMPServiceGroupOfID(aPI2));
        assertEquals(1, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner1ID).size());
        assertTrue(aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner1ID).contains(aSG1));
        assertEquals(0, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner2ID).size());
        // change owner
        assertTrue(aSGMgr.updateSMPServiceGroup(aPI1, sOwner1ID, sExtension).isUnchanged());
        assertTrue(aSGMgr.updateSMPServiceGroup(aPI1, sOwner2ID, sExtension).isChanged());
        assertEquals(0, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner1ID).size());
        assertEquals(1, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner2ID).size());
        assertTrue(aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner2ID).contains(aSG1));
        assertTrue(aSGMgr.updateSMPServiceGroupNoEx(aPI2, sOwner1ID, sExtension).isUnchanged());
        assertTrue(aSGMgr.updateSMPServiceGroupNoEx(aPI2, sOwner2ID, sExtension).isUnchanged());
        aSG1 = aSGMgr.getSMPServiceGroupOfID(aPI1);
        assertEquals(sOwner2ID, aSG1.getOwnerID());
        final ISMPServiceGroup aSG2 = aSGMgr.createSMPServiceGroup(sOwner2ID, aPI2, sExtension, true);
        assertNotNull(aSG2);
        assertEquals(aPI2, aSG2.getParticipantIdentifier());
        assertEquals(sSG2, aSG2.getID());
        assertEquals(sOwner2ID, aSG2.getOwnerID());
        assertEquals(sExtension, aSG2.getFirstExtensionXML().trim());
        // Check manager state
        assertEquals(nCount + 2, aSGMgr.getSMPServiceGroupCount());
        assertEquals(nCount + 2, aSGMgr.getAllSMPServiceGroups().size());
        assertTrue(aSGMgr.getAllSMPServiceGroups().contains(aSG1));
        assertTrue(aSGMgr.getAllSMPServiceGroups().contains(aSG2));
        assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI1));
        assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI2));
        assertEquals(aSG1, aSGMgr.getSMPServiceGroupOfID(aPI1));
        assertEquals(aSG2, aSGMgr.getSMPServiceGroupOfID(aPI2));
        assertEquals(0, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner1ID).size());
        assertEquals(2, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner2ID).size());
        assertTrue(aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner2ID).contains(aSG1));
        assertTrue(aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner2ID).contains(aSG2));
        // delete SG1
        assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI1, true).isChanged());
        assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI1, true).isUnchanged());
        // Check manager state
        assertEquals(nCount + 1, aSGMgr.getSMPServiceGroupCount());
        assertEquals(nCount + 1, aSGMgr.getAllSMPServiceGroups().size());
        assertTrue(aSGMgr.getAllSMPServiceGroups().contains(aSG2));
        assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI1));
        assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI2));
        assertNull(aSGMgr.getSMPServiceGroupOfID(aPI1));
        assertEquals(aSG2, aSGMgr.getSMPServiceGroupOfID(aPI2));
        assertEquals(0, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner1ID).size());
        assertEquals(1, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner2ID).size());
        assertTrue(aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner2ID).contains(aSG2));
        // Finally delete SG2
        assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI2, true).isChanged());
        assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI2, true).isUnchanged());
        // Check empty state
        assertEquals(nCount, aSGMgr.getSMPServiceGroupCount());
        assertEquals(nCount, aSGMgr.getAllSMPServiceGroups().size());
        assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI1));
        assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI2));
        assertNull(aSGMgr.getSMPServiceGroupOfID(aPI1));
        assertNull(aSGMgr.getSMPServiceGroupOfID(aPI2));
        assertEquals(0, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner1ID).size());
        assertEquals(0, aSGMgr.getAllSMPServiceGroupsOfOwner(sOwner2ID).size());
        assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI1, true).isUnchanged());
        assertTrue(aSGMgr.deleteSMPServiceGroupNoEx(aPI2, true).isUnchanged());
        assertTrue(aSGMgr.updateSMPServiceGroupNoEx(aPI1, sOwner1ID, sExtension).isUnchanged());
        assertTrue(aSGMgr.updateSMPServiceGroupNoEx(aPI2, sOwner1ID, sExtension).isUnchanged());
        assertTrue(aSGMgr.updateSMPServiceGroupNoEx(aPI1, sOwner2ID, sExtension).isUnchanged());
        assertTrue(aSGMgr.updateSMPServiceGroupNoEx(aPI2, sOwner2ID, sExtension).isUnchanged());
    } finally {
        // Don't care about the result
        aSGMgr.deleteSMPServiceGroupNoEx(aPI1, true);
        aSGMgr.deleteSMPServiceGroupNoEx(aPI2, true);
    }
}
Also used : IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 75 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier in project phoss-smp by phax.

the class ISMPServiceInformationManagerFuncTest method testAll.

@Test
public void testAll() throws SMPServerException {
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
    final IParticipantIdentifier aPI1 = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:junittest1");
    final IDocumentTypeIdentifier aDocTypeID = PeppolIdentifierFactory.INSTANCE.createDocumentTypeIdentifierWithDefaultScheme("junit::testdoc#ext:1.0");
    final IProcessIdentifier aProcessID = PeppolIdentifierFactory.INSTANCE.createProcessIdentifierWithDefaultScheme("junit-proc");
    final String sUserID = CSecurity.USER_ADMINISTRATOR_ID;
    if (SMPMetaManager.getInstance().getBackendConnectionState().isFalse()) {
        // Failed to get DB connection. E.g. MySQL down or misconfigured.
        return;
    }
    aServiceGroupMgr.deleteSMPServiceGroupNoEx(aPI1, true);
    final ISMPServiceGroup aSG = aServiceGroupMgr.createSMPServiceGroup(sUserID, aPI1, null, true);
    assertNotNull(aSG);
    try {
        final XMLOffsetDateTime aStartDT = PDTFactory.getCurrentXMLOffsetDateTime();
        final XMLOffsetDateTime aEndDT = aStartDT.plusYears(1);
        final SMPEndpoint aEP = new SMPEndpoint("tp", "http://localhost/as2", false, "minauth", aStartDT, aEndDT, "cert", "sd", "tc", "ti", "<extep />");
        final SMPProcess aProcess = new SMPProcess(aProcessID, new CommonsArrayList<>(aEP), "<extproc/>");
        final SMPServiceInformation aServiceInformation = new SMPServiceInformation(aSG, aDocTypeID, new CommonsArrayList<>(aProcess), "<extsi/>");
        assertTrue(aServiceInfoMgr.mergeSMPServiceInformation(aServiceInformation).isSuccess());
    } finally {
        // Don't care about the result
        aServiceGroupMgr.deleteSMPServiceGroupNoEx(aPI1, true);
    }
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) XMLOffsetDateTime(com.helger.commons.datetime.XMLOffsetDateTime) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Aggregations

IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)218 Test (org.junit.Test)70 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)58 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)57 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)51 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)47 File (java.io.File)46 Nonnull (javax.annotation.Nonnull)43 ESimpleUserMessageSendResult (com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult)42 Element (org.w3c.dom.Element)41 SMPClientReadOnly (com.helger.smpclient.peppol.SMPClientReadOnly)40 AS4RawResponseConsumerWriteToFile (com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile)38 AS4IncomingDumperFileBased (com.helger.phase4.dump.AS4IncomingDumperFileBased)35 AS4OutgoingDumperFileBased (com.helger.phase4.dump.AS4OutgoingDumperFileBased)35 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)30 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)24 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)24 SMPServerException (com.helger.phoss.smp.exception.SMPServerException)24 ISMPServiceInformation (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation)19 ICommonsList (com.helger.commons.collection.impl.ICommonsList)18