/**
* build diff of current and new definition and determine type of change
*/
QNodeTypeDefinition ntdOld = registeredNTDefs.get(name);
NodeTypeDefDiff diff = NodeTypeDefDiff.create(ntdOld, ntd);
if (!diff.isModified()) {
// the definition has not been modified, there's nothing to do here...
return getEffectiveNodeType(name);
}
if (diff.isTrivial()) {
/**
* the change is trivial and has no effect on current content
* (e.g. that would be the case when non-mandatory properties had
* been added);
* re-register node type definition and update caches &
* notify listeners on re-registration
*/
internalUnregister(name);
// remove old node type definition from store
customNTDefs.remove(name);
EffectiveNodeType entNew = internalRegister(ntd);
// add new node type definition to store
customNTDefs.add(ntd);
// persist node type definitions
persistCustomNodeTypeDefs(customNTDefs);
// inform cluster if this is not an external invocation
if (!external && eventChannel != null) {
eventChannel.reregistered(ntd);
}
// notify listeners
notifyReRegistered(name);
return entNew;
}
String message =
"The following node type change contains non-trivial changes."
+ "Up until now only trivial changes are supported."
+ " (see javadoc for "
+ NodeTypeDefDiff.class.getName()
+ "):\n" + diff.toString();
throw new RepositoryException(message);
// TODO Implement checkForConflictingContent()
// make sure existing content would not conflict
// with new node type definition