/** * Gets the initial value for the 'default location' option.<p> * * @param folderResource the current folder * * @return the initial value for the option */ private Boolean getInitialValueForUseDefaultLocationOption(CmsResource folderResource) { String rootPath = folderResource.getRootPath(); return Boolean.valueOf(OpenCms.getSiteManager().getSiteForRootPath(rootPath) != null); }
/** * Gets the main translation locale configured for the given root path.<p> * * @param rootPath a root path * * @return the main translation locale configured for the given path, or null if none was found */ public Locale getMainLocale(String rootPath) { CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(rootPath); if (site == null) { return null; } return site.getMainTranslationLocale(null); }
/** * Sets a site parameter and writes back the updated system configuration.<p> * * @param siteRoot the root path used to identify the site * * @param key the parameter key * @param value the parameter value */ public void setSiteParam(String siteRoot, String key, String value) { CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(siteRoot); if (site == null) { throw new IllegalArgumentException("No site found for path: " + siteRoot); } else { site.getParameters().put(key, value); OpenCms.writeConfiguration(CmsSystemConfiguration.class); } }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#matches(org.opencms.file.CmsObject, org.opencms.workplace.explorer.CmsResourceUtil[]) */ public boolean matches(CmsObject cms, CmsResourceUtil[] resourceUtil) { CmsSite currentSite = OpenCms.getSiteManager().getSiteForRootPath(cms.getRequestContext().getSiteRoot()); CmsSite resourceSite = OpenCms.getSiteManager().getSiteForRootPath(resourceUtil[0].getResource().getRootPath()); return (currentSite != null) && (resourceSite != null) && (currentSite != resourceSite); }
CmsSite result = getSiteForRootPath(rootPath); if (result == null) { result = getSiteForSiteRoot(fallbackSiteRoot);
CmsSite result = getSiteForRootPath(rootPath); if (result == null) { result = getSiteForSiteRoot(fallbackSiteRoot);
/** * Returns true if this is a potential group head, i.e. the locale of the primary resource is the main translation locale configured for the site * in which it is located.<p> * * @return true if this is a potential group head */ public boolean isPotentialGroupHead() { CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(m_primaryResource.getRootPath()); if (site == null) { return false; } Locale mainLocale = site.getMainTranslationLocale(null); if (mainLocale == null) { return false; } Locale primaryLocale = getMainLocale(); return mainLocale.equals(primaryLocale); }
CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(currentResource.getRootPath()); List<Locale> secondaryLocales = Lists.newArrayList(); Locale mainLocale = null;
CmsPropertyDefinition.PROPERTY_EXPORTNAME, false).getValue(); CmsSite site = sm.getSiteForRootPath(foldername); if (exportname != null) { if (exportname.charAt(exportname.length() - 1) != '/') {
/** * Checks whether the given detail page is valid for the given resource.<p> * * @param cms the CMS context * @param page the detail page * @param detailRes the detail resource * * @return true if the given detail page is valid */ protected boolean isValidDetailPage(CmsObject cms, CmsResource page, CmsResource detailRes) { if (OpenCms.getSystemInfo().isRestrictDetailContents()) { // in 'restrict detail contents mode', do not allow detail contents from a real site on a detail page of a different real site CmsSite pageSite = OpenCms.getSiteManager().getSiteForRootPath(page.getRootPath()); CmsSite detailSite = OpenCms.getSiteManager().getSiteForRootPath(detailRes.getRootPath()); if ((pageSite != null) && (detailSite != null) && !pageSite.getSiteRoot().equals(detailSite.getSiteRoot())) { return false; } } return OpenCms.getADEManager().isDetailPage(cms, page); } }
/** * @see org.opencms.ui.components.fileselect.A_CmsFileSelectField#setResourceValue(org.opencms.file.CmsResource) */ @Override protected void setResourceValue(CmsResource resource) { CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(resource.getRootPath()); if (!m_useRootPaths && (site != null) && A_CmsUI.getCmsObject().getRequestContext().getSiteRoot().equals(site.getSiteRoot())) { setValue(true, A_CmsUI.getCmsObject().getSitePath(resource)); } else { setValue(true, resource.getRootPath()); } }
CmsSite errorSite = OpenCms.getSiteManager().getSiteForRootPath(rootPath); cms.getRequestContext().setSiteRoot(errorSite.getSiteRoot()); String relPath = cms.getRequestContext().removeSiteRoot(rootPath);
/** * Returns the workplace link.<p> * * @param cms the cms context * @param resourceRootFolder the resource folder root path * * @return the workplace link */ public static String getVaadinWorkplaceLink(CmsObject cms, String resourceRootFolder) { CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(resourceRootFolder); String siteRoot = site != null ? site.getSiteRoot() : OpenCms.getSiteManager().startsWithShared(resourceRootFolder) ? OpenCms.getSiteManager().getSharedFolder() : ""; String link = getFileExplorerLink(cms, siteRoot) + cms.getRequestContext().removeSiteRoot(resourceRootFolder); return link; }
CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(path); if (site != null) {
try { CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(resource.getRootPath()); if (site != null) { newCms = OpenCms.initCmsObject(cms);
try { if (CmsStringUtil.isPrefixPath(CmsResource.VFS_FOLDER_SITES, path) || (OpenCms.getSiteManager().getSiteForRootPath(path) != null)) { cms = OpenCms.initCmsObject(cms); cms.getRequestContext().setSiteRoot("");
/** * Creates a new sitemap generator instance.<p> * * @param folderRootPath the root folder for the XML sitemap to generate * * @throws CmsException if something goes wrong */ public CmsXmlSitemapGenerator(String folderRootPath) throws CmsException { m_baseFolderRootPath = CmsFileUtil.removeTrailingSeparator(folderRootPath); m_guestCms = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest()); m_siteGuestCms = OpenCms.initCmsObject(m_guestCms); CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(CmsStringUtil.joinPaths(folderRootPath, "/")); m_siteRoot = site.getSiteRoot(); m_siteGuestCms.getRequestContext().setSiteRoot(m_siteRoot); m_baseFolderSitePath = CmsStringUtil.joinPaths( "/", m_siteGuestCms.getRequestContext().removeSiteRoot(m_baseFolderRootPath)); }
CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(file.getRootPath()); if (site != null) { newCms = OpenCms.initCmsObject(cms);
CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(rootPath);
/** * @see org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapService#prepareReloadSitemap(org.opencms.util.CmsUUID, org.opencms.ade.sitemap.shared.CmsSitemapData.EditorMode) */ public String prepareReloadSitemap(CmsUUID rootId, EditorMode mode) throws CmsRpcException { try { CmsObject cms = getCmsObject(); CmsResource res = cms.readResource(CmsADEManager.PATH_SITEMAP_EDITOR_JSP); CmsResource target = cms.readResource(rootId, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED); String targetRootPath = OpenCms.getADEManager().getSubSiteRoot(cms, target.getRootPath()); CmsSite targetSite = OpenCms.getSiteManager().getSiteForRootPath(targetRootPath); CmsADESessionCache.getCache(getRequest(), getCmsObject()).setSitemapEditorMode(mode); if (targetSite != null) { cms.getRequestContext().setSiteRoot(targetSite.getSiteRoot()); String path = cms.getRequestContext().removeSiteRoot(targetRootPath); String link = OpenCms.getLinkManager().substituteLink(cms, res); link = link + "?path=" + path; return link; } return null; } catch (Exception e) { error(e); return null; } }