for (Value predecessorValue : predecessors.getValues()) {
addedValues.clear();
List<JcrValue> newNodeSuccessors = new ArrayList<>();
// Add each of the successors from the version's predecessor ...
NodeKey predecessorKey = ((NodeKeyReference)((JcrValue)predecessorValue).value()).getNodeKey();
AbstractJcrNode predecessor = session().node(predecessorKey, null);
MutableCachedNode predecessorSystem = system.mutable(predecessor.key());
JcrValue[] nodeSuccessors = predecessor.getProperty(JcrLexicon.SUCCESSORS).getValues();
addValuesNotInSet(nodeSuccessors, newNodeSuccessors, versionId, addedValues);
if (successors != null) {
// Add each of the successors from the version being removed ...
addValuesNotInSet(successors.getValues(), newNodeSuccessors, versionId, addedValues);
}
// Set the property ...
Object[] newSuccessorReferences = extractValues(newNodeSuccessors);
predecessorSystem.setProperty(system, session.propertyFactory().create(JcrLexicon.SUCCESSORS,
newSuccessorReferences));
addedValues.clear();
}
if (successors != null) {
// Remove the reference to the dead version from the predecessors property of all the successors
for (Value successorValue : successors.getValues()) {
addedValues.clear();
List<JcrValue> newNodePredecessors = new ArrayList<>();
// Add each of the predecessors from the version's successor ...
NodeKey successorKey = ((NodeKeyReference)((JcrValue)successorValue).value()).getNodeKey();
AbstractJcrNode successor = session().node(successorKey, null);
MutableCachedNode successorSystem = system.mutable(successor.key());
JcrValue[] nodePredecessors = successor.getProperty(JcrLexicon.PREDECESSORS).getValues();
addValuesNotInSet(nodePredecessors, newNodePredecessors, versionId, addedValues);