Internal configuration lookup method.<p>

@param cms the cms context
@param rootPath the root path for which to look up the configuration

@return the configuration for the given path
353166
protected CmsADEConfigData internalLookupConfiguration(CmsObject cms, String rootPath) {

        boolean online = (null == cms) || isOnline(cms);
        CmsADEConfigCacheState state = getCacheState(online);
        return state.lookupConfiguration(rootPath);
    }
1310544
protected List<CmsResource> getSitemapSubEntryResources(String rootPath) throws CmsException {

        CmsObject rootCms = OpenCms.initCmsObject(getCmsObject());
        List<CmsResource> result = new ArrayList<CmsResource>();
        rootCms.getRequestContext().setSiteRoot("");
        CmsJspNavBuilder navBuilder = new CmsJspNavBuilder(rootCms);
        for (CmsJspNavElement navElement : navBuilder.getNavigationForFolder(
            rootPath,
            Visibility.all,
            CmsResourceFilter.ONLY_VISIBLE)) {
            if ((navElement != null) && navElement.isInNavigation()) {
                result.add(navElement.getResource());
            }
        }
        return result;
    }
1239216
private String getAvailableLocalVariant(CmsObject cms, String path, String baseName) {

        A_CmsUI.get();
        List<String> localVariations = CmsLocaleManager.getLocaleVariants(
            baseName,
            UI.getCurrent().getLocale(),
            false,
            true);

        for (String name : localVariations) {
            if (cms.existsResource(path + name)) {
                return name;
            }
        }
        return null;
    }
767214
public static void createFolder(CmsObject cms, String rootPath) throws CmsException {

        CmsObject rootCms = OpenCms.initCmsObject(cms);
        rootCms.getRequestContext().setSiteRoot("");
        List<String> parents = new ArrayList<String>();
        String currentPath = rootPath;
        while (currentPath != null) {
            if (rootCms.existsResource(currentPath)) {
                break;
            }
            parents.add(currentPath);
            currentPath = CmsResource.getParentFolder(currentPath);
        }
        parents = Lists.reverse(parents);
        for (String parent : parents) {
            try {
                rootCms.createResource(
                    parent,
                    OpenCms.getResourceManager().getResourceType(CmsResourceTypeFolder.getStaticTypeName()));
                try {
                    rootCms.unlockResource(parent);
                } catch (CmsException e) {
                    // may happen if parent folder is locked also
                    if (LOG.isInfoEnabled()) {
                        LOG.info(e);
                    }
                }
            } catch (CmsVfsResourceAlreadyExistsException e) {
                // nop
            }
        }
    }
945013
public CmsPermissionInfo getPermissionInfo(CmsObject cms, CmsResource resource, String contextPath)
    throws CmsException {

        boolean hasView = cms.hasPermissions(
            resource,
            CmsPermissionSet.ACCESS_VIEW,
            false,
            CmsResourceFilter.ALL.addRequireVisible());
        boolean hasWrite = false;
        if (hasView) {
            try {
                I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource.getTypeId());
                CmsExplorerTypeSettings settings = OpenCms.getWorkplaceManager().getExplorerTypeSetting(
                    type.getTypeName());
                hasView = (settings == null)
                    || settings.getAccess().getPermissions(cms, resource).requiresViewPermission();
                if (hasView
                    && CmsResourceTypeXmlContent.isXmlContent(resource)
                    && !CmsResourceTypeXmlContainerPage.isContainerPage(resource)) {
                    if (contextPath == null) {
                        contextPath = resource.getRootPath();
                    }
                    CmsResourceTypeConfig localConfigData = lookupConfiguration(cms, contextPath).getResourceType(
                        type.getTypeName());
                    if (localConfigData != null) {
                        Map<CmsUUID, CmsElementView> elmenetViews = getElementViews(cms);
                        hasView = elmenetViews.containsKey(localConfigData.getElementView())
                            && elmenetViews.get(localConfigData.getElementView()).hasPermission(cms, resource);
                    }
                }
                // the user may only have write permissions if he is allowed to view the resource
                hasWrite = hasView
                    && cms.hasPermissions(
                        resource,
                        CmsPermissionSet.ACCESS_WRITE,
                        false,
                        CmsResourceFilter.IGNORE_EXPIRATION)
                    && ((settings == null)
                        || settings.getAccess().getPermissions(cms, resource).requiresWritePermission());
            } catch (CmsLoaderException e) {
                LOG.warn(e.getLocalizedMessage(), e);
                hasWrite = false;
            }
        }

        String noEdit = new CmsResourceUtil(cms, resource).getNoEditReason(
            OpenCms.getWorkplaceManager().getWorkplaceLocale(cms),
            true);
        return new CmsPermissionInfo(hasView, hasWrite, noEdit);
    }
