Return the cms object with the site root set to "/".
@return the cms object with the site root set to "/".
@throws CmsException thrown if initializing the root cms object fails.
10832
private CmsObject getRootCms() throws CmsException {

        if (null == m_rootCms) {
            m_rootCms = OpenCms.initCmsObject(m_cms);
            m_rootCms.getRequestContext().setSiteRoot("");
        }
        return m_rootCms;
    }
1029363
public static function getRoot() {
    if (!isset(self::$root)) {
      try {

        $root = getenv('PSC_CMS');

        if (!empty($root)) {
          return self::$root = new Dir($root);
        }
  
      } catch (\Webforge\Common\System\Exception $e) {}

      throw MissingEnvironmentVariableException::factory('PSC_CMS', 'The variable should reference a directory, where the host-config.php can live. Use trailing slash/backslash.');
    }

    return self::$root;
  }
998372
protected void updateSearchRoot() throws CmsException {

        CmsObject newCms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
        newCms.getRequestContext().setSiteRoot((String)m_siteSelect.getValue());
        m_searchRoot.setCmsObject(newCms);
        m_searchRoot.setValue("/");

    }
937246
public String getFolderPath(CmsObject cms, String pageFolderRootPath) {

        checkInitialized();
        if (m_folderOrName != null) {
            return m_folderOrName.getFolderPath(cms, pageFolderRootPath);
        } else {
            String siteRoot = null;
            if (pageFolderRootPath != null) {
                siteRoot = OpenCms.getSiteManager().getSiteRoot(pageFolderRootPath);
            }
            if (siteRoot == null) {
                siteRoot = cms.getRequestContext().getSiteRoot();
            }
            return CmsStringUtil.joinPaths(siteRoot, CmsADEManager.CONTENT_FOLDER_NAME, m_typeName);
        }
    }
668613
private String getSite(CmsObject cms, CmsFavoriteEntry entry) {

        CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(entry.getSiteRoot());
        Item item = m_sitesContainer.getItem(entry.getSiteRoot());
        if (item != null) {
            return (String)(item.getItemProperty("caption").getValue());
        }
        String result = entry.getSiteRoot();
        if (site != null) {
            if (!CmsStringUtil.isEmpty(site.getTitle())) {
                result = site.getTitle();
            }
        }
        return result;
    }
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;
    }
913029
public List<CmsAlias> getAliasesForSite(CmsObject cms, String siteRoot) throws CmsException {

        return m_securityManager.getAliasesForSite(cms.getRequestContext(), siteRoot);
    }
1137638
public CmsVfsSitemapService getSitemapService() throws CmsException {

        CmsVfsSitemapService svc = new CmsVfsSitemapService();
        CmsObject cms = OpenCms.initCmsObject(m_cms);
        cms.getRequestContext().setSiteRoot("");
        svc.setCms(cms);
        return svc;
    }
253032
public String getPath() {

        String path = getFullPath();
        if (m_relativeTo != null) {
            path = getResource().getRootPath();
            if (path.startsWith(m_relativeTo)) {
                path = path.substring(m_relativeTo.length());
                if (path.length() == 0) {
                    path = ".";
                }
            } else {
                String site = getSite();
                if (path.startsWith(site + "/") || path.equals(site)) {
                    path = path.substring(site.length());
                }
            }
        }
        if (m_abbrevLength > 0) {
            boolean absolute = path.startsWith("/");
            path = CmsStringUtil.formatResourceName(path, m_abbrevLength);
            if (!absolute && path.startsWith("/")) {
                // remove leading '/'
                path = path.substring(1);
            }
        }
        return path;
    }
1300091
private I_CmsSearchIndex getIndex() {

        I_CmsSearchIndex index = null;
        // get the configured index or the selected index
        if (isInitialCall()) {
            // the search form is in the initial state
            // get the configured index
            index = OpenCms.getSearchManager().getIndex(getSettings().getUserSettings().getWorkplaceSearchIndexName());
        } else {
            // the search form is not in the inital state, the submit button was used already or the
            // search index was changed already
            // get the selected index in the search dialog
            index = OpenCms.getSearchManager().getIndex(getJsp().getRequest().getParameter("indexName.0"));
        }
        return index;
    }
