/** * Maps a path to a repository. * * @param path URI * @return repository denoted by the provided URI. */ public static String mapPathToRepository(String path) { String workspaceName = getURI2RepositoryManager().getRepository(path); if (StringUtils.isEmpty(workspaceName)) { workspaceName = DEFAULT_REPOSITORY; } return workspaceName; }
/** * Parses provided URI to the link. * * @param link URI representing path to piece of content * @return Link pointing to the content represented by provided URI */ public static Link parseLink(String link) throws LinkException { // ignore context handle if existing link = StringUtils.removeStart(link, MgnlContext.getContextPath()); Matcher matcher = LINK_PATTERN.matcher(link); if (matcher.matches()) { String orgHandle = matcher.group(1); orgHandle = Components.getComponent(I18nContentSupport.class).toRawURI(orgHandle); String workspaceName = getURI2RepositoryManager().getRepository(orgHandle); String handle = getURI2RepositoryManager().getHandle(orgHandle); return createLinkInstance(workspaceName, handle, matcher.group(3), matcher.group(5), matcher.group(7)); } throw new LinkException("can't parse [ " + link + "]"); }