PrincipalBasedPermissionProvider implements AggregatedPermissionProvider, Constants { @Override public @NotNull TreePermission getTreePermission(@NotNull Tree tree, @NotNull TreePermission parentPermission) { Tree readOnly = getReadOnlyTree(tree); TreeType parentType; if (parentPermission instanceof AbstractTreePermission) { parentType = ((AbstractTreePermission) parentPermission).getType(); } else { parentType = (tree.isRoot()) ? TreeType.DEFAULT : typeProvider.getType(tree.getParent()); } return getTreePermission(readOnly, typeProvider.getType(readOnly, parentType), parentPermission); } PrincipalBasedPermissionProvider(@NotNull Root root,
                                     @NotNull String workspaceName,
                                     @NotNull Iterable<String> principalPaths,
                                     @NotNull PrincipalBasedAuthorizationConfiguration authorizationConfiguration); @Override void refresh(); @NotNull @Override Set<String> getPrivileges(@Nullable Tree tree); @Override boolean hasPrivileges(@Nullable Tree tree, @NotNull String... privilegeNames); @Override @NotNull RepositoryPermission getRepositoryPermission(); @Override @NotNull TreePermission getTreePermission(@NotNull Tree tree, @NotNull TreePermission parentPermission); @Override boolean isGranted(@NotNull Tree tree, @Nullable PropertyState property, long permissions); @Override boolean isGranted(@NotNull String oakPath, @NotNull String jcrActions); @Override @NotNull PrivilegeBits supportedPrivileges(@Nullable Tree tree, @Nullable PrivilegeBits privilegeBits); @Override long supportedPermissions(@Nullable Tree tree, @Nullable PropertyState property, long permissions); @Override long supportedPermissions(@NotNull TreeLocation location, long permissions); @Override long supportedPermissions(@NotNull TreePermission treePermission, @Nullable PropertyState property, long permissions); @Override boolean isGranted(@NotNull TreeLocation location, long permissions); @Override @NotNull TreePermission getTreePermission(@NotNull Tree tree, @NotNull TreeType type, @NotNull TreePermission parentPermission);  }
@Test public void testGetTreePermission() { Tree tree = root.getTree(PathUtils.ROOT_PATH); TreePermission tp = permissionProvider.getTreePermission(tree, TreePermission.EMPTY); for (String elem : PathUtils.elements(TEST_OAK_PATH)) { tree = tree.getChild(elem); tp = permissionProvider.getTreePermission(tree, tp); assertTrue(tp instanceof AbstractTreePermission); assertSame(TreeType.DEFAULT, ((AbstractTreePermission) tp).getType()); } }