Helper method to check whether a given resource is a folder.<p>

@param resource the resouce to check
@return true if the resource is a folder

@throws CmsLoaderException if the resource type couldn't be found
11554
protected static boolean isFolder(CmsResource resource) throws CmsLoaderException {

        I_CmsResourceType resourceType = OpenCms.getResourceManager().getResourceType(resource.getTypeId());
        return resourceType.isFolder();
    }
767859
public static boolean isJavaArtifact(IResource resource) {
        if (resource == null || (resource.getType() != IResource.FILE)) {
            return false;
        }
        String ex = resource.getFileExtension();
        if ("java".equalsIgnoreCase(ex) || "class".equalsIgnoreCase(ex)) {
            return true;
        }
        String name = resource.getName();
        return Archive.isArchiveFileName(name);
    }
1056579
private void deleteResource(CmsResource resource) throws CmsException {

        String path = null;
        CmsObject cms = getCmsObject();
        try {
            path = cms.getSitePath(resource);
            cms.lockResource(path);
            cms.deleteResource(path, CmsResource.DELETE_PRESERVE_SIBLINGS);
            // check if any detail container page resources exist to this resource
            List<CmsResource> detailContainers = CmsDetailOnlyContainerUtil.getDetailOnlyResources(cms, resource);
            for (CmsResource detailContainer : detailContainers) {
                deleteResource(detailContainer);
            }
        } finally {
            try {
                if (path != null) {
                    getCmsObject().unlockResource(path);
                }
            } catch (Exception e) {
                // should really never happen
                LOG.debug(e.getLocalizedMessage(), e);
            }
        }
    }
322336
public static boolean isModelCopyGroup(CmsObject cms, CmsResource resource) {

        boolean result = false;
        if (isModelGroup(resource)) {
            try {
                CmsProperty tempElementsProp = cms.readPropertyObject(
                    resource,
                    CmsPropertyDefinition.PROPERTY_TEMPLATE_ELEMENTS,
                    false);
                if (!tempElementsProp.isNullProperty()
                    && CmsContainerElement.USE_AS_COPY_MODEL.equals(tempElementsProp.getValue())) {
                    result = true;
                }
            } catch (CmsException e) {
                LOG.warn(e.getMessage(), e);
            }

        }
        return result;
    }
99637
protected List<CmsResource> getChildren(CmsResource resource) throws CmsException {

        return m_cms.getSubFolders(resource.getRootPath(), m_filter);
    }
1363073
protected boolean isInvalidResourceName(String resourceName) {

        if (resourceName == null) {
            return true;
        }
        try {

            m_cms.readResource(resourceName);
            return false;
        } catch (CmsException e) {
            //Ok, resource not valid..
        }
        return true;
    }
345117
protected void setResource(CmsObject cms, CmsResource resource) {

        m_resource = CmsJspResourceWrapper.wrap(cms, resource);
    }
451071
public void setType(String typeName) {

        try {
            try {
                m_resourceBuilder.setType(OpenCms.getResourceManager().getResourceType(typeName));
            } catch (@SuppressWarnings("unused") CmsLoaderException e) {
                // TODO: what happens if the resource type is a specialized folder and is not configured??
                try {
                    m_resourceBuilder.setType(
                        OpenCms.getResourceManager().getResourceType(CmsResourceTypePlain.getStaticTypeName()));
                } catch (@SuppressWarnings("unused") CmsLoaderException e1) {
                    // this should really never happen
                    m_resourceBuilder.setType(
                        OpenCms.getResourceManager().getResourceType(CmsResourceTypePlain.getStaticTypeName()));
                }
            }
            if (m_resourceBuilder.getType().isFolder()) {
                // ensure folders end with a "/"
                if (!CmsResource.isFolder(m_destination)) {
                    m_destination += "/";
                }
            }
        } catch (Throwable e) {
            setThrowable(e);
        }
    }
