ModeShape does allow you to change/update existing node types, and this may indeed make existing content "invalid" when making further changes. This is an area that the JSR-283 specification leaves a lot up to the implementation. For example, Section 19.2.4.1 "Updating Node Types" says this:
A repository that supports node type management may support updates to a node type already in use as the type of an existing node. The extent of any such capability is implementation dependent. For example, some implementations may permit only changes which do not invalidate existing content, while others may allow larger changes. How any resulting incompatibilities are resolved is also implementation dependent.
ModeShape does implement the more permissive changes, and so we recommend using good practices and procedures when updating node types. If you know you're adding a mandatory property definition or child node definition to a node type, then consider the implications before doing that and make sure you update the content (before or after the node type is changed, depending upon whether the node type might allow residual properties or residual child nodes).
If your node types do not have residual property definitions and/or child node definitions, then it may make sense to implement the change in multiple steps:
- Register the node type(s) first with non-mandatory (e.g., optional) property definition(s) and/or child node definition(s).
- Change any existing content that uses the node types and add the new property and/or child nodes, using navigation or queries to find the nodes that need to be changed.
- Register the node type(s) with the same property definition(s) and or child node definition(s) now being
mandatory
.
Or, if it makes sense in your repository, add the property definition(s) as a new mixin. After the mixin is registered, you can start using it on new content and you can go back and add the mixin to existing nodes where you want to add the new property (or properties).
We also recommend that you think about how your node types might evolve when you're first creating the node types. Evolution will just be one of several facets that influence your design.
The challenge of updating node types is that what needs to be done (and the best way to do it) depends so much upon the specifics of the node type. This is why we chose to leave a lot of this process up to you. The alternative would have been that ModeShape is far more restrictive on what kinds of updates are allowed on node types, and that would have prevented and/or constrained a lot of node type updates.