Privilege[] privileges = privilegesFromName(Privilege.JCR_ALL);
givePrivileges(path, privileges, getRestrictions(superuser, path));
// create new node and lock it
Session s = getTestSession();
UserTransaction utx = new UserTransactionImpl(s);
utx.begin();
// add node and save it
Node n = s.getNode(childNPath);
if (n.hasNode(nodeName1)) {
Node c = n.getNode(nodeName1);
c.remove();
s.save();
}
// create node and save
Node n2 = n.addNode(nodeName1);
s.save(); // -> node is NEW -> no failure
// create child node
Node n3 = n2.addNode(nodeName2);
s.save(); // -> used to fail because n2 was saved (EXISTING) but not committed.
n3.remove();
n2.remove();
// recreate n2 // -> another area where ItemManager#getItem is called in the ItemSaveOperation
n2 = n.addNode(nodeName1);
s.save();
// set a property on a child node of an uncommited parent
n2.setProperty(propertyName1, "testSetProperty");
s.save(); // -> used to fail because PropertyImpl#getParent called from PropertyImpl#checkSetValue
// was checking read permission on the not yet commited parent
// commit
utx.commit();
}