1338327
public static boolean isNavLevelFolder(CmsObject cms, CmsResource resource) {

        if (resource.isFolder()) {
            I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource);
            if (CmsResourceTypeFolder.RESOURCE_TYPE_NAME.equals(type.getTypeName())) {
                try {
                    CmsProperty prop = cms.readPropertyObject(
                        resource,
                        CmsPropertyDefinition.PROPERTY_DEFAULT_FILE,
                        false);
                    return !prop.isNullProperty() && NAVIGATION_LEVEL_FOLDER.equals(prop.getValue());
                } catch (CmsException e) {
                    LOG.debug(e.getMessage(), e);
                }
            }
        }
        return false;
    }
339230
protected static void checkIsFolder(CmsResource resource) throws CmsException {

        if (!isFolder(resource)) {
            throw new CmsIllegalArgumentException(
                Messages.get().container(
                    org.opencms.file.Messages.ERR_REWRITE_LINKS_ROOT_NOT_FOLDER_1,
                    resource.getRootPath()));
        }
    }
367459
public void parse(CmsResource resource) throws CmsException {

        CmsFile file = m_cms.readFile(resource);
        parse(file);
    }
773033
public CmsLocaleGroup readDefaultFileLocaleGroup(CmsResource resource) throws CmsException {

        if (resource.isFolder()) {
            CmsResource defaultFile = m_cms.readDefaultFile(resource, CmsResourceFilter.IGNORE_EXPIRATION);
            if (defaultFile != null) {
                return readLocaleGroup(defaultFile);
            } else {
                LOG.warn("default file not found, reading locale group of folder.");
            }
        }
        return readLocaleGroup(resource);

    }
857961
public CmsResource createFolder(CmsObject cms) throws CmsException {

        if (m_folder != null) {
            return m_folder;
        }
        return cms.createResource(
            m_path,
            OpenCms.getResourceManager().getResourceType(CmsResourceTypeFolder.RESOURCE_TYPE_NAME).getTypeId());
    }
889936
public CmsRelationFilter filterResource(CmsResource resource) {

        CmsRelationFilter filter = filterStructureId(resource.getStructureId());
        filter = filterPath(resource.getRootPath());
        return filter;
    }
955610
public void setTargetForlder(CmsResource resource) {

        if (resource.isFolder()) {
            if (m_context.getResources().size() == 1) {
                try {
                    if (m_dialogMode.equals(DialogMode.copy)
                        | (m_dialogMode.equals(DialogMode.copy_and_move)
                            && CmsResource.getParentFolder(m_context.getResources().get(0).getRootPath()).equals(
                                resource.getRootPath()))) {
                        m_targetPath.setValue(getTargetName(m_context.getResources().get(0), resource));
                    } else {

                        m_targetPath.setValue(
                            getCms().getSitePath(resource) + getTargetName(m_context.getResources().get(0), resource));
                    }
                } catch (CmsException e) {
                    m_targetPath.setValue(getCms().getSitePath(resource));
                }
            } else {
                m_targetPath.setValue(getCms().getSitePath(resource));
            }

            updateDefaultActions(resource.getRootPath());
        } else {
            throw new CmsIllegalArgumentException(
                org.opencms.workplace.commons.Messages.get().container(
                    org.opencms.workplace.commons.Messages.ERR_COPY_MULTI_TARGET_NOFOLDER_1,
                    A_CmsUI.getCmsObject().getSitePath(resource)));
        }
    }
583284
public static boolean hasChildren(CmsObject cms, CmsResource resource) throws CmsException {

        return !cms.getResourcesInFolder(cms.getSitePath(resource), CmsResourceFilter.ALL).isEmpty();
    }
635366
public static boolean isXmlContent(CmsResource resource) {

        boolean result = false;
        if (resource != null) {
            // avoid array index out of bound exception:
            if (!resource.isFolder()) {
                result = OpenCms.getResourceManager().getResourceType(resource) instanceof CmsResourceTypeXmlContent;
            }
        }
        return result;
    }