Search in sources :

Example 1 with IWebPageResourceContent

use of com.helger.photon.uicore.page.external.IWebPageResourceContent 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

MutableInt (com.helger.commons.mutable.MutableInt)1 IMenuItemPage (com.helger.photon.core.menu.IMenuItemPage)1 IMenuTree (com.helger.photon.core.menu.IMenuTree)1 IWebPageResourceContent (com.helger.photon.uicore.page.external.IWebPageResourceContent)1 Nullable (javax.annotation.Nullable)1