List<ItemState> changes = new ArrayList<ItemState>();
NodeData parentNodeData = (NodeData)dataManager.getItemData(cause.getParentIdentifier());
NodeData nextSibling =
(NodeData)dataManager.getItemData(parentNodeData, new QPathEntry(cause.getQPath().getName(), cause.getQPath()
.getIndex() + 1), ItemType.NODE);
String reindexedId = null;
// repeat till next sibling exists and it's not a caused Node (deleted or moved to) or just
// reindexed
while (nextSibling != null && !nextSibling.getIdentifier().equals(cause.getIdentifier())
&& !nextSibling.getIdentifier().equals(reindexedId))
{
// update with new index
QPath siblingPath =
QPath.makeChildPath(nextSibling.getQPath().makeParentPath(), nextSibling.getQPath().getName(), nextSibling
.getQPath().getIndex() - 1);
NodeData reindexed =
new TransientNodeData(siblingPath, nextSibling.getIdentifier(), nextSibling.getPersistedVersion(),
nextSibling.getPrimaryTypeName(), nextSibling.getMixinTypeNames(), nextSibling.getOrderNumber(),
nextSibling.getParentIdentifier(), nextSibling.getACL());
reindexedId = reindexed.getIdentifier();
ItemState reindexedState = ItemState.createUpdatedState(reindexed);
changes.add(reindexedState);
// reload pooled implies... it's actual for session and workspace scope
// operations
// TODO this operation must respect all sub-tree of reindexed node
// http://jira.exoplatform.org/browse/JCR-340
itemsPool.reload(reindexed);
// next...
nextSibling =
(NodeData)dataManager.getItemData(parentNodeData, new QPathEntry(nextSibling.getQPath().getName(),
nextSibling.getQPath().getIndex() + 1), ItemType.NODE);
}
return changes;
}