// ancestor is checked in
Property existingMixinProperty = getProperty(JcrLexicon.MIXIN_TYPES);
if (existingMixinProperty == null) {
throw new NoSuchNodeTypeException(JcrI18n.invalidMixinTypeForNode.text(mixinName, getPath()));
}
Value[] existingMixinValues = existingMixinProperty.getValues();
if (existingMixinValues.length == 0) {
throw new NoSuchNodeTypeException(JcrI18n.invalidMixinTypeForNode.text(mixinName, getPath()));
}
// ------------------------------------------------------------------------------
// Build the new list of mixin types
// ------------------------------------------------------------------------------
int newMixinValuesCount = existingMixinValues.length - 1;
Value[] newMixinValues = new Value[newMixinValuesCount];
List<Name> newMixinNames = new ArrayList<Name>(newMixinValuesCount);
Name primaryTypeName = getPrimaryNodeType().getInternalName();
int j = 0;
for (int i = 0; i < existingMixinValues.length; i++) {
if (!existingMixinValues[i].getString().equals(mixinName)) {
if (j < newMixinValuesCount) {
newMixinValues[j++] = existingMixinValues[i];
newMixinNames.add(cache.nameFactory.create(existingMixinValues[i].getString()));
} else {
throw new NoSuchNodeTypeException(JcrI18n.invalidMixinTypeForNode.text(mixinName, getPath()));
}
}
}
// ------------------------------------------------------------------------------