new Privilege[] {acm.privilegeFromName(Privilege.JCR_ALL)});
acm.setPolicy("/testNode", acl);
session.save();
// remove the new property from 4.0 which actually stores the ACL count to simulate a pre 4.0 repository
SessionCache systemSession = repository.createSystemSession(repository.runningState().context(), false);
SystemContent systemContent = new SystemContent(systemSession);
MutableCachedNode systemNode = systemContent.mutableSystemNode();
systemNode.removeProperty(systemSession, ModeShapeLexicon.ACL_COUNT);
systemSession.save();
return null;
}
}, config);
// second run should run the upgrade
startRunStop(new RepositoryOperation() {
@Override
public Void call() throws Exception {
// check that the upgrade function correctly added the new property
SessionCache systemSession = repository.createSystemSession(repository.runningState().context(), false);
SystemContent systemContent = new SystemContent(systemSession);
MutableCachedNode systemNode = systemContent.mutableSystemNode();
Property aclCountProp = systemNode.getProperty(ModeShapeLexicon.ACL_COUNT, systemSession);
assertNotNull("ACL count property not found after upgrade", aclCountProp);
assertEquals(1, Long.valueOf(aclCountProp.getFirstValue().toString()).longValue());
// force a 2nd upgrade
changeLastUpgradeId(repository, Upgrades.ModeShape_4_0_0_Alpha1.INSTANCE.getId() - 1);
// remove all ACLs
JcrSession session = repository.login();
AccessControlManager acm = session.getAccessControlManager();
// TODO author=Horia Chiorean date=25-Mar-14 description=Why null ?!
acm.removePolicy("/testNode", null);
session.save();
// remove the new property from 4.0 which actually stores the ACL count to simulate a pre 4.0 repository
systemNode.removeProperty(systemSession, ModeShapeLexicon.ACL_COUNT);
systemSession.save();
return null;
}
}, config);
// check that the upgrade disabled ACLs
startRunStop(new RepositoryOperation() {
@Override
public Void call() throws Exception {
SessionCache systemSession = repository.createSystemSession(repository.runningState().context(), true);
SystemContent systemContent = new SystemContent(systemSession);
CachedNode systemNode = systemContent.systemNode();
Property aclCountProp = systemNode.getProperty(ModeShapeLexicon.ACL_COUNT, systemSession);
assertNotNull("ACL count property not found after upgrade", aclCountProp);
assertEquals(0, Long.valueOf(aclCountProp.getFirstValue().toString()).longValue());