Prepares the CmsObject for jumping to this favorite location, and returns the appropriate URL.

@param cms the CmsObject to initialize for jumping to the favorite
@return the link for the favorite location

@throws CmsException if something goes wrong
7799
public String updateContextAndGetFavoriteUrl(CmsObject cms) throws CmsException {

        CmsResourceFilter filter = CmsResourceFilter.IGNORE_EXPIRATION;
        CmsProject project = null;
        switch (getType()) {
            case explorerFolder:
                CmsResource folder = cms.readResource(getStructureId(), filter);
                project = cms.readProject(getProjectId());
                cms.getRequestContext().setSiteRoot(getSiteRoot());
                cms.getRequestContext().setCurrentProject(project);
                String explorerLink = CmsVaadinUtils.getWorkplaceLink()
                    + "#!"
                    + CmsFileExplorerConfiguration.APP_ID
                    + "/"
                    + getProjectId()
                    + "!!"
                    + getSiteRoot()
                    + "!!"
                    + cms.getSitePath(folder);
                return explorerLink;
            case page:
                project = cms.readProject(getProjectId());
                CmsResource target = cms.readResource(getStructureId(), filter);
                CmsResource detailContent = null;
                String link = null;
                cms.getRequestContext().setCurrentProject(project);
                cms.getRequestContext().setSiteRoot(getSiteRoot());
                if (getDetailId() != null) {
                    detailContent = cms.readResource(getDetailId());
                    link = OpenCms.getLinkManager().substituteLinkForUnknownTarget(
                        cms,
                        cms.getSitePath(detailContent),
                        cms.getSitePath(target),
                        false);
                } else {
                    link = OpenCms.getLinkManager().substituteLink(cms, target);
                }
                return link;
            default:
                return null;
        }
    }
350268
private CmsResource getContainerpage(CmsObject cms) throws CmsException {

        String currentUri = cms.getRequestContext().getUri();
        CmsResource containerPage = cms.readResource(currentUri);
        if (!CmsResourceTypeXmlContainerPage.isContainerPage(containerPage)) {
            // container page is used as template
            String cntPagePath = cms.readPropertyObject(
                containerPage,
                CmsPropertyDefinition.PROPERTY_TEMPLATE_ELEMENTS,
                true).getValue("");
            try {
                containerPage = cms.readResource(cntPagePath);
            } catch (CmsException e) {
                if (!LOG.isDebugEnabled()) {
                    LOG.warn(e.getLocalizedMessage());
                }
                LOG.debug(e.getLocalizedMessage(), e);
            }
        }
        return containerPage;
    }
922646
public CmsPublishList getPublishList(CmsObject cms) throws CmsException {

        return m_securityManager.fillPublishList(
            cms.getRequestContext(),
            new CmsPublishList(cms.getRequestContext().getCurrentProject()));
    }
534342
public static String getSiteSelectOptionsStatic(CmsObject cms, Locale locale) {

        List<CmsSite> sites = OpenCms.getSiteManager().getAvailableSites(
            cms,
            true,
            false,
            cms.getRequestContext().getOuFqn());

        StringBuffer resultBuffer = new StringBuffer();
        Iterator<CmsSite> i = sites.iterator();
        int counter = 0;
        while (i.hasNext()) {
            CmsSite site = i.next();
            String siteRoot = site.getSiteRoot();
            if (!siteRoot.endsWith("/")) {
                siteRoot += "/";
            }
            if (counter != 0) {
                resultBuffer.append("|");
            }
            resultBuffer.append(siteRoot).append(":").append(
                CmsWorkplace.substituteSiteTitleStatic(site.getTitle(), locale));
            counter++;
        }

        if (sites.size() < 1) {
            // no site found, assure that at least the current site is shown in the selector
            String siteRoot = cms.getRequestContext().getSiteRoot();
            CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot);
            if (!siteRoot.endsWith("/")) {
                siteRoot += "/";
            }
            String title = "";
            if (site != null) {
                title = site.getTitle();
            }
            resultBuffer.append(siteRoot).append(":").append(title);
        }
        return resultBuffer.toString();
    }
