Search in sources :

Example 21 with ISMPSettings

use of com.helger.phoss.smp.settings.ISMPSettings in project phoss-smp by phax.

the class SMPRendererSecure method getMenuContent.

@Nonnull
public static IHCNode getMenuContent(@Nonnull final ILayoutExecutionContext aLEC) {
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    final HCNodeList ret = new HCNodeList();
    final ISMPSettings aSettings = SMPMetaManager.getSettings();
    ret.addChild(BootstrapMenuItemRenderer.createSideBarMenu(aLEC));
    final BootstrapSuccessBox aBox = new BootstrapSuccessBox().addClass(CBootstrapCSS.MT_2);
    if (SMPMetaManager.getInstance().getBackendConnectionState().isFalse()) {
        aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" No database connection: ").addChild(new HCA(CAjax.FUNCTION_BACKEND_CONNECTION_RESET.getInvocationURL(aRequestScope)).addChild("Retry")));
        aBox.setType(EBootstrapAlertType.DANGER);
    }
    // Information on SML usage
    if (aSettings.isSMLEnabled()) {
        aBox.addChild(new HCDiv().addChild(EDefaultIcon.YES.getAsNode()).addChild(" SML connection is configured."));
        if (aSettings.getSMLInfo() == null) {
            aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" No SML is selected. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
            aBox.setType(EBootstrapAlertType.DANGER);
        }
    } else {
        // Warn only if SML is needed
        if (aSettings.isSMLRequired()) {
            aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" SML connection is NOT configured. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
            aBox.setTypeIfWorse(EBootstrapAlertType.WARNING);
        }
    }
    if (aSettings.isDirectoryIntegrationRequired()) {
        if (aSettings.isDirectoryIntegrationEnabled()) {
            aBox.addChild(new HCDiv().addChild(EDefaultIcon.YES.getAsNode()).addChild(" Directory support is configured."));
            if (StringHelper.hasNoText(aSettings.getDirectoryHostName())) {
                aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" No Directory host is provided. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
                aBox.setType(EBootstrapAlertType.DANGER);
            }
        } else {
            // Warn only if Directory is needed
            aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" Directory support is NOT configured. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
            aBox.setTypeIfWorse(EBootstrapAlertType.WARNING);
        }
    }
    // Information on certificate
    if (!SMPKeyManager.isKeyStoreValid()) {
        aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" Certificate configuration is invalid."));
        aBox.setType(EBootstrapAlertType.DANGER);
    }
    ret.addChild(aBox);
    return ret;
}
Also used : HCDiv(com.helger.html.hc.html.grouping.HCDiv) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) HCA(com.helger.html.hc.html.textlevel.HCA) BootstrapSuccessBox(com.helger.photon.bootstrap4.alert.BootstrapSuccessBox) Nonnull(javax.annotation.Nonnull)

Example 22 with ISMPSettings

use of com.helger.phoss.smp.settings.ISMPSettings in project phoss-smp by phax.

the class PageSecureServiceGroupExport method fillContent.

@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
    final ISMPSettings aSettings = SMPMetaManager.getSettings();
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final long nServiceGroupCount = aServiceGroupMgr.getSMPServiceGroupCount();
    final boolean bHandleBusinessCards = aSettings.isDirectoryIntegrationEnabled();
    if (nServiceGroupCount < 0)
        aNodeList.addChild(error("The number of service groups is unknown, hence nothing can be exported!"));
    else if (nServiceGroupCount == 0)
        aNodeList.addChild(warn("Since no service group is present, nothing can be exported!"));
    else {
        aNodeList.addChild(info("Export " + (nServiceGroupCount == 1 ? "service group" : "all " + nServiceGroupCount + " service groups") + (bHandleBusinessCards ? " and business card" + (nServiceGroupCount == 1 ? "" : "s") : "") + " to an XML file."));
    }
    // The main export logic happens in the AJAX handler
    final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(getUIHandler().createToolbar(aWPEC));
    aToolbar.addChild(new BootstrapButton().addChild("Export all Service Groups").setIcon(EDefaultIcon.SAVE_ALL).setOnClick(AJAX_EXPORT_SG.getInvocationURL(aRequestScope)).setDisabled(nServiceGroupCount <= 0));
}
Also used : IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)

Aggregations

ISMPSettings (com.helger.phoss.smp.settings.ISMPSettings)22 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)12 HCNodeList (com.helger.html.hc.impl.HCNodeList)10 Nonnull (javax.annotation.Nonnull)9 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)8 PDTToString (com.helger.commons.datetime.PDTToString)7 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)7 HCA (com.helger.html.hc.html.textlevel.HCA)6 ManageParticipantIdentifierServiceCaller (com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller)6 ISMPParticipantMigrationManager (com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager)6 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)6 ISMLInfo (com.helger.peppol.sml.ISMLInfo)5 SMPMetaManager (com.helger.phoss.smp.domain.SMPMetaManager)5 ISMPBusinessCardManager (com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardManager)5 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)5 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)5 Locale (java.util.Locale)5 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)4 ICommonsList (com.helger.commons.collection.impl.ICommonsList)4 ISMPBusinessCard (com.helger.phoss.smp.domain.businesscard.ISMPBusinessCard)4