values.add(new TransientValueData(cn));
}
newMixin.add(type.getName());
values.add(new TransientValueData(type.getName()));
PropertyData prop =
(PropertyData)dataManager.getItemData(((NodeData)getData()), new QPathEntry(Constants.JCR_MIXINTYPES, 0),
ItemType.PROPERTY);
ItemState state;
if (prop != null)
{// there was mixin prop
prop =
new TransientPropertyData(prop.getQPath(), prop.getIdentifier(), prop.getPersistedVersion(),
prop.getType(), prop.getParentIdentifier(), prop.isMultiValued(), values);
state = ItemState.createUpdatedState(prop);
}
else
{
prop =
TransientPropertyData.createPropertyData(this.nodeData(), Constants.JCR_MIXINTYPES, PropertyType.NAME,
true, values);
state = ItemState.createAddedState(prop);
}
NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();
// change ACL
for (PropertyDefinitionData def : ntmanager.getAllPropertyDefinitions(type.getName()))
{
if (ntmanager.isNodeType(Constants.EXO_OWNEABLE, new InternalQName[]{type.getName()})
&& def.getName().equals(Constants.EXO_OWNER))
{
AccessControlList acl =
new AccessControlList(session.getUserID(), ((NodeData)data).getACL().getPermissionEntries());
setACL(acl);
}
}
updateMixin(newMixin);
dataManager.update(state, false);
// Should register jcr:mixinTypes and autocreated items if node is not added
ItemAutocreator itemAutocreator = new ItemAutocreator(ntmanager, valueFactory, dataManager, false);
PlainChangesLog changes =
itemAutocreator.makeAutoCreatedItems(nodeData(), type.getName(), dataManager, session.getUserID());
for (ItemState autoCreatedState : changes.getAllStates())
{
dataManager.update(autoCreatedState, false);
}
// launch event
session.getActionHandler().postAddMixin(this, type.getName());
if (LOG.isDebugEnabled())
LOG.debug("Node.addMixin Property " + prop.getQPath().getAsString() + " values " + mixinTypes.length);
}