org.apache.jackrabbit.oak.api.Tree.exists()方法的使用及代码示例

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

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

Tree.exists介绍

[英]Determine whether this tree has been removed or does not exist otherwise (e.g. caused by a refresh, rebase or commit) or is not visible due to access control restriction or does not exist at all.
[中]确定此树是否已被删除或不存在(例如,由刷新、重定基础或提交引起),或由于访问控制限制而不可见或根本不存在。

代码示例

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

@Nonnull
Tree getTree() {
  if (tree.exists()) {
    return tree;
  } else {
    throw new IllegalStateException("Authorizable " + id + ": underlying tree has been disconnected.");
  }
}

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

/**
 * Returns the tree that contains the restriction of the specified
 * ACE tree.
 *
 * @param aceTree The ACE tree for which the restrictions are being read.
 * @return The tree storing the restriction information.
 */
@Nonnull
protected Tree getRestrictionsTree(@Nonnull Tree aceTree) {
  Tree restrictions = aceTree.getChild(REP_RESTRICTIONS);
  if (!restrictions.exists()) {
    // no rep:restrictions tree -> read from aceTree for backwards compatibility
    restrictions = aceTree;
  }
  return restrictions;
}

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

@Nonnull
private Tree getPrivilegesTree(Root root) throws CommitFailedException {
  Tree privilegesTree = root.getTree(PRIVILEGES_PATH);
  if (!privilegesTree.exists()) {
    throw new CommitFailedException(CONSTRAINT, 44, "Privilege store not initialized.");
  }
  return privilegesTree;
}

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

@Test
public void testReadAccess() {
  Tree ps = testRoot.getTree(PermissionConstants.PERMISSIONS_STORE_PATH);
  assertFalse(ps.exists());
}

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

@Test
public void testGetChild() throws Exception {
  Tree rootTree = testRoot.getTree("/");
  assertTrue(rootTree.exists());
  Tree a = rootTree.getChild("a");
  assertTrue(a.exists());
  Tree b = a.getChild("b");
  assertTrue(b.exists());
  assertTrue(b.getChild("c").exists());
  assertFalse(a.getChild("bb").exists());
}

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

@Test
public void testGetAggregatedPrivilegeNamesMissingAggProperty() {
  when(pTree.exists()).thenReturn(true);
  when(privTree.getChild(KNOWN_PRIV_NAME)).thenReturn(pTree);
  Iterable<String> result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME);
  assertTrue(Iterables.elementsEqual(ImmutableList.of(KNOWN_PRIV_NAME), result));
}

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

@Test
public void testGetPrivilegeNamesNonExistingPrivilegesTree() {
  when(privTree.exists()).thenReturn(false);
  Set<String> names = bitsProvider.getPrivilegeNames(bits);
  assertTrue(names.isEmpty());
}

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

@Test
public void testGetPrivilegeNamesFromCache() {
  when(privTree.exists()).thenReturn(true);
  when(privTree.getChildren()).thenReturn(ImmutableSet.of(pTree));
  Set<String> names = bitsProvider.getPrivilegeNames(bits);
  assertSame(names, bitsProvider.getPrivilegeNames(bits));
}

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

@Test
public void testGetHiddenTree() {
  Tree hidden = parent.getChild(HIDDEN_NAME);
  assertNotNull(hidden);
  assertFalse(hidden.exists());
  assertEquals(0, hidden.getChildrenCount(1));
}

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

@Nullable
private Tree getAclTree(@Nullable String oakPath, @NotNull Tree accessControlledTree) {
  if (Util.isAccessControlled(oakPath, accessControlledTree, ntMgr)) {
    String aclName = Util.getAclName(oakPath);
    Tree policyTree = accessControlledTree.getChild(aclName);
    if (policyTree.exists()) {
      return policyTree;
    }
  }
  return null;
}

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

public boolean canAddMixin(String typeName) throws RepositoryException {
  Tree type = sessionDelegate.getRoot().getTree(NODE_TYPES_PATH).getChild(typeName);
  if (type.exists()) {
    return !TreeUtil.getBoolean(type, JCR_IS_ABSTRACT)
        && TreeUtil.getBoolean(type, JCR_ISMIXIN);
  } else {
    throw new NoSuchNodeTypeException(
        "Node type " + typeName + " does not exist");
  }
}

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

