throws NoSuchNodeTypeException, RepositoryException {
// check state of this instance
sanityCheck();
Name ntName = sessionContext.getQName(mixinName);
NodeTypeManagerImpl ntMgr = sessionContext.getNodeTypeManager();
NodeTypeImpl mixin = ntMgr.getNodeType(ntName);
if (!mixin.isMixin()) {
return false;
}
int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT
| ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD;
int permissions = Permission.NODE_TYPE_MNGMT;
// special handling of mix:(simple)versionable. since adding the mixin alters
// the version storage jcr:versionManagement privilege is required
// in addition.
if (NameConstants.MIX_VERSIONABLE.equals(ntName)
|| NameConstants.MIX_SIMPLE_VERSIONABLE.equals(ntName)) {
permissions |= Permission.VERSION_MNGMT;
}
if (!sessionContext.getItemValidator().canModify(this, options, permissions)) {
return false;
}
final Name primaryTypeName = data.getNodeState().getNodeTypeName();
NodeTypeImpl primaryType = ntMgr.getNodeType(primaryTypeName);
if (primaryType.isDerivedFrom(ntName)) {
// mixin already inherited -> addMixin is allowed but has no effect.
return true;
}
// build effective node type of mixins & primary type
// in order to detect conflicts
NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry();
EffectiveNodeType entExisting;
try {
// existing mixin's
Set<Name> mixins = new HashSet<Name>(data.getNodeState().getMixinTypeNames());