825773
public function getCMSTreeTitle()
    {
        $subsite = Subsite::currentSubsite();
        return $subsite ? Convert::raw2xml($subsite->Title) : _t(__CLASS__.'.SITECONTENTLEFT', 'Site Content');
    }
713005
private CmsObject initCmsObject(CmsContextInfo contextInfo) throws CmsException {

        CmsUser user = contextInfo.getUser();
        if (user == null) {
            user = m_securityManager.readUser(null, contextInfo.getUserName());
        }

        CmsProject project = contextInfo.getProject();
        if (project == null) {
            project = m_securityManager.readProject(contextInfo.getProjectName());
        }

        // first create the request context
        CmsRequestContext context = new CmsRequestContext(
            user,
            project,
            contextInfo.getRequestedUri(),
            contextInfo.getRequestMatcher(),
            contextInfo.getSiteRoot(),
            contextInfo.isSecureRequest(),
            contextInfo.getLocale(),
            contextInfo.getEncoding(),
            contextInfo.getRemoteAddr(),
            contextInfo.getRequestTime(),
            m_resourceManager.getFolderTranslator(),
            m_resourceManager.getFileTranslator(),
            contextInfo.getOuFqn());
        context.setDetailResource(contextInfo.getDetailResource());

        // now initialize and return the CmsObject
        return new CmsObject(m_securityManager, context);
    }
1165023
protected CmsObject initCmsObjectFromSession(HttpServletRequest req) throws CmsException {

        String url = req.getRequestURL().toString();
        String p = "[ " + url + " ] ";
        if (LOG.isDebugEnabled()) {
            LOG.debug(p + "Trying to init cms object from session for request \"" + req.toString() + "\".");
        }
        // try to get an OpenCms user session info object for this request
        CmsSessionInfo sessionInfo = m_sessionManager.getSessionInfo(req);

        if (sessionInfo == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug(p + "No session info found.");
            }
            return null;
        }

        // initialize the requested site root
        CmsSite site = getSiteManager().matchRequest(req);

        // a user name is found in the session manager, reuse this user information
        CmsUUID project = sessionInfo.getProject();

        // initialize site root from request
        String siteroot = sessionInfo.getSiteRoot();
        if (siteroot == null) {
            // not sure if this can actually happen?
            LOG.debug(p + "site root from session info was null, determining site root from current request's host");
            siteroot = site.getSiteRoot();
        }
        // initialize user from request
        CmsUser user = m_securityManager.readUser(null, sessionInfo.getUserId());

        if (LOG.isDebugEnabled()) {
            LOG.debug(p + "Initializing cms object with user \"" + user.getName() + "\".");
            LOG.debug(p + "siteRoot = " + siteroot);
        }
        return initCmsObject(req, user, siteroot, project, sessionInfo.getOrganizationalUnitFqn());
    }
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;

    }
803695
private CmsObject getCmsObject() {

        CmsFlexController controller = CmsFlexController.getController(pageContext.getRequest());
        return controller.getCmsObject();

    }
798849
private CmsResource createSiteRootIfNeeded(String siteRoot) throws CmsException {

        CmsResource siteRootResource = null;

        // check if the site root already exists
        try {
            // take the existing site and do not perform any OU related actions
            if (m_cms.existsResource(siteRoot)) {
                siteRootResource = m_cms.readResource(siteRoot);
            } else {
                CmsResource onlineVersion = m_cmsOnline.readResource(siteRoot);
                siteRootResource = m_cms.readResource(onlineVersion.getStructureId());
            }

        } catch (CmsVfsResourceNotFoundException e) {
            // not create a new site folder and the according OU if option is checked checked
            getReport().println(
                Messages.get().container(Messages.RPT_SITE_CREATE_RESOURCES_0),
                I_CmsReport.FORMAT_DEFAULT);
            I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(
                CmsResourceTypeFolderSubSitemap.TYPE_SUBSITEMAP);
            siteRootResource = m_cms.createResource(siteRoot, type);
            CmsProperty folderTitle = new CmsProperty(
                CmsPropertyDefinition.PROPERTY_TITLE,
                m_site.getTitle(),
                m_site.getTitle());
            m_cms.writePropertyObject(siteRoot, folderTitle);

        }
        return siteRootResource;
    }
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());
    }