use of org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree in project jackrabbit-oak by apache.
the class PrivilegeValidator method childNodeAdded.
@Override
public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException {
if (isPrivilegeDefinition(after)) {
// make sure privileges have been initialized before
getPrivilegesTree(rootBefore);
// name may not contain reserved namespace prefix
if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) {
String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name;
throw new CommitFailedException("Privilege", 1, msg);
}
// validate the definition
Tree tree = new ImmutableTree(ImmutableTree.ParentProvider.UNSUPPORTED, name, after);
validateDefinition(tree);
}
// that is not handled by this validator anyway).
return null;
}
use of org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree in project jackrabbit-oak by apache.
the class GlobbingPathFilterTest method matchSuffix.
/**
* r/s/t/** should match r/s/t and all its descendants
*/
@Test
public void matchSuffix() {
EventFilter filter = new GlobbingPathFilter("a/b/c/d/r/s/t/**");
ImmutableTree t = tree;
for (String name : elements("a/b/c/d/r/s")) {
t = t.getChild(name);
assertFalse(filter.includeAdd(name, t.getNodeState()));
filter = filter.create(name, t.getNodeState(), t.getNodeState());
assertNotNull(filter);
}
for (String name : elements("t/u/v/r/s/t/u/v/r/s/t/u/v/w")) {
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 GlobbingPathFilterTest method matchAtEnd.
/**
* **/r/s/t/u/v/w should match r/s/t/u/v/r/s/t/u/v/r/s/t/u/v/w
*/
@Test
public void matchAtEnd() {
EventFilter filter = new GlobbingPathFilter("**/r/s/t/u/v/w");
ImmutableTree t = tree;
for (String name : elements("r/s/t/u/v/r/s/t/u/v/r/s/t/u/v")) {
t = t.getChild(name);
assertFalse(filter.includeAdd(name, t.getNodeState()));
filter = filter.create(name, t.getNodeState(), t.getNodeState());
assertNotNull(filter);
}
t = t.getChild("w");
assertTrue(filter.includeAdd("w", t.getNodeState()));
filter = filter.create("w", 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 setup.
@Before
public void setup() {
NodeBuilder root = EMPTY_NODE.builder();
createPath(root, "a/b/c/d");
createPath(root, "q");
createPath(root, "x/y/x/y/z");
createPath(root, "r/s/t/u/v/r/s/t/u/v/r/s/t/u/v/w");
tree = new ImmutableTree(root.getNodeState());
}
use of org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree in project jackrabbit-oak by apache.
the class GlobbingPathFilterTest method inTheMiddle.
/**
* match ** 'in the middle'
*/
@Test
public void inTheMiddle() {
EventFilter filter = new GlobbingPathFilter("/foo/" + STAR_STAR + "/bar");
ImmutableTree t = tree;
for (String name : elements("foo/a/b/c")) {
t = t.getChild(name);
assertFalse(filter.includeAdd(name, t.getNodeState()));
filter = filter.create(name, t.getNodeState(), t.getNodeState());
assertNotNull(filter);
}
for (String name : elements("bar")) {
t = t.getChild(name);
assertTrue(filter.includeAdd(name, t.getNodeState()));
filter = filter.create(name, t.getNodeState(), t.getNodeState());
assertNotNull(filter);
}
}
Aggregations