Gets site root level path of a site.
@param resource Resource within the site
@return Site root path for the site. The path is not checked for validness.
167599
public String getRootPath(Resource resource) {
    int rootLevel = urlHandlerConfig.getSiteRootLevel(resource);
    if (rootLevel > 0) {
      return Path.getAbsoluteParent(resource.getPath(), rootLevel, resource.getResourceResolver());
    }
    return null;
  }
637108
public function getPath()
    {
        $path = parent::getPath();
        if ('' == $path)
        {
            $path = '/';
        }
        if ($this->siteRoot)
        {
            $path = substr($path, strlen($this->siteRoot));
        }
        return $path;
    }
640082
protected static String getAbsoluteUrl(String resource) {
        if (resource.startsWith("/" + WonderPush.API_VERSION)) {
            resource = resource.substring(1 + WonderPush.API_VERSION.length());
        }
        return WonderPush.getBaseURL() + resource;
    }
472978
private static String getRootPath(final String locationPattern) {

        int rootDirEnd = locationPattern.length();

        while (AntPathMatcher.isPattern(locationPattern.substring(0, rootDirEnd))) {
            rootDirEnd = locationPattern.lastIndexOf('/', rootDirEnd - 2) + 1;
        }
        return locationPattern.substring(0, rootDirEnd);
    }
692828
public static URL getResourceUrl(String resource, Class<?> baseClass) {
		return ResourceUtil.getResource(resource, baseClass);
	}
687767
public function get(
        $root = null,
        $siteId = null,
        $pages = null,
        $pageType = null,
        $pageName = null
    ) {
        if (empty($root)) {
            $root = self::RESOURCE_SITES;
        }

        if (empty($siteId)) {
            return $root;
        }

        if (empty($pages)) {
            return $root . '.' . $siteId;
        }

        if (empty($pageType) || empty($pageName)) {
            return $root . '.' . $siteId . '.' . $pages;
        }

        return $root . '.' . $siteId . '.' . $pages . '.' . $pageType . '.' . $pageName;
    }
214273
protected void findRoot(Collection<CmsResource> resources) throws CmsException {

        m_commonRoot = getCommonSite(resources);
        String commonPath = getCommonAncestorPath(resources);
        try {
            m_rootResource = m_cms.readResource(m_commonRoot, m_filter);
        } catch (CmsVfsResourceNotFoundException e) {
            String currentPath = commonPath;
            String lastWorkingPath = null;
            while (m_cms.existsResource(currentPath, m_filter)) {
                lastWorkingPath = currentPath;
                currentPath = CmsResource.getParentFolder(currentPath);
            }
            m_rootResource = m_cms.readResource(lastWorkingPath, m_filter);
            m_commonRoot = lastWorkingPath;
        }
        m_knownResources.add(m_rootResource);
    }
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;
    }
801877
public String getSiteString (int siteId)
    {
        checkReloadSites();
        Site site = _sitesById.get(siteId);
        if (site == null) {
            site = _sitesById.get(_defaultSiteId);
        }
        return (site == null) ? DEFAULT_SITE_STRING : site.siteString;
    }
656657
static String root(final ResourcePath path) {
        if (path.getDepth() == 1)
            return path.getResourcePath();
        throw new JaxRxException(404, "Resource not found: " + path);
    }
1357338
public static String getRootRelativePath(String url) {

		Matcher matcher = URL_SEPARATOR_PATTERN.matcher(url);
		StringBuffer result = new StringBuffer();
		boolean first = true;
		while (matcher.find()) {
			if (first) {
				matcher.appendReplacement(result, "");
				first = false;
			} else {
				matcher.appendReplacement(result, ROOT_REPLACE_PATTERN);
			}
		}

		return result.toString();
	}
544122
Path getRootDirectory()
  {
    Path rawRoot = config().get("baratine.root", Path.class, 
                                Paths.get("/tmp/baratine"));

    return rawRoot;
  }
197195
public static String getPathToChild(Resource file, Resource dir) {
	if (dir == null || !file.getResourceProvider().getScheme().equals(dir.getResourceProvider().getScheme())) return null;
	boolean isFile = file.isFile();
	String str = "/";
	while (file != null) {
	    if (file.equals(dir)) {
		if (isFile) return str.substring(0, str.length() - 1);
		return str;
	    }
	    str = "/" + file.getName() + str;
	    file = file.getParentResource();
	}
	return null;
    }
1322559
private String lookupAdditionalSite(String rootPath) {

        for (int i = 0, size = m_additionalSiteRoots.size(); i < size; i++) {
            String siteRoot = m_additionalSiteRoots.get(i);
            if (rootPath.startsWith(siteRoot + "/")) {
                return siteRoot;
            }
        }
        return null;
    }
930352
public static String getCategoryPath(String rootPath, String baseFolder) throws CmsException {

        String base;
        if (rootPath.startsWith(CmsCategoryService.CENTRALIZED_REPOSITORY)) {
            base = CmsCategoryService.CENTRALIZED_REPOSITORY;
        } else {
            base = baseFolder;
            if (!base.endsWith("/")) {
                base += "/";
            }
            if (!base.startsWith("/")) {
                base = "/" + base;
            }
            int pos = rootPath.indexOf(base);
            if (pos < 0) {
                throw new CmsDataAccessException(
                    Messages.get().container(Messages.ERR_CATEGORY_INVALID_LOCATION_1, rootPath));
            }
            base = rootPath.substring(0, pos + base.length());
        }
        return rootPath.substring(base.length());
    }
461874
public @Nullable String getLinkRootPath(@NotNull Page page, @NotNull String linkTypeId) {
    if (StringUtils.equals(linkTypeId, InternalLinkType.ID)) {
      // inside an experience fragment it does not make sense to use a site root path
      if (Path.isExperienceFragmentPath(page.getPath())) {
        return DEFAULT_ROOT_PATH_CONTENT;
      }
      return AdaptTo.notNull(page.getContentResource(), SiteRoot.class).getRootPath(page);
    }
    else if (StringUtils.equals(linkTypeId, InternalCrossContextLinkType.ID)) {
      return DEFAULT_ROOT_PATH_CONTENT;
    }
    else if (StringUtils.equals(linkTypeId, MediaLinkType.ID)) {
      return DEFAULT_ROOT_PATH_MEDIA;
    }
    return null;
  }
881156
@Nullable
  public static Location getParent(Location location) {
    URI source = location.toURI();

    // If it is root, return null
    if ("/".equals(source.getPath())) {
      return null;
    }

    URI resolvedParent = URI.create(source.toString() + "/..").normalize();
    return location.getLocationFactory().create(resolvedParent);
  }