Checks whether a built of the indices is necessary.
@param cms The appropriate CmsObject instance.
@return true, if the spellcheck indices have to be rebuilt, otherwise false
557041
public static boolean updatingIndexNecessesary(CmsObject cms) {

        // Set request to the offline project.
        setCmsOfflineProject(cms);

        // Check whether the spellcheck index directories are empty.
        // If they are, the index has to be built obviously.
        if (isSolrSpellcheckIndexDirectoryEmpty()) {
            return true;
        }

        // Compare the most recent date of a dictionary with the oldest timestamp
        // that determines when an index has been built.
        long dateMostRecentDictionary = getMostRecentDate(cms);
        long dateOldestIndexWrite = getOldestIndexDate(cms);

        return dateMostRecentDictionary > dateOldestIndexWrite;
    }
225931
protected boolean isSitePathValid() {

        try {
            CmsObject cmsLocal = OpenCms.initCmsObject(m_cms);
            cmsLocal.getRequestContext().setSiteRoot((String)m_site.getValue());
            if (m_startfolder.getValue().length() <= ((String)m_site.getValue()).length()) {
                return false;
            }
            return cmsLocal.existsResource(m_startfolder.getValue().substring(((String)m_site.getValue()).length()));
        } catch (CmsException e) {
            LOG.error("Unabel to ini CmsObject", e);
            return false;
        }
    }
1054658
private void checkPermissionsForMassEdit(CmsObject cms, String siteRoot) throws CmsException {

        String originalSiteRoot = cms.getRequestContext().getSiteRoot();
        try {
            cms.getRequestContext().setSiteRoot(siteRoot);
            checkPermissionsForMassEdit(cms);
        } finally {
            cms.getRequestContext().setSiteRoot(originalSiteRoot);
        }
    }
402704
public boolean isShowEditorHelp(CmsObject cms) {

        CmsUser user = cms.getRequestContext().getCurrentUser();
        String showHelp = (String)user.getAdditionalInfo(ADDINFO_ADE_SHOW_EDITOR_HELP);
        return CmsStringUtil.isEmptyOrWhitespaceOnly(showHelp) || Boolean.parseBoolean(showHelp);
    }
357744
public static boolean existsEditor(CmsResource resource) {

        int plainId;
        try {
            plainId = OpenCms.getResourceManager().getResourceType(
                CmsResourceTypePlain.getStaticTypeName()).getTypeId();
        } catch (CmsLoaderException e) {
            // this should really never happen
            plainId = CmsResourceTypePlain.getStaticTypeId();
        }
        if ((CmsResourceTypeJsp.isJsp(resource))
            || (resource.getTypeId() == plainId)
            || CmsResourceTypeXmlPage.isXmlPage(resource)) {
            return true;
        }
        return false;
    }
129908
@SuppressWarnings("deprecation")
    public boolean isInheritedContainer(CmsObject cms) throws CmsException {

        if (m_resource == null) {
            initResource(cms);
        }
        return OpenCms.getResourceManager().getResourceType(
            CmsResourceTypeXmlContainerPage.INHERIT_CONTAINER_TYPE_NAME).getTypeId() == m_resource.getTypeId();
    }
1371318
public void rebuildIndex(String index) throws Exception {

        OpenCms.getSearchManager().rebuildIndex(index, new CmsShellReport(m_cms.getRequestContext().getLocale()));
    }
1199467
public boolean hasMoreAdminOUs() throws CmsException {

        List<CmsOrganizationalUnit> orgUnits = getOrgUnits();

        if (orgUnits == null) {
            return false;
        }
        if (orgUnits.size() <= 1) {
            return false;
        }
        return true;
    }
1145347
private boolean hasRole(CmsRole role) {

        if (m_user != null) {
            return OpenCms.getRoleManager().hasRole(m_cms, m_user.getName(), CmsRole.VFS_MANAGER);
        }
        return false;
    }
583284
public static boolean hasChildren(CmsObject cms, CmsResource resource) throws CmsException {

        return !cms.getResourcesInFolder(cms.getSitePath(resource), CmsResourceFilter.ALL).isEmpty();
    }
1190252
public boolean isGroupContainer(CmsObject cms) throws CmsException {

        if (m_resource == null) {
            initResource(cms);
        }
        return CmsResourceTypeXmlContainerPage.GROUP_CONTAINER_TYPE_NAME.equals(
            OpenCms.getResourceManager().getResourceType(m_resource).getTypeName());
    }
71600
public void updateCmsObject(CmsObject cms) {

        try {
            m_cms = OpenCms.initCmsObject(cms);
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
            m_cms = cms;
        }
    }
695608
public void init(CmsObject cms, List<CmsResource> resources) {

        m_cms = cms;
        m_resources = resources;
    }
11554
protected static boolean isFolder(CmsResource resource) throws CmsLoaderException {

        I_CmsResourceType resourceType = OpenCms.getResourceManager().getResourceType(resource.getTypeId());
        return resourceType.isFolder();
    }
