Reads all cached images.<p>

@param cms the cms context
@param withVariations if also variations should be read
@param showSize if it is needed to compute the image size
@param statsOnly if only statistical information should be retrieved
325978
private void init(CmsObject cms, boolean withVariations, boolean showSize, boolean statsOnly) {

        File basedir = new File(CmsImageLoader.getImageRepositoryPath());
        try {
            CmsObject clonedCms = getClonedCmsObject(cms);
            visitImages(clonedCms, basedir, withVariations, showSize, statsOnly);
        } catch (CmsException e) {
            // should never happen
        }
        m_variations = Collections.unmodifiableMap(m_variations);
        m_sizes = Collections.unmodifiableMap(m_sizes);
        m_lengths = Collections.unmodifiableMap(m_lengths);
    }
774556
public void addResult(CmsResourceTypeStatResult result) {

        if (!m_results.contains(result)) {
            m_results.add(result);
            m_updated = false;
        } else {
            m_results.remove(result);
            m_results.add(result);
            m_updated = true;
        }
    }
826582
protected void initLocalizationContent(String configurationFileName) {

        CmsObject cms = null;
        try {
            // this will always be in the root site
            cms = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest());
        } catch (CmsException e) {
            // error initializing cms object, log error
            if (LOG.isErrorEnabled()) {
                LOG.error(
                    Messages.get().getBundle().key(
                        Messages.ERR_INVALID_INIT_USER_1,
                        OpenCms.getDefaultUsers().getUserGuest()));
            }
        }
        if ((cms != null) && CmsStringUtil.isNotEmptyOrWhitespaceOnly(configurationFileName)) {
            // try to get XML content from cache
            Object o = CmsVfsMemoryObjectCache.getVfsMemoryObjectCache().getCachedObject(cms, configurationFileName);
            if (o != null) {
                // found the cached XML content, use it
                m_localizationContent = (CmsXmlContent)o;
                return;
            }
            try {
                CmsFile configFile = cms.readFile(configurationFileName);
                m_localizationContent = CmsXmlContentFactory.unmarshal(cms, configFile);
                // store unmarshaled content in cache
                CmsVfsMemoryObjectCache.getVfsMemoryObjectCache().putCachedObject(
                    cms,
                    configurationFileName,
                    m_localizationContent);
            } catch (CmsException e) {
                // ignore, no configuration file found
            }
        }
    }
1357717
private CmsADESessionCache getSessionCache(CmsObject cms) {

        return m_editableRequest
        ? CmsADESessionCache.getCache((HttpServletRequest)(pageContext.getRequest()), cms)
        : null;
    }
397765
public void readDependencies(CmsObject cms) {

        try {
            // read all resources in the parent folder of the published resource
            List<CmsResource> folderContent = cms.getResourcesInFolder(
                CmsResource.getParentFolder(cms.getRequestContext().removeSiteRoot(getResource().getRootPath())),
                CmsResourceFilter.DEFAULT);
            // now calculate the dependencies form the folder content that has been read
            readDependencies(cms, folderContent);
        } catch (CmsException e) {
            LOG.warn("Unable to read dependencies for " + getResource().getRootPath(), e);
        }
    }
1286712
void displayResult(CmsSolrResultList resultList) {

        List<CmsResource> resources;
        evalSeries(resultList);
        if (m_hideSeriesInstances) {
            Set<CmsUUID> instanceIds = new HashSet<CmsUUID>();
            resources = new ArrayList<CmsResource>();
            for (CmsSearchResource res : resultList) {
                if (!instanceIds.contains(res.getStructureId())) {
                    instanceIds.add(res.getStructureId());
                    resources.add(res);
                }
            }
        } else {
            resources = new ArrayList<CmsResource>(resultList);
        }
        m_resultTable.fillTable(A_CmsUI.getCmsObject(), resources, true, false);
        String state = A_CmsWorkplaceApp.addParamToState(
            "",
            CmsEditor.RESOURCE_ID_PREFIX,
            m_currentResource.getStructureId().toString());
        state = A_CmsWorkplaceApp.addParamToState(
            state,
            PARAM_LOCALE,
            m_currentConfigParser.getSearchLocale().toString());
        m_currentState = state;
        CmsAppWorkplaceUi.get().changeCurrentAppState(state);
        if (m_isOverView) {
            enableOverviewMode(false);
            updateBreadCrumb(getBreadCrumbForState(state));
        }
    }
1349886
public void setPreviewVisible(boolean visible) {

        m_previewVisible = visible;
        if (m_previewVisible) {
            useMaxDimensions();
            m_previewVisibility.setValue(I_CmsLayoutBundle.INSTANCE.previewDialogCss().previewVisible());
            if (m_galleryHandler instanceof CmsGalleryPopup) {
                ((CmsGalleryPopup)m_galleryHandler).center();
            }
        } else {
            m_previewVisibility.setValue(I_CmsLayoutBundle.INSTANCE.previewDialogCss().hidePreview());
            updateSizes();
        }
    }
