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

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

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

Text.isDescendant介绍

[英]Determines if the descendant path is hierarchical a descendant of path.
[中]确定descendant路径是否是path的后代。

代码示例

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

private void verifyHierarchy(@NotNull String path) throws CommitFailedException {
  if (!Text.isDescendant(userRootPath, path)) {
    String msg = "Attempt to create a token (or it's parent) outside of configured scope " + path;
    throw constraintViolation(64, msg);
  }
}

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

private void verifyHierarchy(@Nonnull String path) throws CommitFailedException {
  if (!Text.isDescendant(userRootPath, path)) {
    String msg = "Attempt to create a token (or it's parent) outside of configured scope " + path;
    throw constraintViolation(64, msg);
  }
}

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

private void verifyHierarchy(@NotNull String path) throws CommitFailedException {
  if (!Text.isDescendant(userRootPath, path)) {
    String msg = "Attempt to create a token (or it's parent) outside of configured scope " + path;
    throw constraintViolation(64, msg);
  }
}

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

private boolean isAncestor(@NotNull String path) {
  return Text.isDescendant(path, supportedPath);
}

代码示例来源: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.jackrabbit/jackrabbit-core

/**
 *
 * @param nodePath the node path
 * @return the node
 * @throws PathNotFoundException if the node does not exist
 * @throws RepositoryException if an error occurs
 */
private NodeImpl getAcNode(String nodePath) throws PathNotFoundException,
    RepositoryException {
  if (Text.isDescendant(acRootPath, nodePath)) {
    return (NodeImpl) session.getNode(nodePath);
  } else {
    // node outside of rep:policy tree -> not handled by this editor.
    return null;
  }
}

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

/**
 *
 * @param nodePath the node path
 * @return the node
 * @throws PathNotFoundException if the node does not exist
 * @throws RepositoryException if an error occurs
 */
private NodeImpl getAcNode(String nodePath) throws PathNotFoundException,
    RepositoryException {
  if (Text.isDescendant(acRootPath, nodePath)) {
    return (NodeImpl) session.getNode(nodePath);
  } else {
    // node outside of rep:policy tree -> not handled by this editor.
    return null;
  }
}

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

@Override
  public boolean childNodeChanged(String name, NodeState before, NodeState after) {
    if (ROOT_PATH.equals(path) || Text.isDescendant(path, PRIVILEGES_PATH)) {
      after.compareAgainstBaseState(before, new PrivilegeDiff(this, name, nodeBuilder.child(name)));
    }
    return true;
  }
}

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

@Override
  public boolean childNodeChanged(String name, NodeState before, NodeState after) {
    if (ROOT_PATH.equals(path) || Text.isDescendant(path, PRIVILEGES_PATH)) {
      after.compareAgainstBaseState(before, new PrivilegeDiff(this, name, nodeBuilder.child(name)));
    }
    return true;
  }
}

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

@Override
  public boolean childNodeChanged(String name, NodeState before, NodeState after) {
    if (ROOT_PATH.equals(path) || Text.isDescendant(path, PRIVILEGES_PATH)) {
      after.compareAgainstBaseState(before, new PrivilegeDiff(this, name, nodeBuilder.child(name)));
    }
    return true;
  }
}

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

/**
 * Build the Group object from the given group node.
 *
 * @param groupNode The new group node.
 * @return An instance of <code>Group</code>.
 * @throws RepositoryException If the node isn't a child of the configured
 * groupsPath-node or if another error occurs.
 */
Group createGroup(NodeImpl groupNode) throws RepositoryException {
  if (groupNode == null || !groupNode.isNodeType(NT_REP_GROUP)) {
    throw new IllegalArgumentException();
  }
  if (!Text.isDescendant(groupsPath, groupNode.getPath())) {
    throw new RepositoryException("Group has to be within the Group Path");
  }
  return doCreateGroup(groupNode);
}

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

/**
 * Build the User object from the given user node.
 *
 * @param userNode The new user node.
 * @return An instance of <code>User</code>.
 * @throws RepositoryException If the node isn't a child of the configured
 * usersPath-node or if another error occurs.
 */
User createUser(NodeImpl userNode) throws RepositoryException {
  if (userNode == null || !userNode.isNodeType(NT_REP_USER)) {
    throw new IllegalArgumentException();
  }
  if (!Text.isDescendant(usersPath, userNode.getPath())) {
    throw new RepositoryException("User has to be within the User Path");
  }
  return doCreateUser(userNode);
}

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

/**
 * Build the Group object from the given group node.
 *
 * @param groupNode The new group node.
 * @return An instance of <code>Group</code>.
 * @throws RepositoryException If the node isn't a child of the configured
 * groupsPath-node or if another error occurs.
 */
Group createGroup(NodeImpl groupNode) throws RepositoryException {
  if (groupNode == null || !groupNode.isNodeType(NT_REP_GROUP)) {
    throw new IllegalArgumentException();
  }
  if (!Text.isDescendant(groupsPath, groupNode.getPath())) {
    throw new RepositoryException("Group has to be within the Group Path");
  }
  return doCreateGroup(groupNode);
}

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

private static TreePermission createTreePermission(@NotNull String path) {
  if (isSupported(path)) {
    return new TestTreePermission(path);
  } else if (Text.isDescendant(path, AbstractCompositeProviderTest.TEST_A_PATH)) {
    return new EmptyTestPermission(path);
  } else {
    return TreePermission.NO_RECOURSE;
  }
}

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

@Test
public void testCreateGroupWithPath() throws Exception {
  UserProvider up = createUserProvider(4);
  // create test user
  Tree group = up.createGroup("authors", "a/b/c");
  assertNotNull(group);
  assertTrue(Text.isDescendant(customGroupPath, group.getPath()));
  String groupPath = customGroupPath + "/a/b/c/authors";
  assertEquals(groupPath, group.getPath());
}

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

@Test
public void testCreateUserWithPath() throws Exception {
  UserProvider up = createUserProvider(1);
  // create test user
  Tree userTree = up.createUser("nadine", "a/b/c");
  assertNotNull(userTree);
  assertTrue(Text.isDescendant(customUserPath, userTree.getPath()));
  String userPath = customUserPath + "/a/b/c/nadine";
  assertEquals(userPath, userTree.getPath());
}

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

public void testCreateGroupWithIntermediatePath() throws RepositoryException, NotExecutableException {
  UserManager umgr = getUserManager(uSession);
  Group testGroup = null;
  try {
    testGroup = umgr.createGroup(getTestPrincipal(), "/any/intermediate/path");
    save(uSession);
    assertTrue(Text.isDescendant(groupsPath + "/any/intermediate/path", ((GroupImpl)testGroup).getNode().getPath()));
  } finally {
    if (testGroup != null) {
      testGroup.remove();
      save(uSession);
    }
  }
}

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

public void testCreateGroup() throws RepositoryException, NotExecutableException {
  UserManager umgr = getUserManager(uSession);
  Group testGroup = null;
  try {
    testGroup = umgr.createGroup(getTestPrincipal());
    save(uSession);
    assertTrue(Text.isDescendant(groupsPath, ((GroupImpl)testGroup).getNode().getPath()));
  } finally {
    if (testGroup != null) {
      testGroup.remove();
      save(uSession);
    }
  }
}

代码示例来源: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));
}

相关文章