session.lockManager().lock(node, true, false, Long.MAX_VALUE, null);
// manipulate that lock using the system cache to simulate corrupt data
SessionCache systemSession = repository.createSystemSession(repository.runningState().context(), false);
SystemContent systemContent = new SystemContent(systemSession);
ChildReferences childReferences = systemContent.locksNode().getChildReferences(systemSession);
assertFalse("No locks found", childReferences.isEmpty());
for (ChildReference childReference : childReferences) {
MutableCachedNode lock = systemSession.mutable(childReference.getKey());
lock.setProperty(systemSession, propertyFactory.create(ModeShapeLexicon.IS_DEEP, true));
lock.setProperty(systemSession, propertyFactory.create(ModeShapeLexicon.LOCKED_KEY, node.key().toString()));
lock.setProperty(systemSession, propertyFactory.create(ModeShapeLexicon.SESSION_SCOPE, false));
}
systemSession.save();
return null;
}
}, "config/repo-config-persistent-no-indexes.json");
// second run should run the upgrade
startRunStop(new RepositoryOperation() {
@SuppressWarnings( "deprecation" )
@Override
public Void call() throws Exception {
// manipulate that lock using the system cache to simulate corrupt data
SessionCache systemSession = repository.createSystemSession(repository.runningState().context(), true);
SystemContent systemContent = new SystemContent(systemSession);
ChildReferences childReferences = systemContent.locksNode().getChildReferences(systemSession);
assertFalse("No locks found", childReferences.isEmpty());
for (ChildReference childReference : childReferences) {
CachedNode lock = systemSession.getNode(childReference.getKey());
assertNull("Property not removed", lock.getProperty(ModeShapeLexicon.IS_DEEP, systemSession));
assertNull("Property not removed", lock.getProperty(ModeShapeLexicon.LOCKED_KEY, systemSession));
assertNull("Property not removed", lock.getProperty(ModeShapeLexicon.SESSION_SCOPE, systemSession));