You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Tobias Bocanegra (JIRA)" <ji...@apache.org> on 2016/12/07 02:05:59 UTC
[jira] [Commented] (OAK-5229) Using Node.setPrimaryType() should
fail if non-matching childnodes
[ https://issues.apache.org/jira/browse/OAK-5229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15727400#comment-15727400 ]
Tobias Bocanegra commented on OAK-5229:
---------------------------------------
{code}
@Test
public void setPrimaryTypeFails() throws RepositoryException {
Node testNode = getNode(TEST_PATH);
assertEquals("nt:unstructured", testNode.getPrimaryNodeType().getName());
assertEquals("nt:unstructured", testNode.getProperty("jcr:primaryType").getString());
// create subnode that would not be allowed with nt:folder
testNode.addNode("unstructured_child", NodeType.NT_UNSTRUCTURED);
getAdminSession().save();
testNode.setPrimaryType("nt:folder");
try {
getAdminSession().save();
/*1*/ fail("Changing the primary type to nt:folder should fail.");
} catch (RepositoryException e) {
// ok
}
Session session2 = createAnonymousSession();
try {
testNode = session2.getNode(TEST_PATH);
/*2*/ assertEquals("nt:unstructured", testNode.getPrimaryNodeType().getName());
assertEquals("nt:unstructured", testNode.getProperty("jcr:primaryType").getString());
} finally {
session2.logout();
}
getAdminSession().getNode(TEST_PATH + "/unstructured_child").setProperty("test", "value");
/*3*/ getAdminSession().save();
}
{code}
Sample test:
1. saving the changed primary type should fail.
2. if the check for (1) is disabled, then (2) fails. and nodetype indeed is now nt:folder
3. if the check for (1) and (2) is disabled, then (3) fails with exception mentioned above
> 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
>
> 1. Assume the following:
> {noformat}
> /testNode [nt:unstructured]
> /unstructured_child [nt:unstructured]
> {noformat}
> 2. setting "/testNode".setPrimaryType("nt:folder")
> the above works, leaving the repository in an inconsistent state.
> 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)