299020
public CmsSitemapTreeItem getTreeItem(String path) {

        CmsSitemapData data = m_controller.getData();
        CmsClientSitemapEntry root = data.getRoot();
        String rootSitePath = root.getSitePath();
        String remainingPath = path.substring(rootSitePath.length());

        CmsSitemapTreeItem result = getRootItem();

        String[] names = CmsStringUtil.splitAsArray(remainingPath, "/");
        for (String name : names) {
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) {
                continue;
            }
            result = (CmsSitemapTreeItem)result.getChild(name);
            if (result == null) {
                return null;
            }
        }
        return result;

    }
1003208
public static String getParentFolderTokens(String rootPath) {

        if (CmsStringUtil.isEmpty(rootPath)) {
            return "/";
        }
        StringBuffer result = new StringBuffer(128);
        String folderName = CmsResource.getFolderPath(rootPath);
        for (int i = 0; i < folderName.length(); i++) {
            char c = folderName.charAt(i);
            if (c == '/') {
                if (result.length() > 0) {
                    result.append(' ');
                }
                result.append(folderName.substring(0, i + 1));
            }
        }
        return result.toString();
    }
903218
private String getTargetSiteRoot(CmsObject cms, String path, String basePath) {

        if (OpenCms.getSiteManager().startsWithShared(path) || path.startsWith(CmsWorkplace.VFS_PATH_SYSTEM)) {
            return null;
        }
        String targetSiteRoot = OpenCms.getSiteManager().getSiteRoot(path);
        if ((targetSiteRoot == null) && (basePath != null)) {
            targetSiteRoot = OpenCms.getSiteManager().getSiteRoot(basePath);
        }
        if (targetSiteRoot == null) {
            targetSiteRoot = cms.getRequestContext().getSiteRoot();
        }
        return targetSiteRoot;
    }
533822
public void initRoot(CmsObject cms, CmsResource root) {

        addTreeItem(cms, root, null);
        readTreeLevel(cms, root.getStructureId());
    }
841922
public CmsTool resolveAdminTool(String rootKey, String toolPath) {

        return m_tools.getObject(rootKey + ROOT_SEPARATOR + toolPath);
    }
1113595
public static CmsFlexBucketConfiguration loadFromVfsFile(CmsObject cms, String path) throws CmsException {

        if (!cms.existsResource(path)) {
            return null;
        }
        CmsResource configRes = cms.readResource(path);
        if (configRes.isFolder()) {
            return null;
        }
        CmsFile configFile = cms.readFile(configRes);
        String encoding = CmsFileUtil.getEncoding(cms, configRes);
        Properties props = new Properties();
        try {
            props.load(new InputStreamReader(new ByteArrayInputStream(configFile.getContents()), encoding));
            return loadFromProperties(props);
        } catch (IOException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
        return null;
    }
210380
public CmsContainerPageBean transformContainerpageBean(CmsObject cms, CmsContainerPageBean input, String rootPath) {

        CmsTemplateMapperConfiguration config = getConfiguration(cms);
        if ((config == null) || !config.isEnabledForPath(rootPath)) {
            return input;
        }
        List<CmsContainerBean> newContainers = new ArrayList<>();
        for (CmsContainerBean container : input.getContainers().values()) {
            List<CmsContainerElementBean> elements = container.getElements();
            List<CmsContainerElementBean> newElements = new ArrayList<>();
            for (CmsContainerElementBean element : elements) {
                CmsContainerElementBean newElement = transformContainerElement(cms, config, element);
                if (newElement != null) {
                    newElements.add(newElement);
                }
            }
            CmsContainerBean newContainer = new CmsContainerBean(
                container.getName(),
                container.getType(),
                container.getParentInstanceId(),
                container.isRootContainer(),
                newElements);
            newContainers.add(newContainer);
        }
        CmsContainerPageBean result = new CmsContainerPageBean(newContainers);
        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;

    }
427032
private List<CmsResource> getVirtualResourcesForRoot(CmsObject cms) throws CmsException {

        CmsResource resource = createFakeFolder(BASE_PATH);
        return Arrays.asList(resource);
    }
92335
protected Component getResourceComponent(String path) {

        try {
            CmsPathSelectField field = new CmsPathSelectField();
            field.setUseRootPaths(true);
            CmsObject cms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
            cms.getRequestContext().setSiteRoot("");
            field.setCmsObject(cms);
            if (path != null) {
                field.setValue(path);
            }
            return field;
        } catch (CmsException e) {
            //
        }
        return null;
    }
423009
public static URL getStaticResourceURL(String resourcePath) {

        URL resourceURL = null;
        if (isStaticResourceUri(resourcePath)) {
            String path = removeStaticResourcePrefix(resourcePath);
            path = CmsStringUtil.joinPaths(OPENCMS_PATH_PREFIX, path);
            resourceURL = OpenCms.getSystemInfo().getClass().getClassLoader().getResource(path);
        }
        return resourceURL;
    }
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;
        }
    }