throws RepositoryException {
final String[] mixins = getMixinTypes(reqProperties, path);
if (mixins != null) {
final Resource rsrc = resolver.getResource(path);
final ModifiableValueMap mvm = rsrc.adaptTo(ModifiableValueMap.class);
if ( mvm != null ) {
final Node node = rsrc.adaptTo(Node.class);
final Set<String> newMixins = new HashSet<String>();
newMixins.addAll(Arrays.asList(mixins));
// clear existing mixins first
if ( node != null ) {
checkoutIfNecessary(node, changes, versioningConfiguration);
for (NodeType mixin : node.getMixinNodeTypes()) {
String mixinName = mixin.getName();
if (!newMixins.remove(mixinName)) {
node.removeMixin(mixinName);
}
}
// add new mixins
for (String mixin : newMixins) {
node.addMixin(mixin);
// this is a bit of a cheat; there isn't a formal checkout, but assigning
// the mix:versionable mixin does an implicit checkout
if (mixin.equals("mix:versionable") &&
versioningConfiguration.isCheckinOnNewVersionableNode()) {
changes.add(Modification.onCheckout(path));
}
}
} else {
mvm.put("jcr:mixinTypes", mixins);
}
}
}
}