org.apache.jackrabbit.util.Text.getRelativeParent()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中org.apache.jackrabbit.util.Text.getRelativeParent()方法的一些代码示例,展示了Text.getRelativeParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Text.getRelativeParent()方法的具体详情如下:
包路径:org.apache.jackrabbit.util.Text
类名称:Text
方法名:getRelativeParent

Text.getRelativeParent介绍

[英]Returns the nth relative parent of the path, where n=level.

Example:
Text.getRelativeParent("/foo/bar/test", 1) == "/foo/bar"
[中]返回路径的第n个相对父级,其中n=级别。
例子:
Text.getRelativeParent("/foo/bar/test", 1) == "/foo/bar"

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

private MoveEntry(@Nonnull String sourcePath,
           @Nonnull String destPath) {
    this.sourcePath = sourcePath;
    this.destPath = destPath;
    parentSourcePaths.add(Text.getRelativeParent(sourcePath, 1));
    parentDestPaths.add(Text.getRelativeParent(destPath, 1));
  }
}

代码示例来源:origin: apache/jackrabbit-oak

private MoveEntry(@NotNull String sourcePath,
           @NotNull String destPath) {
    this.sourcePath = sourcePath;
    this.destPath = destPath;
    parentSourcePaths.add(Text.getRelativeParent(sourcePath, 1));
    parentDestPaths.add(Text.getRelativeParent(destPath, 1));
  }
}

代码示例来源:origin: apache/jackrabbit

/**
 * Same as {@link #getRelativeParent(String, int)} but adding the possibility
 * to pass paths that end with a trailing '/'
 *
 * @see #getRelativeParent(String, int)
 */
public static String getRelativeParent(String path, int level, boolean ignoreTrailingSlash) {
  if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1) {
    path = path.substring(0, path.length()-1);
  }
  return getRelativeParent(path, level);
}

代码示例来源:origin: com.github.igor-suhorukov/dom-transformation

/**
 * Same as {@link #getRelativeParent(String, int)} but adding the possibility
 * to pass paths that end with a trailing '/'
 *
 * @see #getRelativeParent(String, int)
 */
public static String getRelativeParent(String path, int level, boolean ignoreTrailingSlash) {
  if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1) {
    path = path.substring(0, path.length()-1);
  }
  return getRelativeParent(path, level);
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr-commons

/**
 * Same as {@link #getRelativeParent(String, int)} but adding the possibility
 * to pass paths that end with a trailing '/'
 *
 * @see #getRelativeParent(String, int)
 */
public static String getRelativeParent(String path, int level, boolean ignoreTrailingSlash) {
  if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1) {
    path = path.substring(0, path.length()-1);
  }
  return getRelativeParent(path, level);
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

/**
 * Same as {@link #getRelativeParent(String, int)} but adding the possibility
 * to pass paths that end with a trailing '/'
 *
 * @see #getRelativeParent(String, int)
 */
public static String getRelativeParent(String path, int level, boolean ignoreTrailingSlash) {
  if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1) {
    path = path.substring(0, path.length()-1);
  }
  return getRelativeParent(path, level);
}

代码示例来源:origin: org.apache.jackrabbit/com.springsource.org.apache.jackrabbit.commons

/**
 * Same as {@link #getRelativeParent(String, int)} but adding the possibility
 * to pass paths that end with a trailing '/'
 *
 * @see #getRelativeParent(String, int)
 */
public static String getRelativeParent(String path, int level, boolean ignoreTrailingSlash) {
  if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1) {
    path = path.substring(0, path.length()-1);
  }
  return getRelativeParent(path, level);
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core

void setSearchRoots(String userSearchRoot, String groupSearchRoot) {
  this.userSearchRoot = userSearchRoot;
  this.groupSearchRoot = groupSearchRoot;
  authorizableSearchRoot = userSearchRoot;
  while (!Text.isDescendant(authorizableSearchRoot, groupSearchRoot)) {
    authorizableSearchRoot = Text.getRelativeParent(authorizableSearchRoot, 1);
  }
}

代码示例来源:origin: apache/jackrabbit

