Search in sources :

Example 11 with IMenuItemPage

use of com.helger.photon.core.menu.IMenuItemPage in project peppol-practical by phax.

the class PageSecureAdminAddons method _handleAction.

@Nullable
private IHCNode _handleAction(@Nullable final String sAction) {
    if (ACTION_EXPIRE_PAGE_CACHE.equals(sAction)) {
        final IMenuTree aPublicMenuTree = PhotonGlobalState.state(CApplicationID.APP_ID_PUBLIC).getMenuTree();
        // Bulk modify
        final MutableInt aCounterUpdated = new MutableInt(0);
        final MutableInt aCounterNoNeed = new MutableInt(0);
        aPublicMenuTree.iterateAllMenuObjects(aMenuObj -> {
            if (aMenuObj instanceof IMenuItemPage) {
                final IMenuItemPage aMenuItemPage = (IMenuItemPage) aMenuObj;
                if (aMenuItemPage.getPage() instanceof IWebPageResourceContent) {
                    final IWebPageResourceContent aPageViewExternal = (IWebPageResourceContent) aMenuItemPage.getPage();
                    if (aPageViewExternal.isReadEveryTime())
                        aCounterNoNeed.inc();
                    else {
                        aPageViewExternal.updateFromResource();
                        aCounterUpdated.inc();
                    }
                }
            }
        });
        final String sMsg = aCounterUpdated.intValue() + " pages were reloaded." + (aCounterNoNeed.isGT0() ? " On " + aCounterNoNeed.intValue() + " pages no action was necessary because they are set to reload every time." : "");
        LOGGER.info(sMsg);
        AuditHelper.onAuditExecuteSuccess("page-reload", aCounterUpdated.getAsInteger(), aCounterNoNeed.getAsInteger());
        return success(sMsg);
    }
    return null;
}
Also used : IWebPageResourceContent(com.helger.photon.uicore.page.external.IWebPageResourceContent) IMenuTree(com.helger.photon.core.menu.IMenuTree) MutableInt(com.helger.commons.mutable.MutableInt) IMenuItemPage(com.helger.photon.core.menu.IMenuItemPage) Nullable(javax.annotation.Nullable)

Aggregations

IMenuItemPage (com.helger.photon.core.menu.IMenuItemPage)11 Locale (java.util.Locale)6 IRequestWebScopeWithoutResponse (com.helger.web.scope.IRequestWebScopeWithoutResponse)5 IHCNode (com.helger.html.hc.IHCNode)4 HCHead (com.helger.html.hc.html.metadata.HCHead)4 HCBody (com.helger.html.hc.html.sections.HCBody)4 LayoutExecutionContext (com.helger.photon.core.execcontext.LayoutExecutionContext)4 BasePageShowChildren (com.helger.photon.uicore.page.system.BasePageShowChildren)4 BasePageSecurityChangePassword (com.helger.photon.bootstrap4.pages.security.BasePageSecurityChangePassword)3 MenuObjectFilterUserAssignedToUserGroup (com.helger.photon.core.menu.filter.MenuObjectFilterUserAssignedToUserGroup)3 WebPageExecutionContext (com.helger.photon.uicore.page.WebPageExecutionContext)3 Nonnull (javax.annotation.Nonnull)3 SimpleURL (com.helger.commons.url.SimpleURL)2 HCUL (com.helger.html.hc.html.grouping.HCUL)2 HCNodeList (com.helger.html.hc.impl.HCNodeList)2 BootstrapContainer (com.helger.photon.bootstrap4.layout.BootstrapContainer)2 BootstrapMenuItemRendererHorz (com.helger.photon.bootstrap4.uictrls.ext.BootstrapMenuItemRendererHorz)2 IMenuItemExternal (com.helger.photon.core.menu.IMenuItemExternal)2 IMenuObject (com.helger.photon.core.menu.IMenuObject)2 IMenuSeparator (com.helger.photon.core.menu.IMenuSeparator)2