113283
public static CmsResource lookupPage(CmsObject cms, String uri) throws CmsException {

        try {
            CmsResource res = cms.readResource(uri);
            return res;
        } catch (CmsVfsResourceNotFoundException e) {
            String detailName = CmsResource.getName(uri).replaceAll("/$", "");
            CmsUUID detailId = cms.readIdForUrlName(detailName);
            if (detailId != null) {
                return cms.readResource(detailId);
            }
            throw new CmsVfsResourceNotFoundException(
                org.opencms.db.generic.Messages.get().container(
                    org.opencms.db.generic.Messages.ERR_READ_RESOURCE_1,
                    uri));
        }
    }
73042
public List<CmsXmlSitemapUrlBean> generateSitemapBeans() throws CmsException {

        String baseSitePath = m_siteGuestCms.getRequestContext().removeSiteRoot(m_baseFolderRootPath);
        initializeFileData(baseSitePath);
        for (CmsResource resource : getDirectPages()) {
            String sitePath = m_siteGuestCms.getSitePath(resource);
            List<CmsProperty> propertyList = m_siteGuestCms.readPropertyObjects(resource, true);
            String onlineLink = OpenCms.getLinkManager().getOnlineLink(m_siteGuestCms, sitePath);
            boolean isContainerPage = CmsResourceTypeXmlContainerPage.isContainerPage(resource);
            long dateModified = resource.getDateLastModified();
            if (isContainerPage) {
                if (m_computeContainerPageDates) {
                    dateModified = computeContainerPageModificationDate(resource);
                } else {
                    dateModified = -1;
                }
            }
            CmsXmlSitemapUrlBean urlBean = new CmsXmlSitemapUrlBean(
                replaceServerUri(onlineLink),
                dateModified,
                getChangeFrequency(propertyList),
                getPriority(propertyList));
            urlBean.setOriginalResource(resource);
            addResult(urlBean, 3);
            if (isContainerPage) {
                Locale locale = getLocale(resource, propertyList);
                addDetailLinks(resource, locale);
            }
        }

        for (CmsUUID aliasStructureId : m_pageAliasesBelowBaseFolderByStructureId.keySet()) {
            addAliasLinks(aliasStructureId);
        }

        List<CmsXmlSitemapUrlBean> result = new ArrayList<CmsXmlSitemapUrlBean>();
        for (ResultEntry resultEntry : m_resultMap.values()) {
            result.add(resultEntry.getUrlBean());
        }
        return result;
    }
194991
public static I_CmsXmlContentHandler getContentHandlerForResource(CmsObject cms, CmsResource resource)
    throws CmsException {

        return getContentDefinitionForResource(cms, resource).getContentHandler();
    }
898031
public CmsResource getOrCreateFolder(CmsObject cms) throws CmsException {

        CmsResource result = getFolder(cms);
        if (result != null) {
            return result;
        }
        return createFolder(cms);
    }
704888
private CmsContainerPageBean getPage(CmsResource pageResource) throws CmsException {

        CmsContainerPageBean result = null;
        if ((pageResource != null) && CmsResourceTypeXmlContainerPage.isContainerPage(pageResource)) {
            CmsXmlContainerPage xmlContainerPage = CmsXmlContainerPageFactory.unmarshal(m_cms, pageResource, m_request);
            result = xmlContainerPage.getContainerPage(m_cms);
            CmsModelGroupHelper modelHelper = new CmsModelGroupHelper(
                m_cms,
                OpenCms.getADEManager().lookupConfiguration(m_cms, pageResource.getRootPath()),
                CmsJspTagEditable.isEditableRequest(m_request) && (m_request instanceof HttpServletRequest)
                ? CmsADESessionCache.getCache((HttpServletRequest)m_request, m_cms)
                : null,
                CmsContainerpageService.isEditingModelGroups(m_cms, pageResource));
            result = modelHelper.readModelGroups(xmlContainerPage.getContainerPage(m_cms));
        }
        return result;
    }
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;
    }
788234
protected String getPath(CmsClientSitemapEntry entry, String newUrlName) {

        if (newUrlName.equals("")) {
            return entry.getSitePath();
        }
        return CmsResource.getParentFolder(entry.getSitePath()) + newUrlName + "/";
    }
