JCRNodeWrapper objectNode;
try {
objectNode = currentUserSession.getNodeByUUID(aNode.getUUID());
} catch (RepositoryException e) {
logger.error(e.toString(), e);
throw new GWTJahiaServiceException(new StringBuilder(aNode.getDisplayName()).append(" could not be accessed :\n").append(e.toString()).toString());
}
try {
List<String> types = aNode.getNodeTypes();
if (removedTypes != null) {
for (ExtendedNodeType mixin : objectNode.getMixinNodeTypes()) {
if (removedTypes.contains(mixin.getName())) {
List<ExtendedItemDefinition> items = mixin.getItems();
for (ExtendedItemDefinition item : items) {
if (item.isNode()) {
if (objectNode.hasNode(item.getName())) {
currentUserSession.checkout(objectNode);
objectNode.getNode(item.getName()).remove();
}
} else {
if (objectNode.hasProperty(item.getName())) {
currentUserSession.checkout(objectNode);
objectNode.getProperty(item.getName()).remove();
}
}
}
objectNode.removeMixin(mixin.getName());
}
}
}
for (String type : types) {
if (!objectNode.isNodeType(type)) {
currentUserSession.checkout(objectNode);
objectNode.addMixin(type);
}
}
setProperties(objectNode, newProps);
objectNode.saveSession();
} catch (RepositoryException e) {
throw new GWTJahiaServiceException("Could not save node " + objectNode.getName() + ", " + e.getMessage());
}
}
}