774419
public boolean checkUpdatable(CmsObject cms) {

        CmsModule newModule = getModule();
        LOG.info("Checking if module " + newModule.getName() + " is updateable");
        String exportVersion = newModule.getExportVersion();
        CmsModule installedModule = OpenCms.getModuleManager().getModule(getModule().getName());
        if (!CmsModuleUpdater.checkCompatibleModuleResources(installedModule, newModule)) {
            LOG.info("Module is not updateable because of incompatible module resources. ");
            return false;
        }

        if ((exportVersion == null) || !exportVersion.equals("" + CmsImportVersion10.IMPORT_VERSION10)) {
            LOG.info("Module is not updateable because the export version is not 10.");
            return false;
        }

        try {
            Map<CmsUUID, CmsResourceImportData> importResourcesById = new HashMap<>();
            for (CmsResourceImportData resData : getResourceData()) {
                if (resData.hasStructureId()) {
                    importResourcesById.put(resData.getResource().getStructureId(), resData);
                }
            }
            cms = getCms();
            CmsObject onlineCms = OpenCms.initCmsObject(cms);
            m_onlineCms = onlineCms;
            CmsProject online = cms.readProject(CmsProject.ONLINE_PROJECT_NAME);
            onlineCms.getRequestContext().setCurrentProject(online);
            for (CmsResourceImportData resData : getResourceData()) {
                String importPath = CmsModuleUpdater.normalizePath(resData.getResource().getRootPath());
                if (resData.hasStructureId()) {
                    CmsUUID importId = resData.getResource().getStructureId();
                    for (CmsObject cmsToRead : Arrays.asList(cms, onlineCms)) {
                        try {
                            CmsResource resourceFromVfs = cmsToRead.readResource(importPath, CmsResourceFilter.ALL);
                            boolean skipResourceIdCheck = false;
                            if (!resourceFromVfs.getStructureId().equals(importId)) {

                                if (resData.getResource().isFile()
                                    && resourceFromVfs.isFile()
                                    && !containsStructureId(resourceFromVfs.getStructureId())
                                    && !vfsResourceWithStructureId(importId)) {

                                    LOG.info(
                                        "Permitting conflicting id in module update for resource "
                                            + resData.getPath()
                                            + " because the id from the module is not present in the VFS and vice versa.");
                                    m_conflictingIds.put(importId, resourceFromVfs.getStructureId());

                                    // If we have different structure ids, but they don't conflict with anything else in the manifest or VFS,
                                    // we don't compare resource ids. First, because having different resource ids is normal in this scenario, second
                                    // because the resource in the VFS is deleted anyway during the module update.
                                    skipResourceIdCheck = true;

                                } else {

                                    LOG.info(
                                        "Module is not updateable because the same path is mapped to different structure ids in the import and in the VFS: "
                                            + importPath);
                                    return false;
                                }
                            }
                            if (!skipResourceIdCheck
                                && resData.getResource().isFile()
                                && !(resData.getResource().getResourceId().equals(resourceFromVfs.getResourceId()))) {
                                LOG.info(
                                    "Module is not updateable because of a resource id conflict for "
                                        + resData.getResource().getRootPath());
                                return false;
                            }
                        } catch (CmsVfsResourceNotFoundException e) {
                            // ignore
                        }
                    }

                    try {
                        CmsResource vfsResource = cms.readResource(importId, CmsResourceFilter.ALL);
                        if (vfsResource.isFolder() != resData.getResource().isFolder()) {
                            LOG.info(
                                "Module is not updateable because the same id belongs to a file in the import and a folder in the VFS, or vice versa");
                            return false;
                        }
                    } catch (CmsVfsResourceNotFoundException e) {
                        // ignore
                    }
                } else {
                    CmsModule module = getModule();
                    boolean included = false;
                    boolean excluded = false;
                    for (String res : module.getResources()) {
                        if (CmsStringUtil.isPrefixPath(res, resData.getPath())) {
                            included = true;
                            break;
                        }
                    }
                    for (String res : module.getExcludeResources()) {
                        if (CmsStringUtil.isPrefixPath(res, resData.getPath())) {
                            excluded = true;
                            break;
                        }
                    }
                    if (included && !excluded) {
                        LOG.info(
                            "Module is not updateable because one of the resource entries included in the module resources has no structure id in the manifest.");
                        return false;
                    }
                }

            }
            return true;
        } catch (CmsException e) {
            LOG.info("Module is not updateable because of error: " + e.getLocalizedMessage(), e);
            return false;
        }
    }
1160018
private static boolean isSolrSpellcheckIndexDirectoryEmpty() {

        final File path = new File(getSolrSpellcheckRfsPath());
        final File[] directories = path.listFiles(SPELLCHECKING_DIRECTORY_NAME_FILTER);

        // Each directory that has been created by Solr but hasn't been indexed yet
        // contains exactly two files. If there are more files, at least one index has
        // already been built, so return false in that case.
        if (directories != null) {
            for (final File directory : directories) {
                if (directory.list().length > 2) {
                    return false;
                }
            }
        }
        return true;
    }
300020
private boolean checkWriteConfiguration() {

        if ((m_fieldconfiguration != null) || m_fieldconfiguration.getFields().isEmpty()) {
            for (CmsSearchField field : m_fieldconfiguration.getFields()) {
                if (field.getMappings().isEmpty()) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }