Returns the folder if it already exists, or null if it doesn't.<p>

@param cms the current CMS context

@return the folder if it exists, else null

@throws CmsException if something goes wrong
556112
public CmsResource getFolder(CmsObject cms) throws CmsException {

        if (m_folder != null) {
            return m_folder;
        }
        try {
            CmsResource folder = cms.readResource(m_path);
            return folder;
        } catch (CmsVfsResourceNotFoundException e) {
            return null;
        }
    }
416493
private CmsObject getOnlineCmsObject(CmsObject cms) {

        CmsObject res = null;
        try {
            res = OpenCms.initCmsObject(cms);
            res.getRequestContext().setCurrentProject(cms.readProject(CmsProject.ONLINE_PROJECT_ID));
        } catch (CmsException e) {
            LOG.error("Cannot create CmsObject", e);
        }
        return res;
    }
473240
public static CmsResource readResource(CmsObject cms, CmsHistoryResourceBean bean) throws CmsException {

        CmsHistoryVersion versionBean = bean.getVersion();
        if (versionBean.getVersionNumber() != null) {
            return (CmsResource)(cms.readResource(bean.getStructureId(), versionBean.getVersionNumber().intValue()));
        } else {
            if (versionBean.isOnline()) {
                CmsObject onlineCms = OpenCms.initCmsObject(cms);
                onlineCms.getRequestContext().setCurrentProject(cms.readProject(CmsProject.ONLINE_PROJECT_ID));
                return onlineCms.readResource(bean.getStructureId(), CmsResourceFilter.IGNORE_EXPIRATION);
            } else {
                return cms.readResource(bean.getStructureId(), CmsResourceFilter.IGNORE_EXPIRATION);
            }
        }
    }
641681
public CmsFile getFile() {

        if ((m_file == null) && !isFolder()) {
            try {
                m_file = m_cms.readFile(this);
            } catch (CmsException e) {
                // this should not happen since we are updating from a resource object
            }
        }
        return m_file;
    }
11554
protected static boolean isFolder(CmsResource resource) throws CmsLoaderException {

        I_CmsResourceType resourceType = OpenCms.getResourceManager().getResourceType(resource.getTypeId());
        return resourceType.isFolder();
    }
234214
public CmsObjectWrapper getCms(SrvSession session, TreeConnection connection) throws CmsException {

        String userName = session.getClientInformation().getUserName();
        userName = CmsJlanUsers.translateUser(userName);
        CmsContextInfo contextInfo = new CmsContextInfo(m_cms.getRequestContext());
        contextInfo.setUserName(userName);
        CmsObject newCms = OpenCms.initCmsObject(m_cms, contextInfo);
        newCms.getRequestContext().setSiteRoot(getRoot());
        newCms.getRequestContext().setCurrentProject(getProject());
        CmsObjectWrapper result = new CmsObjectWrapper(newCms, getWrappers());
        result.setAddByteOrderMark(m_addByteOrderMark);
        result.getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE);
        return result;
    }
1151122
public Map<String, String> computeFolderTypes() throws CmsException {

        Map<String, String> folderTypes = Maps.newHashMap();
        // do this first, since folder types from modules should be overwritten by folder types from sitemaps
        if (m_moduleConfiguration != null) {
            folderTypes.putAll(wrap(m_moduleConfiguration).getFolderTypes());
        }

        List<CmsADEConfigDataInternal> configDataObjects = new ArrayList<CmsADEConfigDataInternal>(
            m_siteConfigurationsByPath.values());
        for (CmsADEConfigDataInternal configData : configDataObjects) {
            folderTypes.putAll(wrap(configData).getFolderTypes());
        }
        return folderTypes;
    }
428688
public String launch(CmsObject cms, Map<String, String> parameters) throws CmsException {

        if (Boolean.valueOf(parameters.get("writeLog")).booleanValue()) {
            m_report = new CmsLogReport(cms.getRequestContext().getLocale(), CmsExternalLinksValidator.class);
        }
        validateLinks(cms);
        return "CmsExternLinkValidator.launch(): Links checked.";
    }
35964
private static String getContextRootPath(CmsObject cms, String creationSitemap) {

        String path = null;
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(creationSitemap)) {
            try {
                path = cms.readFolder(creationSitemap).getRootPath();
            } catch (CmsException e) {
                LOG.warn("The provided creation sitemap " + creationSitemap + " is not a VFS folder.", e);
            }
        }
        if (path == null) {
            path = cms.addSiteRoot(cms.getRequestContext().getFolderUri());
        }

        return path;
    }
496598
private CmsObject getAdminCms(CmsObject cms) throws CmsException {

        CmsObject adminCms = OpenCms.initCmsObject(m_adminCms);
        adminCms.getRequestContext().setSiteRoot(cms.getRequestContext().getSiteRoot());
        adminCms.getRequestContext().setRequestTime(cms.getRequestContext().getRequestTime());
        adminCms.getRequestContext().setCurrentProject(cms.getRequestContext().getCurrentProject());
        adminCms.getRequestContext().setEncoding(cms.getRequestContext().getEncoding());
        adminCms.getRequestContext().setUri(cms.getRequestContext().getUri());
        return adminCms;
    }
818722
public static String getNewResourceName(CmsObject cms, String fileName, String folder) {

        String newResname = CmsResource.getName(fileName.replace('\\', '/'));
        newResname = cms.getRequestContext().getFileTranslator().translateResource(newResname);
        newResname = folder + newResname;
        return newResname;
    }
744531
public I_CmsEditHandler getEditHandler(CmsObject cms) {

        String schema = getSchema();

        try {
            CmsXmlContentDefinition contentDefinition = CmsXmlContentDefinition.unmarshal(cms, schema);
            // get the content handler for the resource type to create
            I_CmsXmlContentHandler handler = contentDefinition.getContentHandler();
            return handler.getEditHandler();

        } catch (CmsXmlException e) {
            LOG.error(e.getMessage(), e);
        }
        return null;
    }
905773
private String getProject(CmsObject cms, CmsFavoriteEntry entry) throws CmsException {

        String result = m_projectLabels.get(entry.getProjectId());
        if (result == null) {
            result = cms.readProject(entry.getProjectId()).getName();
            m_projectLabels.put(entry.getProjectId(), result);
        }
        return result;
    }
1011215
CmsObject getRootCms() {

        try {
            if (m_rootCms == null) {

                m_rootCms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
                m_rootCms.getRequestContext().setSiteRoot("");
            }
        } catch (CmsException e) {
            //
        }
        return m_rootCms;

    }
174575
private CmsObject getCmsObject() {

        CmsObject cms;
        try {
            cms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
            //m_cms.getRequestContext().setSiteRoot("");
        } catch (CmsException e) {
            cms = A_CmsUI.getCmsObject();
        }
        return cms;
    }
870388
protected void readFolder(CmsUUID folderId, boolean clearFilter) throws CmsException {

        CmsObject cms = A_CmsUI.getCmsObject();
        if (clearFilter) {
            m_searchField.clear();
        }
        CmsResource folder = cms.readResource(folderId, FOLDERS);
        m_currentFolder = folderId;
        String folderPath = cms.getSitePath(folder);
        if (OpenCms.getSiteManager().isSharedFolder(cms.getRequestContext().getSiteRoot())) {
            folderPath = folderPath.substring(cms.getRequestContext().getSiteRoot().length());
        }
        setPathInfo(folderPath);
        List<CmsResource> childResources = cms.readResources(folder, FILES_N_FOLDERS, false);
        m_fileTable.fillTable(cms, childResources, clearFilter);
        boolean hasFolderChild = false;
        for (CmsResource child : childResources) {
            if (child.isFolder()) {
                hasFolderChild = true;
                break;
            }
        }
        m_treeContainer.setChildrenAllowed(folderId, hasFolderChild);
        String sitePath = folder.getRootPath().equals(cms.getRequestContext().getSiteRoot() + "/") ? "" : folderPath;
        String state = new StateBean(
            cms.getRequestContext().getSiteRoot(),
            sitePath,
            cms.getRequestContext().getCurrentProject().getUuid().toString()).asString();
        if (LOG.isDebugEnabled()) {
            String p = RandomStringUtils.randomAlphanumeric(5) + " readFolder ";
            LOG.debug(p + "siteRoot = " + cms.getRequestContext().getSiteRoot());
            LOG.debug(p + "folder = " + folder.getRootPath());
            LOG.debug(p + "folderPath = " + folderPath);
            LOG.debug(p + "sitePath = " + sitePath);
            LOG.debug(p + "state = " + state);
            LOG.debug(p + "m_currentState = " + m_currentState);
            LOG.debug(p + "m_currentState.asString = " + StateBean.parse(m_currentState).asString());
        }
        if ((m_currentState == null) || !(state).equals(StateBean.parse(m_currentState).asString())) {
            m_currentState = state;
            CmsAppWorkplaceUi.get().changeCurrentAppState(m_currentState);
        }
        m_locationCache.setFileExplorerLocation(cms.getRequestContext().getSiteRoot(), sitePath);
        m_uploadButton.setTargetFolder(folder.getRootPath());
        m_uploadArea.setTargetFolder(folder.getRootPath());
        if (!m_fileTree.isExpanded(folderId)) {
            expandCurrentFolder();
        }
        if (!m_fileTree.isSelected(folderId)) {
            m_fileTree.select(folderId);
        }
    }
317150
public String getSiteTitle(CmsObject cms, CmsResource resource) throws CmsException {

        String title = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue();
        if (title == null) {
            title = resource.getRootPath();
        }
        if (resource.getRootPath().equals(getSharedFolder())) {
            title = SHARED_FOLDER_TITLE;
        }
        return title;
    }