703603
public CmsFormatterConfigurationCacheState getCachedFormatters(boolean online) {

        CmsFormatterConfigurationCache cache = online ? m_onlineFormatterCache : m_offlineFormatterCache;
        return cache.getState();
    }
71600
public void updateCmsObject(CmsObject cms) {

        try {
            m_cms = OpenCms.initCmsObject(cms);
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
            m_cms = cms;
        }
    }
1119055
public void initialize(CmsObject cms) {

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(
                Messages.get().getBundle().key(
                    Messages.INIT_NUM_SITE_ROOTS_CONFIGURED_1,
                    new Integer((m_siteMatcherSites.size() + ((m_defaultUri != null) ? 1 : 0)))));
        }

        try {

            m_clone = OpenCms.initCmsObject(cms);
            m_clone.getRequestContext().setSiteRoot("");
            m_clone.getRequestContext().setCurrentProject(m_clone.readProject(CmsProject.ONLINE_PROJECT_NAME));

            CmsObject cms_offline = OpenCms.initCmsObject(m_clone);
            CmsProject tempProject = cms_offline.createProject(
                "tempProjectSites",
                "",
                "/Users",
                "/Users",
                CmsProject.PROJECT_TYPE_TEMPORARY);
            cms_offline.getRequestContext().setCurrentProject(tempProject);

            m_siteUUIDs = new HashMap<CmsUUID, CmsSite>();
            // check the presence of sites in VFS

            m_onlyOfflineSites = new ArrayList<CmsSite>();

            for (CmsSite site : m_siteMatcherSites.values()) {
                checkUUIDOfSiteRoot(site, m_clone, cms_offline);
                try {
                    CmsResource siteRes = m_clone.readResource(site.getSiteRoot());
                    site.setSiteRootUUID(siteRes.getStructureId());

                    m_siteUUIDs.put(siteRes.getStructureId(), site);
                    // during server startup the digester can not access properties, so set the title afterwards
                    if (CmsStringUtil.isEmptyOrWhitespaceOnly(site.getTitle())) {
                        String title = m_clone.readPropertyObject(
                            siteRes,
                            CmsPropertyDefinition.PROPERTY_TITLE,
                            false).getValue();
                        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(title)) {
                            site.setTitle(title);
                        }
                    }
                } catch (Throwable t) {
                    if (CmsLog.INIT.isWarnEnabled()) {
                        CmsLog.INIT.warn(Messages.get().getBundle().key(Messages.INIT_NO_ROOT_FOLDER_1, site));
                    }
                }
            }
            cms_offline.deleteProject(tempProject.getUuid());

            // check the presence of the default site in VFS
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_defaultUri)) {
                m_defaultSite = null;
            } else {
                m_defaultSite = new CmsSite(m_defaultUri, CmsSiteMatcher.DEFAULT_MATCHER);
                try {
                    m_clone.readResource(m_defaultSite.getSiteRoot());
                } catch (Throwable t) {
                    if (CmsLog.INIT.isWarnEnabled()) {
                        CmsLog.INIT.warn(
                            Messages.get().getBundle().key(Messages.INIT_NO_ROOT_FOLDER_DEFAULT_SITE_1, m_defaultSite));
                    }
                }
            }
            if (m_defaultSite == null) {
                m_defaultSite = new CmsSite("/", CmsSiteMatcher.DEFAULT_MATCHER);
            }
            if (CmsLog.INIT.isInfoEnabled()) {
                if (m_defaultSite != null) {
                    CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_DEFAULT_SITE_ROOT_1, m_defaultSite));
                } else {
                    CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_DEFAULT_SITE_ROOT_0));
                }
            }
            initWorkplaceMatchers();

            // set site lists to unmodifiable
            setSiteMatcherSites(m_siteMatcherSites);

            // store additional site roots to optimize lookups later
            for (String root : m_siteRootSites.keySet()) {
                if (!root.startsWith(SITES_FOLDER) || (root.split("/").length >= 4)) {
                    m_additionalSiteRoots.add(root);
                }
            }

            if (m_sharedFolder == null) {
                m_sharedFolder = DEFAULT_SHARED_FOLDER;
            }

            // initialization is done, set the frozen flag to true
            m_frozen = true;
        } catch (CmsException e) {
            LOG.warn(e);
        }
        if (!m_isListenerSet) {
            OpenCms.addCmsEventListener(this, new int[] {I_CmsEventListener.EVENT_PUBLISH_PROJECT});
            m_isListenerSet = true;
        }
    }
748357
public void setFindingStatisticTypes(java.util.Collection<String> findingStatisticTypes) {
        if (findingStatisticTypes == null) {
            this.findingStatisticTypes = null;
            return;
        }

        this.findingStatisticTypes = new java.util.ArrayList<String>(findingStatisticTypes);
    }