@NotNull
private Tree getPrivilegesTree(Root root) throws CommitFailedException {
  Tree privilegesTree = root.getTree(PRIVILEGES_PATH);
  if (!privilegesTree.exists()) {
    throw new CommitFailedException(CONSTRAINT, 44, "Privilege store not initialized.");
  }
  return privilegesTree;
}

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

static void assertMemberList(@NotNull Tree groupTree, int cntRefTrees, int cnt) {
  Tree list = groupTree.getChild(REP_MEMBERS_LIST);
  assertTrue(list.exists());
  assertEquals(cntRefTrees, list.getChildrenCount(5));
  for (Tree c : list.getChildren()) {
    PropertyState repMembers = c.getProperty(REP_MEMBERS);
    assertNotNull(repMembers);
    assertTrue(SIZE_TH == repMembers.count() || cnt == repMembers.count());
  }
}

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

@Test
public void testReadCug() {
  List<String> noAccess = ImmutableList.of(
      "/content/a/rep:cugPolicy", "/content/aa/bb/rep:cugPolicy", "/content2/rep:cugPolicy"
  );
  for (String p : noAccess) {
    assertFalse(p, testRoot.getTree(p).exists());
  }
}

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

@Test
public void getChild() {
  Tree tree = root.getTree("/");
  Tree child = tree.getChild("any");
  assertFalse(child.exists());
  child = tree.getChild("x");
  assertTrue(child.exists());
}

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

@Test
public void testGetAggregatedPrivilegeNamesNested() {
  ImmutableSet<String> values = ImmutableSet.of(JCR_READ, JCR_ADD_CHILD_NODES);
  when(pTree.getProperty(REP_AGGREGATES)).thenReturn(PropertyStates.createProperty(REP_AGGREGATES, values, Type.NAMES));
  when(pTree.exists()).thenReturn(true);
  when(privTree.getChild(KNOWN_PRIV_NAME)).thenReturn(pTree);
  Iterable<String> result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME);
  ImmutableSet<String> expected = ImmutableSet.of(REP_READ_NODES, REP_READ_PROPERTIES, JCR_ADD_CHILD_NODES);
  assertEquals(expected, ImmutableSet.copyOf(result));
}

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

@Test
public void testGetBitsNonExistingTree() {
  when(privTree.exists()).thenReturn(true);
  when(privTree.hasChild(KNOWN_PRIV_NAME)).thenReturn(false);
  // privilegesTree has no child for KNOWN_PRIV_NAME
  assertSame(PrivilegeBits.EMPTY, bitsProvider.getBits(KNOWN_PRIV_NAME));
}

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

@CheckForNull
private Tree getPrincipalRoot(@Nonnull String principalName) {
  if (principalTreeMap.containsKey(principalName)) {
    return principalTreeMap.get(principalName);
  } else {
    Tree principalRoot = PermissionUtil.getPrincipalRoot(permissionsTree, principalName);
    if (!principalRoot.exists()) {
      principalRoot = null;
    }
    principalTreeMap.put(principalName, principalRoot);
    return principalRoot;
  }
}

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

/**
 * Combination of {@link Tree#getChild(String)} and adding a child including
 * its jcr:primaryType property (i.e. {@link Tree#addChild(String)} and
 * {@link Tree#setProperty(PropertyState)}) in case no tree exists with the specified name.
 *
 * @param childName       The Oak name of the child item.
 * @param primaryTypeName The Oak name of the primary node type.
 * @return The new child node with the specified name and primary type.
 * @throws AccessDeniedException If the child does not exist after creation.
 */
@Nonnull
public static Tree getOrAddChild(@Nonnull Tree tree, @Nonnull String childName, @Nonnull String primaryTypeName) throws AccessDeniedException {
  Tree child = tree.getChild(childName);
  return (child.exists()) ? child : addChild(tree, childName, primaryTypeName);
}

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

@Nonnull
protected Tree getTree(@Nullable String oakPath, long permissions, boolean checkAcContent) throws RepositoryException {
  Tree tree = (oakPath == null) ? root.getTree("/") : root.getTree(oakPath);
  if (!tree.exists()) {
    throw new PathNotFoundException("No tree at " + oakPath);
  }
  if (permissions != Permissions.NO_PERMISSION) {
    // check permissions
    checkPermissions((oakPath == null) ? null : tree, permissions);
  }
  // check if the tree defines access controlled content
  if (checkAcContent && config.getContext().definesTree(tree)) {
    throw new AccessControlException("Tree " + tree.getPath() + " defines access control content.");
  }
  return tree;
}

相关文章