Search in sources :

Example 1 with PagesStatus

use of com.agiletec.aps.system.services.page.PagesStatus in project entando-core by entando.

the class PageManagerCacheWrapper method initCache.

@Override
public void initCache(IPageDAO pageDao) throws ApsSystemException {
    PagesStatus status = new PagesStatus();
    IPage newDraftRoot = null;
    IPage newOnLineRoot = null;
    try {
        Cache cache = this.getCache();
        this.releaseCachedObjects(cache);
        List<PageRecord> pageRecordList = pageDao.loadPageRecords();
        Map<String, IPage> newFullMap = new HashMap<String, IPage>(pageRecordList.size());
        Map<String, IPage> newOnlineMap = new HashMap<String, IPage>();
        List<IPage> pageListO = new ArrayList<>();
        List<IPage> pageListD = new ArrayList<>();
        for (int i = 0; i < pageRecordList.size(); i++) {
            PageRecord pageRecord = pageRecordList.get(i);
            IPage pageD = pageRecord.createDraftPage();
            IPage pageO = pageRecord.createOnlinePage();
            pageListD.add(pageD);
            newFullMap.put(pageD.getCode(), pageD);
            if (pageD.getCode().equals(pageD.getParentCode())) {
                newDraftRoot = pageD;
                newOnLineRoot = pageO;
            }
            this.buildPagesStatus(status, pageD);
            if (pageD.isOnline()) {
                newOnlineMap.put(pageO.getCode(), pageO);
                pageListO.add(pageO);
            }
        }
        for (int i = 0; i < pageListD.size(); i++) {
            this.buildTreeHierarchy(newDraftRoot, newFullMap, pageListD.get(i));
        }
        for (int i = 0; i < pageListO.size(); i++) {
            this.buildTreeHierarchy(newOnLineRoot, newOnlineMap, pageListO.get(i));
        }
        if (newDraftRoot == null) {
            throw new ApsSystemException("Error in the page tree: root page undefined");
        }
        this.insertObjectsOnCache(cache, status, newDraftRoot, newOnLineRoot, pageListD, pageListO);
    } catch (ApsSystemException e) {
        throw e;
    } catch (Throwable t) {
        _logger.error("Error while building the tree of pages", t);
        throw new ApsSystemException("Error while building the tree of pages", t);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) IPage(com.agiletec.aps.system.services.page.IPage) PageRecord(com.agiletec.aps.system.services.page.PageRecord) PagesStatus(com.agiletec.aps.system.services.page.PagesStatus) Cache(org.springframework.cache.Cache)

Example 2 with PagesStatus

use of com.agiletec.aps.system.services.page.PagesStatus in project entando-core by entando.

the class PageFinderAction method getPagesStatusResponse.

public PagesStatusResponse getPagesStatusResponse() {
    PagesStatusResponse response = null;
    try {
        PagesStatus pagesStatus = this.getPageManager().getPagesStatus();
        response = new PagesStatusResponse(pagesStatus);
    } catch (Throwable t) {
        _logger.error("Error loading pagesStatus", t);
        throw new RuntimeException("Error loading pagesStatus", t);
    }
    return response;
}
Also used : PagesStatusResponse(org.entando.entando.apsadmin.portal.rs.model.PagesStatusResponse) PagesStatus(com.agiletec.aps.system.services.page.PagesStatus)

Aggregations

PagesStatus (com.agiletec.aps.system.services.page.PagesStatus)2 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 IPage (com.agiletec.aps.system.services.page.IPage)1 PageRecord (com.agiletec.aps.system.services.page.PageRecord)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 PagesStatusResponse (org.entando.entando.apsadmin.portal.rs.model.PagesStatusResponse)1 Cache (org.springframework.cache.Cache)1