Search in sources :

Example 61 with ISMPServiceGroupManager

use of com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager in project phoss-smp by phax.

the class PageSecureEndpointChangeCertificate method isValidToDisplayPage.

@Override
@Nonnull
protected IValidityIndicator isValidToDisplayPage(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    if (aServiceGroupMgr.getSMPServiceGroupCount() <= 0) {
        aNodeList.addChild(warn("No service group is present! At least one service group must be present to change certificates."));
        aNodeList.addChild(new BootstrapButton().addChild("Create new service group").setOnClick(AbstractWebPageForm.createCreateURL(aWPEC, CMenuSecure.MENU_SERVICE_GROUPS)).setIcon(EDefaultIcon.YES));
        return EValidity.INVALID;
    }
    return super.isValidToDisplayPage(aWPEC);
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) Nonnull(javax.annotation.Nonnull)

Example 62 with ISMPServiceGroupManager

use of com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager in project phoss-smp by phax.

the class PageSecureEndpointChangeURL method isValidToDisplayPage.

@Override
@Nonnull
protected IValidityIndicator isValidToDisplayPage(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    if (aServiceGroupMgr.getSMPServiceGroupCount() <= 0) {
        aNodeList.addChild(warn("No service group is present! At least one service group must be present to change endpoints."));
        aNodeList.addChild(new BootstrapButton().addChild("Create new service group").setOnClick(AbstractWebPageForm.createCreateURL(aWPEC, CMenuSecure.MENU_SERVICE_GROUPS)).setIcon(EDefaultIcon.YES));
        return EValidity.INVALID;
    }
    return super.isValidToDisplayPage(aWPEC);
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) Nonnull(javax.annotation.Nonnull)

Example 63 with ISMPServiceGroupManager

use of com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager in project phoss-smp by phax.

the class PagePublicStart method fillContent.

@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
    if (SMPWebAppConfiguration.isStartPageParticipantsNone()) {
        // New in v5.0.4
        aNodeList.addChild(info("This SMP has disabled the list of participants."));
    } else {
        final ISMPServiceGroupManager aSMPServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
        final ICommonsList<ISMPServiceGroup> aServiceGroups = aSMPServiceGroupMgr.getAllSMPServiceGroups();
        // Use dynamic or static table?
        final boolean bUseDataTables = SMPWebAppConfiguration.isStartPageDynamicTable();
        final boolean bShowExtensionDetails = SMPWebAppConfiguration.isStartPageExtensionsShow();
        AbstractHCTable<?> aFinalTable;
        if (bUseDataTables) {
            // Dynamic
            final HCTable aTable = new HCTable(new DTCol("Participant ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol(bShowExtensionDetails ? "Extension" : "Extension?").setDataSort(1, 0), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
            aFinalTable = aTable;
        } else {
            // Static
            final BootstrapTable aTable = new BootstrapTable();
            aTable.setBordered(true);
            aTable.setCondensed(true);
            aTable.setStriped(true);
            aTable.addHeaderRow().addCell("Participant ID").addCell(bShowExtensionDetails ? "Extension" : "Extension?").addCell(EPhotonCoreText.ACTIONS.getDisplayText(aDisplayLocale));
            aFinalTable = aTable;
            // Sort manually
            aServiceGroups.sort(Comparator.comparing(x -> x.getParticipantIdentifier().getURIEncoded()));
        }
        for (final ISMPServiceGroup aServiceGroup : aServiceGroups) {
            final String sDisplayName = aServiceGroup.getParticipantIdentifier().getURIEncoded();
            final HCRow aRow = aFinalTable.addBodyRow();
            aRow.addCell(sDisplayName);
            if (bShowExtensionDetails) {
                if (aServiceGroup.extensions().isNotEmpty())
                    aRow.addCell(code(HCExtHelper.nl2divList(aServiceGroup.getFirstExtensionXML())));
                else
                    aRow.addCell();
            } else {
                aRow.addCell(EPhotonCoreText.getYesOrNo(aServiceGroup.extensions().isNotEmpty(), aDisplayLocale));
            }
            final SMPRestDataProvider aDP = new SMPRestDataProvider(aRequestScope, aServiceGroup.getParticipantIdentifier().getURIEncoded());
            aRow.addCell(new HCA(new SimpleURL(aDP.getServiceGroupHref(aServiceGroup.getParticipantIdentifier()))).setTitle("Perform SMP query on " + sDisplayName).setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
        }
        if (aFinalTable.hasBodyRows()) {
            aNodeList.addChild(aFinalTable);
            if (bUseDataTables) {
                final BootstrapDataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aFinalTable);
                aNodeList.addChild(aDataTables);
            }
        } else
            aNodeList.addChild(info("This SMP does not manage any participant yet."));
    }
}
Also used : Locale(java.util.Locale) WebPageExecutionContext(com.helger.photon.uicore.page.WebPageExecutionContext) AbstractHCTable(com.helger.html.hc.html.tabular.AbstractHCTable) HCRow(com.helger.html.hc.html.tabular.HCRow) SMPRestDataProvider(com.helger.phoss.smp.rest.SMPRestDataProvider) SimpleURL(com.helger.commons.url.SimpleURL) AbstractSMPWebPage(com.helger.phoss.smp.ui.AbstractSMPWebPage) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) 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) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) HCNodeList(com.helger.html.hc.impl.HCNodeList) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCTable(com.helger.html.hc.html.tabular.HCTable) SMPMetaManager(com.helger.phoss.smp.domain.SMPMetaManager) EPhotonCoreText(com.helger.photon.core.EPhotonCoreText) ICommonsList(com.helger.commons.collection.impl.ICommonsList) EFamFamIcon(com.helger.photon.uictrls.famfam.EFamFamIcon) HCExtHelper(com.helger.html.hc.ext.HCExtHelper) ESortOrder(com.helger.commons.compare.ESortOrder) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) Comparator(java.util.Comparator) SMPWebAppConfiguration(com.helger.phoss.smp.app.SMPWebAppConfiguration) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) SMPRestDataProvider(com.helger.phoss.smp.rest.SMPRestDataProvider) SimpleURL(com.helger.commons.url.SimpleURL) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) AbstractHCTable(com.helger.html.hc.html.tabular.AbstractHCTable) HCTable(com.helger.html.hc.html.tabular.HCTable) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)

