* todo FIXME delegate to 'node type instance handler'
*/
EffectiveNodeType ent = itemOps.getEffectiveNodeType(node);
if (ent.includesNodeType(QName.MIX_VERSIONABLE)) {
PropDef def;
PropertyState prop;
SessionImpl session = (SessionImpl) wsp.getSession();
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
*/
VersionHistory vh = vMgr.getVersionHistory(session, node);
if (vh == null) {
vh = vMgr.createVersionHistory(session, node);
}
// jcr:versionHistory
if (!node.hasPropertyName(QName.JCR_VERSIONHISTORY)) {
def = itemOps.findApplicablePropertyDefinition(QName.JCR_VERSIONHISTORY,
PropertyType.REFERENCE, false, node);
prop = itemOps.createPropertyState(node, QName.JCR_VERSIONHISTORY,
PropertyType.REFERENCE, def);
prop.setValues(new InternalValue[]{InternalValue.create(new UUID(vh.getUUID()))});
}
// jcr:baseVersion
if (!node.hasPropertyName(QName.JCR_BASEVERSION)) {
def = itemOps.findApplicablePropertyDefinition(QName.JCR_BASEVERSION,
PropertyType.REFERENCE, false, node);
prop = itemOps.createPropertyState(node, QName.JCR_BASEVERSION,
PropertyType.REFERENCE, def);
prop.setValues(new InternalValue[]{InternalValue.create(new UUID(vh.getRootVersion().getUUID()))});
}
// jcr:predecessors
if (!node.hasPropertyName(QName.JCR_PREDECESSORS)) {
def = itemOps.findApplicablePropertyDefinition(QName.JCR_PREDECESSORS,
PropertyType.REFERENCE, true, node);
prop = itemOps.createPropertyState(node, QName.JCR_PREDECESSORS,
PropertyType.REFERENCE, def);
prop.setValues(new InternalValue[]{InternalValue.create(new UUID(vh.getRootVersion().getUUID()))});
}
// jcr:isCheckedOut
if (!node.hasPropertyName(QName.JCR_ISCHECKEDOUT)) {
def = itemOps.findApplicablePropertyDefinition(QName.JCR_ISCHECKEDOUT,
PropertyType.BOOLEAN, false, node);
prop = itemOps.createPropertyState(node, QName.JCR_ISCHECKEDOUT,
PropertyType.BOOLEAN, def);
prop.setValues(new InternalValue[]{InternalValue.create(true)});
}
}
}