use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class TypeEditorTest method changeMandatoryPropertyToBadRequiredType.
@Test
public void changeMandatoryPropertyToBadRequiredType() {
EditorHook hook = new EditorHook(new TypeEditorProvider());
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeBuilder acl = builder.child(AccessControlConstants.REP_POLICY);
acl.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_ACL, Type.NAME);
NodeBuilder ace = acl.child("first");
ace.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_GRANT_ACE, Type.NAME);
ace.setProperty(AccessControlConstants.REP_PRINCIPAL_NAME, EveryonePrincipal.NAME);
ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.NAMES);
NodeState before = builder.getNodeState();
// change to invalid type
ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.STRINGS);
try {
hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
fail();
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class TypeEditorTest method addMandatoryPropertyWithBadRequiredType.
@Test
public void addMandatoryPropertyWithBadRequiredType() {
EditorHook hook = new EditorHook(new TypeEditorProvider());
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeState before = builder.getNodeState();
NodeBuilder acl = builder.child(AccessControlConstants.REP_POLICY);
acl.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_ACL, Type.NAME);
NodeBuilder ace = acl.child("first");
ace.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_GRANT_ACE, Type.NAME);
ace.setProperty(AccessControlConstants.REP_PRINCIPAL_NAME, EveryonePrincipal.NAME);
ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.STRINGS);
try {
hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
fail();
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(55, e.getCode());
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class EmptyCugTreePermissionTest method testJcrSystemPermissions.
@Test
public void testJcrSystemPermissions() throws Exception {
NodeState system = rootState.getChildNode(JcrConstants.JCR_SYSTEM);
TreePermission systemTp = tp.getChildPermission(JcrConstants.JCR_SYSTEM, system);
assertCugPermission(systemTp, false);
assertCugPermission(pp.getTreePermission(root.getTree("/jcr:system"), tp), false);
NodeState versionStore = system.getChildNode(VersionConstants.JCR_VERSIONSTORAGE);
TreePermission versionStoreTp = systemTp.getChildPermission(VersionConstants.JCR_VERSIONSTORAGE, versionStore);
assertCugPermission(versionStoreTp, false);
assertCugPermission(pp.getTreePermission(root.getTree(VersionConstants.VERSION_STORE_PATH), systemTp), false);
NodeState nodeTypes = system.getChildNode(NodeTypeConstants.JCR_NODE_TYPES);
TreePermission nodeTypesTp = systemTp.getChildPermission(NodeTypeConstants.JCR_NODE_TYPES, nodeTypes);
assertSame(TreePermission.NO_RECOURSE, nodeTypesTp);
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class CugUtilTest method testHasCugNodeState.
@Test
public void testHasCugNodeState() throws Exception {
assertTrue(CugUtil.hasCug(getNodeState(root.getTree(SUPPORTED_PATH))));
assertFalse(CugUtil.hasCug((NodeState) null));
for (String path : new String[] { PathUtils.ROOT_PATH, INVALID_PATH, UNSUPPORTED_PATH, SUPPORTED_PATH + "/subtree", SUPPORTED_PATH2, SUPPORTED_PATH3 }) {
assertFalse(CugUtil.hasCug(getNodeState(root.getTree(path))));
}
new NodeUtil(root.getTree(SUPPORTED_PATH2)).addChild(REP_CUG_POLICY, NodeTypeConstants.NT_OAK_UNSTRUCTURED);
assertTrue(CugUtil.hasCug(getNodeState(root.getTree(SUPPORTED_PATH2))));
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class DocumentRootBuilder method reset.
/**
* Reset this builder by creating a new branch and setting the head
* state of that branch as the new base state of this builder.
*/
NodeState reset() {
branch = store.createBranch(store.getRoot());
NodeState head = branch.getHead();
reset(head);
return head;
}
Aggregations