Example 64 with ISMPServiceGroupManager

use of com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager in project phoss-smp by phax.

the class PageSecureServiceGroupMigrationOutbound method isActionAllowed.

@Override
protected boolean isActionAllowed(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final EWebPageFormAction eFormAction, @Nullable final ISMPParticipantMigration aSelectedObject) {
    if (eFormAction.isEdit())
        return false;
    if (eFormAction.isCreating()) {
        final ISMPSettings aSettings = SMPMetaManager.getSettings();
        if (aSettings.getSMLInfo() == null)
            return false;
        if (!aSettings.isSMLEnabled())
            return false;
        final ISMPServiceGroupManager aServiceGroupManager = SMPMetaManager.getServiceGroupMgr();
        if (aServiceGroupManager.getSMPServiceGroupCount() <= 0)
            return false;
    }
    return super.isActionAllowed(aWPEC, eFormAction, aSelectedObject);
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings)

Example 65 with ISMPServiceGroupManager

use of com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager in project phoss-smp by phax.

the class PageSecureServiceGroupMigrationOutbound method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMPParticipantMigrationManager aParticipantMigrationMgr = SMPMetaManager.getParticipantMigrationMgr();
    final ISMPSettings aSettings = SMPMetaManager.getSettings();
    final ISMPServiceGroupManager aServiceGroupManager = SMPMetaManager.getServiceGroupMgr();
    {
        final HCOL aOL = new HCOL();
        aOL.addItem("The migration is initiated on this SMP, and the SML is informed about the upcoming migration");
        aOL.addItem("The other SMP, that is taking over the Service Group, must acknowledge the migration by providing the same migration code (created by this SMP) to the SML");
        aOL.addItem("If the migration was successful, the Service Group must be deleted from this SMP, ideally a temporary redirect to the new SMP is created. If the migration was cancelled no action is needed.");
        aNodeList.addChild(info().addChild(div("The process of migrating a Service Group to another SMP consists of multiple steps:")).addChild(aOL).addChild(div("Therefore each open Migration must either be finished (deleting the Service Group) or cancelled (no action taken)." + " If a Migration is cancelled, it can be retried later.")));
    }
    EValidity eCanStartMigration = EValidity.VALID;
    if (aSettings.getSMLInfo() == null) {
        final BootstrapWarnBox aWarn = aNodeList.addAndReturnChild(warn().addChild(div("No valid SML Configuration is selected hence no participant can be migrated.")).addChild(div(new BootstrapButton().addChild("Select SML Configuration in the Settings").setOnClick(aWPEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).setIcon(EDefaultIcon.EDIT))));
        if (aSettings.isSMLEnabled() || aSettings.isSMLRequired()) {
            aWarn.addChild(div(new BootstrapButton().addChild("Create a new SML Configuration").setOnClick(createCreateURL(aWPEC, CMenuSecure.MENU_SML_CONFIGURATION)).setIcon(EDefaultIcon.YES)));
        }
        eCanStartMigration = EValidity.INVALID;
    } else if (!aSettings.isSMLEnabled()) {
        aNodeList.addChild(warn().addChild(div("SML Connection is not enabled hence no participant can be migrated.")).addChild(div(new BootstrapButton().addChild("Enable SML in the Settings").setOnClick(aWPEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).setIcon(EDefaultIcon.EDIT))));
        eCanStartMigration = EValidity.INVALID;
    } else {
        if (aServiceGroupManager.getSMPServiceGroupCount() <= 0) {
            aNodeList.addChild(warn("No Service Group is present! At least one Service Group must be present to migrate it."));
            // Note: makes no to allow to create a new Service Group here and than
            // directly migrate it away
            eCanStartMigration = EValidity.INVALID;
        }
    }
    {
        final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
        aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
        aToolbar.addChild(new BootstrapButton().addChild("Start Participant Migration").setOnClick(createCreateURL(aWPEC)).setDisabled(eCanStartMigration.isInvalid()).setIcon(EDefaultIcon.NEW));
        aNodeList.addChild(aToolbar);
    }
    final BootstrapTabBox aTabBox = aNodeList.addAndReturnChild(new BootstrapTabBox());
    final ICommonsList<ISMPParticipantMigration> aAllMigs = aParticipantMigrationMgr.getAllOutboundParticipantMigrations(null);
    for (final EParticipantMigrationState eState : EParticipantMigrationState.values()) if (eState.isOutboundState()) {
        final ICommonsList<ISMPParticipantMigration> aMatchingMigs = aAllMigs.getAll(x -> x.getState() == eState);
        aTabBox.addTab(eState.getID(), eState.getDisplayName() + " (" + aMatchingMigs.size() + ")", _createTable(aWPEC, aMatchingMigs, eState));
    }
}
Also used : 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) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) EValidity(com.helger.commons.state.EValidity) ICommonsList(com.helger.commons.collection.impl.ICommonsList) HCNodeList(com.helger.html.hc.impl.HCNodeList) EParticipantMigrationState(com.helger.phoss.smp.domain.pmigration.EParticipantMigrationState) BootstrapTabBox(com.helger.photon.bootstrap4.nav.BootstrapTabBox) BootstrapWarnBox(com.helger.photon.bootstrap4.alert.BootstrapWarnBox) ISMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) HCOL(com.helger.html.hc.html.grouping.HCOL) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) ISMPParticipantMigrationManager(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)

Aggregations

ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)67 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)47 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)45 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)35 IUser (com.helger.photon.security.user.IUser)25 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)23 SMPServerException (com.helger.phoss.smp.exception.SMPServerException)22 Nonnull (javax.annotation.Nonnull)22 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)21 Test (org.junit.Test)19 ISMPRedirectManager (com.helger.phoss.smp.domain.redirect.ISMPRedirectManager)16 HCNodeList (com.helger.html.hc.impl.HCNodeList)15 ISMPServiceInformation (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation)15 IMicroDocument (com.helger.xml.microdom.IMicroDocument)12 ServiceGroupType (com.helger.xsds.peppol.smp1.ServiceGroupType)12 ServiceMetadataReferenceCollectionType (com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType)12 SMPNotFoundException (com.helger.phoss.smp.exception.SMPNotFoundException)11 ISMPSettings (com.helger.phoss.smp.settings.ISMPSettings)11 ICommonsList (com.helger.commons.collection.impl.ICommonsList)10 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)10