void setSearchRoots(String userSearchRoot, String groupSearchRoot) {
  this.userSearchRoot = userSearchRoot;
  this.groupSearchRoot = groupSearchRoot;
  authorizableSearchRoot = userSearchRoot;
  while (!Text.isDescendant(authorizableSearchRoot, groupSearchRoot)) {
    authorizableSearchRoot = Text.getRelativeParent(authorizableSearchRoot, 1);
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.distribution.core

private String getClosestParent(Session session, String path) throws RepositoryException {
  do {
    if (session.nodeExists(path)) {
      return path;
    }
    path = Text.getRelativeParent(path, 1);
  }
  while (path != null && path.length() > 0);
  return null;
}

代码示例来源:origin: org.apache.jackrabbit/oak-core

@Nullable
private User getUser(@NotNull Tree tokenTree) throws RepositoryException {
  String userPath = Text.getRelativeParent(tokenTree.getPath(), 2);
  Authorizable authorizable = userManager.getAuthorizableByPath(userPath);
  if (authorizable != null && !authorizable.isGroup() && !((User) authorizable).isDisabled()) {
    return (User) authorizable;
  } else {
    return null;
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@CheckForNull
private User getUser(@Nonnull Tree tokenTree) throws RepositoryException {
  String userPath = Text.getRelativeParent(tokenTree.getPath(), 2);
  Authorizable authorizable = userManager.getAuthorizableByPath(userPath);
  if (authorizable != null && !authorizable.isGroup() && !((User) authorizable).isDisabled()) {
    return (User) authorizable;
  } else {
    return null;
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Nullable
private User getUser(@NotNull Tree tokenTree) throws RepositoryException {
  String userPath = Text.getRelativeParent(tokenTree.getPath(), 2);
  Authorizable authorizable = userManager.getAuthorizableByPath(userPath);
  if (authorizable != null && !authorizable.isGroup() && !((User) authorizable).isDisabled()) {
    return (User) authorizable;
  } else {
    return null;
  }
}

代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr

public void move(String fromPath, String toPath) throws RepositoryException {
  final String fromParentPath = Text.getRelativeParent(fromPath, 1);
  final boolean appendName = getSession().nodeExists(toPath);
  final String toParentPath = appendName ? toPath : Text.getRelativeParent(toPath, 1);
  final String finalPath = appendName ? toPath + "/" + Text.getName(fromPath) : toPath;
  getSession().move(fromPath, toPath);
  processChanges(fromParentPath, fromPath, toParentPath, finalPath);
}

代码示例来源:origin: apache/jackrabbit

private ZipEntryImportContext(ImportContext context, ZipEntry entry, BoundedInputStream bin, Node contentNode) throws IOException, RepositoryException {
  super(contentNode, Text.getName(makeValidJCRPath(entry.getName(), true)),
      null, bin, context.getIOListener(), getIOManager().getDetector());
  this.entry = entry;
  String path = makeValidJCRPath(entry.getName(), true);
  importRoot = IOUtil.mkDirs(contentNode, Text.getRelativeParent(path, 1), getCollectionNodeType());
}

代码示例来源:origin: io.wcm/io.wcm.wcm.ui.extjs

@Override
public Page getParent(int level) {
 String parentPath = Text.getRelativeParent(resource.getPath(), level);
 Resource parentResource = resource.getResourceResolver().getResource(parentPath);
 if (parentResource != null) {
  return parentResource.adaptTo(Page.class);
 }
 return null;
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
public void afterSuite() throws Exception {
  UserManager userMgr = ((JackrabbitSession) session).getUserManager();
  Authorizable authorizable = userMgr.getAuthorizable(USER);
  if (authorizable != null) {
    authorizable.remove();
  }
  authorizable = userMgr.getAuthorizable(GROUP);
  if (authorizable != null) {
    Node n = session.getNode(Text.getRelativeParent(authorizable.getPath(), 1));
    n.remove();
  }
  session.save();
}

代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr

public void removeItem(String path) throws RepositoryException {
  Item item = getSession().getItem(path);
  if (item.isNode()) {
    new NodeProxy((Node) item).remove();
  } else {
    item.remove();
    processChanges(Text.getRelativeParent(path, 1), path);
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testHasHiddenChild() {
  ImmutableTree parent = (ImmutableTree) TreeUtil.getTree(immutable, Text.getRelativeParent(HIDDEN_PATH, 1));
  assertNotNull(parent);
  assertTrue(parent.hasChild(Text.getName(HIDDEN_PATH)));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testCreateGroup() throws RepositoryException {
  UserProvider up = createUserProvider();
  Tree groupTree = up.createGroup("group1", null);
  assertNotNull(groupTree);
  assertTrue(Text.isDescendant(defaultGroupPath, groupTree.getPath()));
  int level = defaultConfig.getConfigValue(UserConstants.PARAM_DEFAULT_DEPTH, UserConstants.DEFAULT_DEPTH) + 1;
  assertEquals(defaultGroupPath, Text.getRelativeParent(groupTree.getPath(), level));
}

相关文章