Refine search
/** * 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; }
@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()); }
@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)); }
@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; }
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"); } }
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()); } }
@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)); }
@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; } }
/** * 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); }
@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; }