/** * Returns the site with has the provided site root path, * or <code>null</code> if no configured site has that root path.<p> * * The site root must have the form: * <code>/sites/default</code>.<br> * That means there must be a leading, but no trailing slash.<p> * * @param siteRoot the root path to look up the site for * * @return the site with has the provided site root path, * or <code>null</code> if no configured site has that root path * * @deprecated Use {@link OpenCms#getSiteManager()} to obtain the configured site manager instance, * then use the method with the same name and signature. */ public static CmsSite getSite(String siteRoot) { return OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot); }
/** * Returns the current site for the provided OpenCms user context object.<p> * * In the unlikely case that no site matches with the provided OpenCms user context, * the default site is returned.<p> * * @param cms the OpenCms user context object to check for the site * * @return the current site for the provided OpenCms user context object */ public CmsSite getCurrentSite(CmsObject cms) { CmsSite site = getSiteForSiteRoot(cms.getRequestContext().getSiteRoot()); return (site == null) ? m_defaultSite : site; }
/** * Returns the current site for the provided OpenCms user context object.<p> * * In the unlikely case that no site matches with the provided OpenCms user context, * the default site is returned.<p> * * @param cms the OpenCms user context object to check for the site * * @return the current site for the provided OpenCms user context object */ public CmsSite getCurrentSite(CmsObject cms) { CmsSite site = getSiteForSiteRoot(cms.getRequestContext().getSiteRoot()); return (site == null) ? m_defaultSite : site; }
/** * Returns the site for the given resources root path, * or <code>null</code> if the resources root path does not match any site.<p> * * @param rootPath the root path of a resource * * @return the site for the given resources root path, * or <code>null</code> if the resources root path does not match any site * * @see #getSiteForSiteRoot(String) * @see #getSiteRoot(String) */ public CmsSite getSiteForRootPath(String rootPath) { if ((rootPath.length() > 0) && !rootPath.endsWith("/")) { rootPath = rootPath + "/"; } // most sites will be below the "/sites/" folder, CmsSite result = lookupSitesFolder(rootPath); if (result != null) { return result; } // look through all folders that are not below "/sites/" String siteRoot = lookupAdditionalSite(rootPath); return (siteRoot != null) ? getSiteForSiteRoot(siteRoot) : null; }
/** * Returns the site for the given resources root path, * or <code>null</code> if the resources root path does not match any site.<p> * * @param rootPath the root path of a resource * * @return the site for the given resources root path, * or <code>null</code> if the resources root path does not match any site * * @see #getSiteForSiteRoot(String) * @see #getSiteRoot(String) */ public CmsSite getSiteForRootPath(String rootPath) { // most sites will be below the "/sites/" folder, CmsSite result = lookupSitesFolder(rootPath); if (result != null) { return result; } // look through all folders that are not below "/sites/" String siteRoot = lookupAdditionalSite(rootPath); return (siteRoot != null) ? getSiteForSiteRoot(siteRoot) : null; }
result = getSiteForSiteRoot(fallbackSiteRoot); if (result == null) { result = getDefaultSite();
result = getSiteForSiteRoot(fallbackSiteRoot); if (result == null) { result = getDefaultSite();
/** * Returns the base URI.<p> * * @param req the servlet request * @param cms the CmsObject * * @return the base URI */ private String getBaseUri(HttpServletRequest req, CmsObject cms) { String baseUri = req.getParameter(PARAM_BASE_URI); if (CmsStringUtil.isEmptyOrWhitespaceOnly(baseUri)) { String referer = req.getHeader(HEADER_REFERER_KEY); CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(cms.getRequestContext().getSiteRoot()); if (site != null) { String prefix = site.getServerPrefix(cms, "/") + OpenCms.getStaticExportManager().getVfsPrefix(); if ((referer != null) && referer.startsWith(prefix)) { baseUri = referer.substring(prefix.length()); } } } return baseUri; } }
/** * Returns the base URI.<p> * * @param req the servlet request * @param cms the CmsObject * * @return the base URI */ private String getBaseUri(HttpServletRequest req, CmsObject cms) { String baseUri = req.getParameter(PARAM_BASE_URI); if (CmsStringUtil.isEmptyOrWhitespaceOnly(baseUri)) { String referer = req.getHeader(HEADER_REFERER_KEY); CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(cms.getRequestContext().getSiteRoot()); if (site != null) { String prefix = site.getServerPrefix(cms, "/") + OpenCms.getStaticExportManager().getVfsPrefix(); if ((referer != null) && referer.startsWith(prefix)) { baseUri = referer.substring(prefix.length()); } } } return baseUri; } }
CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot); if (!siteRoot.endsWith("/")) { siteRoot += "/";
/** * @see org.opencms.staticexport.CmsDefaultLinkSubstitutionHandler#getRootPathForSite(org.opencms.file.CmsObject, java.lang.String, java.lang.String, boolean) */ @Override protected String getRootPathForSite(CmsObject cms, String path, String siteRoot, boolean isRootPath) { CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot); if ((site != null) && CmsSite.LocalizationMode.singleTree.equals(site.getLocalizationMode())) { if (isRootPath) { path = path.substring(site.getSiteRoot().length()); } Locale locale = CmsSingleTreeLocaleHandler.getLocaleFromPath(path); if (locale != null) { path = path.substring(locale.toString().length() + 1); } return cms.getRequestContext().addSiteRoot(site.getSiteRoot(), path); } else { return super.getRootPathForSite(cms, path, siteRoot, isRootPath); } }
CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot); if (!siteRoot.endsWith("/")) { siteRoot += "/";
CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(prefix); prefix = getCms().getRequestContext().removeSiteRoot(prefix); prefix = site.getUrl() + OpenCms.getSystemInfo().getOpenCmsContext() + prefix;
/** * Checks whether single locale detail containers should be used for the given site root.<p> * * @param siteRoot the site root to check * * @return <code>true</code> if single locale detail containers should be used for the given site root */ public static boolean useSingleLocaleDetailContainers(String siteRoot) { boolean result = false; if ((siteRoot != null) && (OpenCms.getLocaleManager().getLocaleHandler() instanceof CmsSingleTreeLocaleHandler)) { CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot); result = (site != null) && CmsSite.LocalizationMode.singleTree.equals(site.getLocalizationMode()); } return result; }
/** * @see org.opencms.staticexport.CmsDefaultLinkSubstitutionHandler#prepareExportParameters(org.opencms.file.CmsObject, java.lang.String, java.lang.String) */ @Override protected String prepareExportParameters(CmsObject cms, String vfsName, String parameters) { CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(cms.getRequestContext().getSiteRoot()); if ((site != null) && CmsSite.LocalizationMode.singleTree.equals(site.getLocalizationMode())) { if (!(OpenCms.getSiteManager().startsWithShared(vfsName) || vfsName.startsWith(CmsWorkplace.VFS_PATH_SYSTEM))) { if (parameters != null) { parameters += "&"; } else { parameters = "?"; } parameters += CmsLocaleManager.PARAMETER_LOCALE + "=" + cms.getRequestContext().getLocale().toString(); } } return parameters; } }
CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(prefix); prefix = getCms().getRequestContext().removeSiteRoot(prefix); prefix = site.getUrl() + OpenCms.getSystemInfo().getOpenCmsContext() + prefix;
/** * Prepends the site-root to the given URL.<p> * * @param url the URL * * @return the absolute URL */ private String prependSiteRoot(String url) { String site = getCms().getRequestContext().getSiteRoot(); if (CmsStringUtil.isEmptyOrWhitespaceOnly(site) || OpenCms.getSiteManager().isSharedFolder(site)) { site = OpenCms.getSiteManager().getDefaultUri(); if (CmsStringUtil.isEmptyOrWhitespaceOnly(site) || (OpenCms.getSiteManager().getSiteForSiteRoot(site) == null)) { return OpenCms.getSiteManager().getWorkplaceServer() + url; } else { return OpenCms.getSiteManager().getSiteForSiteRoot(site).getUrl() + url; } } return OpenCms.getSiteManager().getSiteForSiteRoot(site).getUrl() + url; }
&& (OpenCms.getSiteManager().getSiteForSiteRoot(startSiteRoot) == null)) {
CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot); String siteName = null; if (site != null) {
CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot); if (site != null) {