if (log.isDebugEnabled())
{
log.debug("Versioned child node " + cvhpPropPath.getAsString());
}
VersionHistoryDataHelper childHistory = null;
try
{
String vhIdentifier =
new String(((PropertyData)dataManager.getItemData(frozen, new QPathEntry(
Constants.JCR_CHILDVERSIONHISTORY, 0), ItemType.PROPERTY)).getValues().get(0).getAsByteArray());
NodeData cHistory = null;
if ((cHistory = (NodeData)dataManager.getItemData(vhIdentifier)) == null)
throw new RepositoryException("Version history is not found with uuid " + vhIdentifier);
childHistory = new VersionHistoryDataHelper(cHistory, dataManager, nodeTypeDataManager);
}
catch (IllegalStateException e)
{
throw new RepositoryException("jcr:childVersionHistory, error of data read "
+ userSession.getLocationFactory().createJCRPath(cvhpPropPath).getAsString(false), e);
}
catch (IOException e)
{
throw new RepositoryException("jcr:childVersionHistory, error of data read "
+ userSession.getLocationFactory().createJCRPath(cvhpPropPath).getAsString(false), e);
}
String versionableIdentifier = null;
try
{
versionableIdentifier =
new String(((PropertyData)dataManager.getItemData(childHistory, new QPathEntry(
Constants.JCR_VERSIONABLEUUID, 0), ItemType.PROPERTY)).getValues().get(0).getAsByteArray());
}
catch (IOException e)
{
throw new RepositoryException("jcr:childVersionHistory, error of data read "
+ userSession.getLocationFactory().createJCRPath(cvhpPropPath).getAsString(false), e);
}
NodeData versionable = (NodeData)dataManager.getItemData(versionableIdentifier);
if (versionable != null)
{
// exists,
// On restore of VN, if the workspace currently has an already
// existing node corresponding to C’s version history and the
// removeExisting flag of the restore is set to true, then that
// instance of C becomes the child of the restored N.
if (!removeExisting)
{
throw new ItemExistsException("Item with the same UUID " + versionableIdentifier
+ " as versionable child node "
+ userSession.getLocationFactory().createJCRPath(versionable.getQPath()).getAsString(false)
+ " already exists and removeExisting=false");
}
// else - leaving existed unchanged
}
else
{
// not found, gets last version (by time of creation) and restore it
NodeData lastVersionData = childHistory.getLastVersionData();
NodeData cvFrozen =
(NodeData)dataManager.getItemData(lastVersionData, new QPathEntry(Constants.JCR_FROZENNODE, 1),
ItemType.NODE);
ItemDataRestoreVisitor restoreVisitor =