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;
}
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));
}
Aggregations