* @throws RepositoryException
* @throws IOException
*/
private void updateVersionedChildNodes(List<String> versionUuids) throws RepositoryException, IOException
{
SessionDataManager dataManager = userSession.getTransientNodesManager();
NodeData versionStorage = (NodeData)dataManager.getItemData(Constants.VERSIONSTORAGE_UUID);
for (String versionUuid : versionUuids)
{
NodeData versionHistoryData =
(NodeData)dataManager.getItemData(versionStorage, new QPathEntry("", versionUuid, 1), ItemType.NODE);
PropertyData versionableUuidProp =
(PropertyData)dataManager.getItemData(versionHistoryData, new QPathEntry(Constants.JCR_VERSIONABLEUUID, 1),
ItemType.PROPERTY);
String versionableUuid = ValueDataConvertor.readString(versionableUuidProp.getValues().get(0));
// fetch child versionable node
NodeData versionedChild = (NodeData)dataManager.getItemData(versionableUuid);
if (versionedChild != null && versionedChild.getQPath().isDescendantOf(versionableNode.getData().getQPath()))
{
// find latest version
String latestVersionUuid = null;
for (int versionNumber = 1;; versionNumber++)
{
NodeData nodeData =
(NodeData)dataManager.getItemData(versionHistoryData, new QPathEntry("", Integer
.toString(versionNumber), 1), ItemType.NODE);
if (nodeData == null)
{
break;
}
else
{
latestVersionUuid = nodeData.getIdentifier();
}
}
if (latestVersionUuid == null)
{
// fetch root version
NodeData rootVersion =
(NodeData)dataManager.getItemData(versionHistoryData, new QPathEntry(Constants.JCR_ROOTVERSION, 1),
ItemType.NODE);
latestVersionUuid = rootVersion.getIdentifier();
}
PropertyData propVersionHistory =
(PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1),
ItemType.PROPERTY);
String prevVerHistoryId = ValueDataConvertor.readString(propVersionHistory.getValues().get(0));
PropertyData propBaseVersion =
(PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_BASEVERSION, 1),
ItemType.PROPERTY);
PropertyData propPredecessors =
(PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_PREDECESSORS, 1),
ItemType.PROPERTY);
TransientPropertyData newVersionHistoryProp =
TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_VERSIONHISTORY,
PropertyType.REFERENCE, false, new TransientValueData(new Identifier(versionUuid)));
// jcr:baseVersion
TransientPropertyData newBaseVersionProp =
TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_BASEVERSION,
PropertyType.REFERENCE, false, new TransientValueData(new Identifier(latestVersionUuid)));
// jcr:predecessors
List<ValueData> predecessorValues = new ArrayList<ValueData>();
predecessorValues.add(new TransientValueData(new Identifier(latestVersionUuid)));
TransientPropertyData newPredecessorsProp =
TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_PREDECESSORS,
PropertyType.REFERENCE, true, predecessorValues);
//remove previous version of childnode nad update properties
NodeData prevVersionHistory = (NodeData)dataManager.getItemData(prevVerHistoryId);
PlainChangesLogImpl changesLog = new PlainChangesLogImpl();
if (!prevVerHistoryId.equals(versionUuid))
{
RemoveVisitor rv = new RemoveVisitor();