use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder in project jackrabbit-oak by apache.
the class PrivilegeValidatorTest method testUnknownAggregate.
@Test
public void testUnknownAggregate() {
try {
NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE).setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PRIVILEGE).setProperty(REP_BITS, 8).setProperty(REP_AGGREGATES, ImmutableList.of("unknown", JCR_READ), Type.NAMES).getNodeState();
PrivilegeValidator validator = new PrivilegeValidator(root, root);
validator.childNodeAdded("test", newDef);
fail("unknown aggregate must be detected.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(51, e.getCode());
}
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder in project jackrabbit-oak by apache.
the class PrivilegeValidatorTest method testCircularAggregate2.
@Test
public void testCircularAggregate2() {
try {
createPrivilegeTree("test2", "test");
NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE).setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PRIVILEGE).setProperty(REP_BITS, 8).setProperty(REP_AGGREGATES, ImmutableList.of("test2", JCR_READ), Type.NAMES).getNodeState();
PrivilegeValidator validator = new PrivilegeValidator(root, root);
validator.childNodeAdded("test", newDef);
fail("unknown aggregate must be detected.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(52, e.getCode());
}
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder in project jackrabbit-oak by apache.
the class VersionableState method getOPV.
private int getOPV(NodeBuilder parent, NodeBuilder child, String childName) throws RepositoryException {
// ignore hidden tree
if (childName.startsWith(":")) {
return IGNORE;
}
ImmutableTree parentTree = new ImmutableTree(parent.getNodeState());
NodeState childState;
if (NT_FROZENNODE.equals(child.getName(JCR_PRIMARYTYPE))) {
// need to translate into a regular node to get proper OPV value
NodeBuilder builder = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE);
builder.setProperty(JCR_PRIMARYTYPE, child.getName(JCR_FROZENPRIMARYTYPE), Type.NAME);
builder.setProperty(JCR_MIXINTYPES, child.getNames(JCR_MIXINTYPES), Type.NAMES);
childState = builder.getNodeState();
} else {
childState = child.getNodeState();
}
ImmutableTree childTree = new ImmutableTree(parentTree, childName, childState);
return ntMgr.getDefinition(parentTree, childTree).getOnParentVersion();
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder in project jackrabbit-oak by apache.
the class PrivilegeValidatorTest method testCircularAggregate.
@Test
public void testCircularAggregate() {
try {
createPrivilegeTree("test");
NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE).setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PRIVILEGE).setProperty(REP_BITS, 8).setProperty(REP_AGGREGATES, ImmutableList.of("test", JCR_READ), Type.NAMES).getNodeState();
PrivilegeValidator validator = new PrivilegeValidator(root, root);
validator.childNodeAdded("test", newDef);
fail("unknown aggregate must be detected.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(52, e.getCode());
}
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder in project jackrabbit-oak by apache.
the class PrivilegeValidatorTest method testPrivBitsMissing.
@Test
public void testPrivBitsMissing() {
try {
NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE).setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PRIVILEGE).getNodeState();
PrivilegeValidator validator = new PrivilegeValidator(root, root);
validator.childNodeAdded("test", newDef);
fail("missing priv bits must be detected.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(48, e.getCode());
}
}
Aggregations