NodeState nodeState = (NodeState) itemState;
EffectiveNodeType nt = getEffectiveNodeType(nodeState);
if (nt.includesNodeType(NameConstants.MIX_VERSIONABLE)) {
if (!nodeState.hasPropertyName(NameConstants.JCR_VERSIONHISTORY)) {
NodeImpl node = (NodeImpl) itemMgr.getItem(itemState.getId());
VersionManager vMgr = session.getVersionManager();
/**
* check if there's already a version history for that
* node; this would e.g. be the case if a versionable
* node had been exported, removed and re-imported with
* either IMPORT_UUID_COLLISION_REMOVE_EXISTING or
* IMPORT_UUID_COLLISION_REPLACE_EXISTING;
* otherwise create a new version history
*/
VersionHistoryInfo history =
vMgr.getVersionHistory(session, nodeState, null);
InternalValue historyId = InternalValue.create(
history.getVersionHistoryId().getUUID());
InternalValue versionId = InternalValue.create(
history.getRootVersionId().getUUID());
node.internalSetProperty(
NameConstants.JCR_VERSIONHISTORY, historyId);
node.internalSetProperty(
NameConstants.JCR_BASEVERSION, versionId);
node.internalSetProperty(
NameConstants.JCR_ISCHECKEDOUT,
InternalValue.create(true));
node.internalSetProperty(
NameConstants.JCR_PREDECESSORS,
new InternalValue[] { versionId });
createdTransientState = true;
}
} else if (nt.includesNodeType(NameConstants.MIX_SIMPLE_VERSIONABLE)) {
// we need to check the version manager for an existing
// version history, since simple versioning does not
// expose it's reference in a property
VersionManager vMgr = session.getVersionManager();
vMgr.getVersionHistory(session, nodeState, null);
// create isCheckedOutProperty if not already exists
NodeImpl node = (NodeImpl) itemMgr.getItem(itemState.getId());
if (!nodeState.hasPropertyName(NameConstants.JCR_ISCHECKEDOUT)) {
node.internalSetProperty(