/** * 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 root part for the given resources root path, * or <code>null</code> if the given resources root path does not match any site root.<p> * * The site root returned will have the form: * <code>/sites/default</code>.<br> * That means there will a leading, but no trailing slash.<p> * * @param rootPath the root path of a resource * * @return the site root part of the resources root path, * or <code>null</code> if the path does not match any site root * * @see #getSiteForRootPath(String) */ public String getSiteRoot(String rootPath) { // add a trailing slash, because the path may be the path of a site root itself if (!rootPath.endsWith("/")) { rootPath = rootPath + "/"; } // most sites will be below the "/sites/" folder, CmsSite site = lookupSitesFolder(rootPath); if (site != null) { return site.getSiteRoot(); } // look through all folders that are not below "/sites/" return lookupAdditionalSite(rootPath); }
/** * 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; }
/** * Returns the site root part for the given resources root path, * or <code>null</code> if the given resources root path does not match any site root.<p> * * The site root returned will have the form: * <code>/sites/default</code>.<br> * That means there will a leading, but no trailing slash.<p> * * @param rootPath the root path of a resource * * @return the site root part of the resources root path, * or <code>null</code> if the path does not match any site root * * @see #getSiteForRootPath(String) */ public String getSiteRoot(String rootPath) { // most sites will be below the "/sites/" folder, CmsSite site = lookupSitesFolder(rootPath); if (site != null) { return site.getSiteRoot(); } // look through all folders that are not below "/sites/" return lookupAdditionalSite(rootPath); }