[ https://issues.apache.org/jira/browse/OAK-5229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15863871#comment-15863871 ]
Marcel Reutegger commented on OAK-5229: --------------------------------------- There was already input from various people what the expected behaviour should be. In an attempt to drive this forward, I'm trying to summarise and put together a proposal that we can eventually agree on. - Fix the *TypeEditor* and ensure the repository cannot be corrupted with content that does not have valid item definitions - Fail setPrimaryType() with a ConstraintViolationException when there are *non-protected* items that do not have a matching item definition after the change of the primary type. With Tobi's example in the description, the setPrimaryType() call would fail and it would be the responsibility of the application to first remove those items (e.g. unstructured_child). - Automatically clean up (remove) *protected* items on setPrimaryType() if there is no matching item definition after the change of the primary type. This means previously protected items may become regular items if permitted by existing item definitions. E.g. removing a mix:referenceable on a nt:unstructured would not remove the jcr:uuid property. - *Unify* the behaviour for setPrimaryType()/addMixin()/removeMixin(). The effect of 'loosing' an item definition on a node caused by setPrimaryType() and removeMixin() must be the same. > Using Node.setPrimaryType() should fail if non-matching childnodes > ------------------------------------------------------------------ > > Key: OAK-5229 > URL: https://issues.apache.org/jira/browse/OAK-5229 > Project: Jackrabbit Oak > Issue Type: Bug > Components: core > Affects Versions: 1.5.14 > Reporter: Tobias Bocanegra > Assignee: Alex Parvulescu > Priority: Critical > Fix For: 1.8, 1.6.1 > > Attachments: OAK-5229.patch, OAK-5229-tests.patch, OAK-5229-v2.patch, > OAK-5229-v3.patch, OAK-5229-v4.patch > > > 1. Assume the following: > {noformat} > /testNode [nt:unstructured] > /unstructured_child [nt:unstructured] > {noformat} > 2. setting "/testNode".setPrimaryType("nt:folder") > 3. save the session. > Altering the primary type works, thus leaving the repository in an > inconsistent state. > Interestingly, subsequent calls to > "/testNiode/unstructured_child".setProperty() will fail: > {noformat} > javax.jcr.nodetype.ConstraintViolationException: OakConstraint0001: > /test_node[[nt:folder]]: No matching definition found for child node > unstructured_child with effective type [nt:unstructured] > {noformat} -- This message was sent by Atlassian JIRA (v6.3.15#6346)