10832
private CmsObject getRootCms() throws CmsException {

        if (null == m_rootCms) {
            m_rootCms = OpenCms.initCmsObject(m_cms);
            m_rootCms.getRequestContext().setSiteRoot("");
        }
        return m_rootCms;
    }
89436
public String getLink(CmsObject cms) {

        if (m_internal) {
            // if we have a local link, leave it unchanged
            // cms may be null for unit tests
            if ((cms == null) || (m_uri.length() == 0) || (m_uri.charAt(0) == '#')) {
                return m_uri;
            }

            checkConsistency(cms);
            //String target = replaceTargetWithDetailPageIfNecessary(cms, m_resource, m_target);
            String target = m_target;
            String uri = computeUri(target, m_query, m_anchor);

            CmsObjectWrapper wrapper = (CmsObjectWrapper)cms.getRequestContext().getAttribute(
                CmsObjectWrapper.ATTRIBUTE_NAME);
            if (wrapper != null) {
                // if an object wrapper is used, rewrite the URI
                m_uri = wrapper.rewriteLink(m_uri);
                uri = wrapper.rewriteLink(uri);
            }

            if ((cms.getRequestContext().getSiteRoot().length() == 0)
                && (cms.getRequestContext().getAttribute(CmsRequestContext.ATTRIBUTE_EDITOR) == null)) {
                // Explanation why this check is required:
                // If the site root name length is 0, this means that a user has switched
                // the site root to the root site "/" in the Workplace.
                // In this case the workplace site must also be the active site.
                // If the editor is opened in the root site, because of this code the links are
                // always generated _with_ server name / port so that the source code looks identical to code
                // that would normally be created when running in a regular site.
                // If normal link processing would be used, the site information in the link
                // would be lost.
                return OpenCms.getLinkManager().substituteLink(cms, uri);
            }

            // get the site root for this URI / link
            // if there is no site root, we either have a /system link, or the site was deleted,
            // return the full URI prefixed with the opencms context
            String siteRoot = getSiteRoot();
            if (siteRoot == null) {
                return OpenCms.getLinkManager().substituteLink(cms, uri);
            }

            if (cms.getRequestContext().getAttribute(CmsRequestContext.ATTRIBUTE_FULLLINKS) != null) {
                // full links should be generated even if we are in the same site
                return OpenCms.getLinkManager().getServerLink(cms, uri);
            }

            // return the link with the server prefix, if necessary
            return OpenCms.getLinkManager().substituteLink(cms, getSitePath(uri), siteRoot);
        } else {

            // don't touch external links
            return m_uri;
        }
    }
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);
            }
        }
    }
717923
protected void parseLinks(CmsObject cms) throws CmsException {

        List<CmsResource> linkParseables = new ArrayList<>();
        for (CmsResourceImportData resData : m_moduleData.getResourceData()) {
            CmsResource importRes = resData.getImportResource();
            if ((importRes != null) && m_importIds.contains(importRes.getStructureId()) && isLinkParsable(importRes)) {
                linkParseables.add(importRes);
            }
        }
        m_report.println(Messages.get().container(Messages.RPT_START_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE);
        CmsImportVersion10.parseLinks(cms, linkParseables, m_report);
        m_report.println(Messages.get().container(Messages.RPT_END_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE);
    }
720820
public String buildResourceList() throws CmsException {

        List resourcesWithProperty = getCms().readResourcesWithProperty(getParamPropertyName());

        return buildResourceList(resourcesWithProperty, false);
    }
603359
public CmsResource getSource(CmsObject cms, CmsResourceFilter filter) throws CmsException {

        try {
            // first look up by id
            return cms.readResource(getSourceId(), filter);
        } catch (CmsVfsResourceNotFoundException e) {
            // then look up by name, but from the root site
            String storedSiteRoot = cms.getRequestContext().getSiteRoot();
            try {
                cms.getRequestContext().setSiteRoot("");
                return cms.readResource(getSourcePath(), filter);
            } finally {
                cms.getRequestContext().setSiteRoot(storedSiteRoot);
            }
        }
    }