Search in sources :

Example 1 with ReloadingCategoryReferencesThread

use of com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread in project entando-core by entando.

the class DataObjectUpdaterService method reloadCategoryReferences.

@Override
public void reloadCategoryReferences(String categoryCode) {
    try {
        Set<String> contents = this.getDataObjectsId(categoryCode);
        ApsSystemUtils.getLogger().debug("start reload category references for " + contents.size() + " contents");
        ReloadingCategoryReferencesThread th = null;
        Thread currentThread = Thread.currentThread();
        if (currentThread instanceof ReloadingCategoryReferencesThread) {
            th = (ReloadingCategoryReferencesThread) Thread.currentThread();
            th.setListSize(contents.size());
        }
        Iterator<String> it = contents.iterator();
        while (it.hasNext()) {
            String dataid = it.next();
            this.reloadEntityReferences(dataid);
            if (null != th) {
                th.setListIndex(th.getListIndex() + 1);
            }
        }
    } catch (Throwable t) {
        ApsSystemUtils.logThrowable(t, this, "reloadCategoryReferences");
    }
}
Also used : ReloadingCategoryReferencesThread(com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread) ReloadingCategoryReferencesThread(com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread)

Example 2 with ReloadingCategoryReferencesThread

use of com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread in project entando-core by entando.

the class CategoryAction method getUpdateReferencesStatus.

/**
 * provide the result for the progress bar
 *
 * @return
 */
public Map<String, Integer> getUpdateReferencesStatus() {
    int total = 0;
    int done = 0;
    ThreadGroup currentGroup = Thread.currentThread().getThreadGroup();
    int numThreads = currentGroup.activeCount();
    Thread[] listOfThreads = new Thread[numThreads];
    currentGroup.enumerate(listOfThreads);
    for (int i = 0; i < numThreads; i++) {
        if (listOfThreads[i].getName().startsWith(ICategoryManager.RELOAD_CATEGORY_REFERENCES_THREAD_NAME_PREFIX)) {
            ReloadingCategoryReferencesThread thread = (ReloadingCategoryReferencesThread) listOfThreads[i];
            total = total + thread.getListSize();
            done = done + thread.getListIndex();
        }
    }
    Map<String, Integer> result = new HashMap<String, Integer>();
    result.put("total", total);
    result.put("done", done);
    return result;
}
Also used : HashMap(java.util.HashMap) ReloadingCategoryReferencesThread(com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread) ReloadingCategoryReferencesThread(com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread)

Example 3 with ReloadingCategoryReferencesThread

use of com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread in project entando-core by entando.

the class ResourceManager method reloadCategoryReferences.

@Override
public void reloadCategoryReferences(String categoryCode) throws ApsSystemException {
    try {
        List<String> resources = this.getCategoryUtilizersForReloadReferences(categoryCode);
        logger.info("start reload category references for {} resources", resources.size());
        ReloadingCategoryReferencesThread th = null;
        Thread currentThread = Thread.currentThread();
        if (currentThread instanceof ReloadingCategoryReferencesThread) {
            th = (ReloadingCategoryReferencesThread) Thread.currentThread();
            th.setListSize(resources.size());
        }
        if (null != resources && !resources.isEmpty()) {
            Iterator<String> it = resources.iterator();
            while (it.hasNext()) {
                String code = it.next();
                ResourceInterface resource = this.loadResource(code);
                this.getResourceDAO().updateResourceRelations(resource);
                if (null != th)
                    th.setListIndex(th.getListIndex() + 1);
            }
        }
    } catch (Throwable t) {
        logger.error("Error searching category utilizers : category code '{}'", categoryCode, t);
        throw new ApsSystemException("Error searching category utilizers : category code '" + categoryCode + "'", t);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) ReloadingCategoryReferencesThread(com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread) ReloadingCategoryReferencesThread(com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread)

Example 4 with ReloadingCategoryReferencesThread

use of com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread in project entando-core by entando.

the class ContentUpdaterService method reloadCategoryReferences.

@Override
public void reloadCategoryReferences(String categoryCode) {
    try {
        Set<String> contents = this.getContentsId(categoryCode);
        ApsSystemUtils.getLogger().debug("start reload category references for " + contents.size() + " contents");
        ReloadingCategoryReferencesThread th = null;
        Thread currentThread = Thread.currentThread();
        if (currentThread instanceof ReloadingCategoryReferencesThread) {
            th = (ReloadingCategoryReferencesThread) Thread.currentThread();
            th.setListSize(contents.size());
        }
        Iterator<String> it = contents.iterator();
        while (it.hasNext()) {
            String contentId = it.next();
            this.reloadEntityReferences(contentId);
            if (null != th) {
                th.setListIndex(th.getListIndex() + 1);
            }
        }
    } catch (Throwable t) {
        ApsSystemUtils.logThrowable(t, this, "reloadCategoryReferences");
    }
}
Also used : ReloadingCategoryReferencesThread(com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread) ReloadingCategoryReferencesThread(com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread)

Aggregations

ReloadingCategoryReferencesThread (com.agiletec.aps.system.services.category.ReloadingCategoryReferencesThread)4 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)1 HashMap (java.util.HashMap)1