1288546
protected CmsResource getFunctionFormatter(CmsObject cms) throws CmsException {

        CmsVfsMemoryObjectCache cache = CmsVfsMemoryObjectCache.getVfsMemoryObjectCache();
        String path = CmsResourceTypeFunctionConfig.FORMATTER_PATH;
        Object cacheValue = cache.getCachedObject(cms, path);
        if (cacheValue == null) {
            CmsResource functionRes = cms.readResource(path);
            cache.putCachedObject(cms, path, functionRes);
            return functionRes;
        } else {
            return (CmsResource)cacheValue;
        }
    }
1015713
public List<I_CmsFormatterBean> getDisplayFormatters(CmsObject cms) {

        List<I_CmsFormatterBean> result = new ArrayList<I_CmsFormatterBean>();

        for (I_CmsFormatterBean formatter : getCachedFormatters().getFormatters().values()) {
            if (formatter.isDisplayFormatter()) {
                result.add(formatter);
            }
        }
        return result;
    }
250929
public void setDisplayFormatters(Object displayFormatters) {

        if (displayFormatters instanceof List) {
            for (Object formatterItem : ((List<?>)displayFormatters)) {
                if (formatterItem instanceof CmsJspContentAccessValueWrapper) {
                    addFormatter((CmsJspContentAccessValueWrapper)formatterItem);
                }
            }
        } else if (displayFormatters instanceof CmsJspContentAccessValueWrapper) {
            addFormatter((CmsJspContentAccessValueWrapper)displayFormatters);
        } else if (displayFormatters instanceof String) {
            String[] temp = ((String)displayFormatters).split(CmsXmlDisplayFormatterValue.SEPARATOR);
            if (temp.length == 2) {
                addDisplayFormatter(temp[0], temp[1]);
            }
        }
    }
890838
public void setStatistics(java.util.Collection<String> statistics) {
        if (statistics == null) {
            this.statistics = null;
            return;
        }

        this.statistics = new java.util.ArrayList<String>(statistics);
    }
656331
public CmsFormatterConfiguration getFormatters(CmsObject cms, CmsResource res) {

        if (CmsResourceTypeFunctionConfig.isFunction(res)) {

            CmsFormatterConfigurationCacheState formatters = getCachedFormatters();
            I_CmsFormatterBean function = formatters.getFormatters().get(res.getStructureId());
            if (function != null) {
                return CmsFormatterConfiguration.create(cms, Collections.singletonList(function));
            } else {
                if ((!res.getStructureId().isNullUUID())
                    && cms.existsResource(res.getStructureId(), CmsResourceFilter.IGNORE_EXPIRATION)) {
                    // usually if it's just been created, but not added to the configuration cache yet
                    CmsFormatterBeanParser parser = new CmsFormatterBeanParser(cms, new HashMap<>());
                    try {
                        function = parser.parse(
                            CmsXmlContentFactory.unmarshal(cms, cms.readFile(res)),
                            res.getRootPath(),
                            "" + res.getStructureId());
                        return CmsFormatterConfiguration.create(cms, Collections.singletonList(function));
                    } catch (Exception e) {
                        LOG.warn(e.getLocalizedMessage(), e);
                        return CmsFormatterConfiguration.EMPTY_CONFIGURATION;
                    }

                } else {
                    // if a new function has been dragged on the page, it doesn't exist in the VFS yet, so we need a different
                    // instance as a replacement
                    CmsResource defaultFormatter = CmsFunctionRenderer.getDefaultFunctionInstance(cms);
                    if (defaultFormatter != null) {
                        I_CmsFormatterBean defaultFormatterBean = formatters.getFormatters().get(
                            defaultFormatter.getStructureId());
                        return CmsFormatterConfiguration.create(cms, Collections.singletonList(defaultFormatterBean));
                    } else {
                        LOG.warn("Could not read default formatter for functions.");
                        return CmsFormatterConfiguration.EMPTY_CONFIGURATION;
                    }
                }
            }
        } else {
            try {
                int resTypeId = res.getTypeId();
                return getFormatters(
                    cms,
                    OpenCms.getResourceManager().getResourceType(resTypeId),
                    getFormattersFromSchema(cms, res));
            } catch (CmsLoaderException e) {
                LOG.warn(e.getLocalizedMessage(), e);
                return CmsFormatterConfiguration.EMPTY_CONFIGURATION;
            }
        }
    }
588744
private NamedTemplate readTemplateWithName(CmsObject cms, String path) {

        try {
            CmsResource resource = cms.readResource(path, CmsResourceFilter.IGNORE_EXPIRATION);
            String name = getTemplateName(cms, resource);
            return new NamedTemplate(resource, name);
        } catch (Exception e) {
            return null;
        }
    }