[ https://issues.apache.org/jira/browse/OAK-5229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15839605#comment-15839605 ]
Thomas Mueller commented on OAK-5229: ------------------------------------- Ah I see your patch also changes the TypeEditor! My patch (untested) would be: {noformat} --- src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java (revision 1779322) +++ src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java (working copy) @@ -190,6 +190,16 @@ checkRequiredType(after, requiredType); checkValueConstraints(definition, after, requiredType); } + if (before != null && JCR_PRIMARYTYPE.equals(after.getName())) { + // check constraints of all child nodes and all properties + for (String c : builder.getChildNodeNames()) { + childNodeAdded(c, builder.getChildNode(c) + .getNodeState()); + } + for (PropertyState p : builder.getProperties()) { + propertyAdded(p); + } + } } } } --- src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java (revision 1779322) +++ src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java (working copy) @@ -1872,7 +1872,6 @@ } @Test - @Ignore("OAK-5229") public void setPrimaryTypeShouldFail() throws RepositoryException { Node testNode = getNode(TEST_PATH); assertEquals("nt:unstructured", testNode.getPrimaryNodeType().getName()); @@ -1888,6 +1887,7 @@ fail("Changing the primary type to nt:folder should fail."); } catch (RepositoryException e) { // ok + getAdminSession().refresh(false); } Session session2 = createAnonymousSession(); {noformat} > 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.6 > > Attachments: OAK-5229.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.4#6332)