本文整理了Java中org.apache.jackrabbit.util.Text.getAbsoluteParent()
方法的一些代码示例,展示了Text.getAbsoluteParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Text.getAbsoluteParent()
方法的具体详情如下:
包路径:org.apache.jackrabbit.util.Text
类名称:Text
方法名:getAbsoluteParent
[英]Returns the nth absolute parent of the path, where n=level.
Example:Text.getAbsoluteParent("/foo/bar/test", 1) == "/foo/bar"
[中]返回路径的第n个绝对父级,其中n=级别。
例子:Text.getAbsoluteParent("/foo/bar/test", 1) == "/foo/bar"
代码示例来源:origin: io.wcm/io.wcm.handler.url
/**
* Gets site root level path of a site.
* @param path Path of page within the site
* @param rootLevel Level of root page
* @return Site root path for the site. The path is not checked for validness.
*/
private String getRootPath(String path, int rootLevel) {
String rootPath = Text.getAbsoluteParent(path, rootLevel);
// strip off everything after first "." - root path may be passed with selectors/extension which is not relevant
if (StringUtils.contains(rootPath, ".")) {
rootPath = StringUtils.substringBefore(rootPath, ".");
}
return rootPath;
}
代码示例来源:origin: io.wcm/io.wcm.config.api
private void addAbsoluteParent(List<String> configurationIds, Resource resource, int absoluteParent) {
String configurationId = Text.getAbsoluteParent(resource.getPath(), absoluteParent);
if (StringUtils.isNotEmpty(configurationId)) {
configurationIds.add(configurationId);
}
}
代码示例来源:origin: io.wcm/io.wcm.caconfig.extensions
/**
* Get absolute parent of given path.
* If the path is below <code>/content/versionhistory</code> or <code>/content/launches</code> the path level is
* adjusted accordingly.
* This is a replacement for {@link com.day.text.Text#getAbsoluteParent(String, int)}.
* @param path Path
* @param parentLevel Parent level
* @param resourceResolver Resource resolver
* @return Absolute parent path or empty string if path is invalid
*/
public static String getAbsoluteParent(String path, int parentLevel, ResourceResolver resourceResolver) {
if (parentLevel < 0) {
return "";
}
int level = parentLevel + getParentLevelOffset(path, resourceResolver);
return Text.getAbsoluteParent(path, level);
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-tools
public ScriptParentResource(ScriptResource scriptResource) {
super(scriptResource.getResourceResolver(), Text.getAbsoluteParent(scriptResource.getPath(), 1), null);
this.scriptResource = scriptResource;
}
代码示例来源:origin: io.wcm/io.wcm.wcm.ui.extjs
@Override
public Page getAbsoluteParent(int level) {
String parentPath = Text.getAbsoluteParent(resource.getPath(), level - 1);
Resource parentResource = resource.getResourceResolver().getResource(parentPath);
if (parentResource != null) {
return parentResource.adaptTo(Page.class);
}
return null;
}
代码示例来源:origin: io.wcm/io.wcm.handler.url
private SiteConfig getSiteConfigForSiteRoot(Resource contextResource) {
if (contextResource == null) {
return null;
}
int siteRootLevel = siteRootDetector.getSiteRootLevel(contextResource);
final String siteRootPath;
if (siteRootLevel >= 0) {
siteRootPath = Text.getAbsoluteParent(contextResource.getPath(), siteRootLevel);
}
else {
siteRootPath = null;
}
// site root cannot be detected? then get SiteConfig directly from resource without any caching
if (StringUtils.isBlank(siteRootPath)) {
return getSiteConfigForResource(contextResource);
}
// get site config for site root resource and cache the result (for a short time)
try {
return siteConfigCache.get(siteRootPath, () -> {
Resource siteRootResource = contextResource.getResourceResolver().getResource(siteRootPath);
return getSiteConfigForResourceCacheable(siteRootResource);
});
}
catch (ExecutionException ex) {
log.warn("Unexpected exception.", ex);
return null;
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public void after() throws Exception {
try {
// revert transient pending changes (that might be invalid)
root.refresh();
// remove the test group and second test user
Authorizable testGroup = getUserManager(root).getAuthorizable(TEST_GROUP_ID);
if (testGroup != null) {
testGroup.remove();
}
Authorizable testUser2 = getUserManager(root).getAuthorizable(TEST_USER2_ID);
if (testUser2 != null) {
testUser2.remove();
}
for (String p : new String[] {SUPPORTED_PATH, SUPPORTED_PATH2, Text.getAbsoluteParent(SUPPORTED_PATH3, 0), UNSUPPORTED_PATH}) {
Tree t = root.getTree(p);
if (t.exists()) {
t.remove();
}
}
root.commit();
} finally {
super.after();
}
}
代码示例来源:origin: apache/jackrabbit-oak
tp = getTreePermission(readOnlyRoot, Text.getAbsoluteParent(SUPPORTED_PATH3, 0), cugPermProvider);
assertSame(TreePermission.NO_RECOURSE, tp);
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testMayContainWithCug() throws Exception {
String cugPath = TreeUtil
.addChild(root.getTree(SUPPORTED_PATH3), "child", NodeTypeConstants.NT_OAK_UNSTRUCTURED).getPath();
createCug(cugPath, EveryonePrincipal.getInstance());
root.commit();
Root readOnlyRoot = getRootProvider().createReadOnlyRoot(root);
TopLevelPaths tlp = new TopLevelPaths(readOnlyRoot);
for (String p : PATHS) {
assertEquals(p, Text.isDescendantOrEqual(p, cugPath), tlp.contains(p));
}
assertTrue(tlp.contains(Text.getAbsoluteParent(SUPPORTED_PATH3, 0)));
assertTrue(tlp.contains(cugPath));
CugPermissionProvider cugPermProvider = createCugPermissionProvider(
ImmutableSet.of(SUPPORTED_PATH, SUPPORTED_PATH2, SUPPORTED_PATH3),
getTestUser().getPrincipal(), EveryonePrincipal.getInstance());
Tree t = readOnlyRoot.getTree(ROOT_PATH);
TreePermission rootTp = cugPermProvider.getTreePermission(t, TreePermission.EMPTY);
assertTrue(rootTp instanceof EmptyCugTreePermission);
TreePermission tp = rootTp;
for (String segm : PathUtils.elements(cugPath)) {
t = t.getChild(segm);
tp = cugPermProvider.getTreePermission(t, tp);
assertCugPermission(tp, Text.isDescendantOrEqual(SUPPORTED_PATH3, t.getPath()));
}
for (String p : new String[] {SUPPORTED_PATH, SUPPORTED_PATH2, UNSUPPORTED_PATH }) {
tp = getTreePermission(readOnlyRoot, p, cugPermProvider);
assertSame(p, TreePermission.NO_RECOURSE, tp);
}
}
内容来源于网络,如有侵权,请联系作者删除!