use of org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree in project jackrabbit-oak by apache.
the class GlobbingPathFilterTest method multipleMatches.
/**
* **/r/s/t/u/v should match r/s/t/u/v and r/s/t/u/v/r/s/t/u/v and r/s/t/u/v/r/s/t/u/v/r/s/t/u/v
*/
@Test
public void multipleMatches() {
EventFilter filter = new GlobbingPathFilter("**/r/s/t/u/v");
ImmutableTree t = tree;
for (int c = 0; c < 2; c++) {
for (String name : elements("r/s/t/u")) {
t = t.getChild(name);
assertFalse(filter.includeAdd(name, t.getNodeState()));
filter = filter.create(name, t.getNodeState(), t.getNodeState());
assertNotNull(filter);
}
t = t.getChild("v");
assertTrue(filter.includeAdd("v", t.getNodeState()));
filter = filter.create("v", t.getNodeState(), t.getNodeState());
assertNotNull(filter);
}
}
use of org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree in project jackrabbit-oak by apache.
the class GlobbingPathFilterTest method all.
/**
* ** should match every path
*/
@Test
public void all() {
EventFilter filter = new GlobbingPathFilter(STAR_STAR);
ImmutableTree t = tree;
for (String name : elements("a/b/c/d")) {
t = t.getChild(name);
assertTrue(filter.includeAdd(name, t.getNodeState()));
filter = filter.create(name, t.getNodeState(), t.getNodeState());
assertNotNull(filter);
}
}
use of org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree in project jackrabbit-oak by apache.
the class CompositeProviderNoScopeTest method testTreePermissionGetChild.
@Override
@Test
public void testTreePermissionGetChild() throws Exception {
List<String> childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting");
Tree rootTree = readOnlyRoot.getTree(ROOT_PATH);
NodeState ns = ((ImmutableTree) rootTree).getNodeState();
TreePermission tp = createPermissionProvider().getTreePermission(rootTree, TreePermission.EMPTY);
assertCompositeTreePermission(tp);
for (String cName : childNames) {
ns = ns.getChildNode(cName);
tp = tp.getChildPermission(cName, ns);
assertCompositeTreePermission(false, tp);
}
}
use of org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree in project jackrabbit-oak by apache.
the class CompositeProviderNoScopeTest method testTreePermissionSize.
@Test
public void testTreePermissionSize() throws Exception {
Field tpField = CompositeTreePermission.class.getDeclaredField("treePermissions");
tpField.setAccessible(true);
Tree rootTree = readOnlyRoot.getTree(ROOT_PATH);
NodeState ns = ((ImmutableTree) rootTree).getNodeState();
TreePermission tp = cppTestUser.getTreePermission(rootTree, TreePermission.EMPTY);
assertEquals(2, ((TreePermission[]) tpField.get(tp)).length);
List<String> childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting");
for (String cName : childNames) {
ns = ns.getChildNode(cName);
tp = tp.getChildPermission(cName, ns);
assertCompositeTreePermission(false, tp);
}
}
use of org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree in project jackrabbit-oak by apache.
the class CompositePermissionProvider method hasPrivileges.
@Override
public boolean hasPrivileges(@Nullable Tree tree, @Nonnull String... privilegeNames) {
Tree immutableTree = PermissionUtil.getImmutableTree(tree, immutableRoot);
PrivilegeBits privilegeBits = privilegeBitsProvider.getBits(privilegeNames);
if (privilegeBits.isEmpty()) {
return true;
}
boolean hasPrivileges = false;
PrivilegeBits coveredPrivs = PrivilegeBits.getInstance();
for (AggregatedPermissionProvider aggregatedPermissionProvider : pps) {
PrivilegeBits supported = aggregatedPermissionProvider.supportedPrivileges(immutableTree, privilegeBits);
if (doEvaluate(supported)) {
Set<String> supportedNames = privilegeBitsProvider.getPrivilegeNames(supported);
hasPrivileges = aggregatedPermissionProvider.hasPrivileges(immutableTree, supportedNames.toArray(new String[supportedNames.size()]));
coveredPrivs.add(supported);
if (!hasPrivileges) {
break;
}
}
}
return hasPrivileges && coveredPrivs.includes(privilegeBits);
}
Aggregations