Issue on (programmatically) removing a property definition using ModeShape 3.2
nl Jun 4, 2013 5:36 AMHi,
I am stuck on removing a property definition which was just added to a mixin before.
I have a mixing called "dmsmix:filecontent" and create a "dmsmix:owner" property using:
{code}
NodeTypeManager ntmgr = session.getWorkspace().getNodeTypeManager();
NodeType nodeType = ntmgr.getNodeType("dmsmix:filecontent");
NodeTypeTemplate nodeTypeTemplate = ntmgr.createNodeTypeTemplate(nodeType);
PropertyDefinitionTemplate tp = ntmgr.createPropertyDefinitionTemplate();
tp.setName("dmsmix:owner");
// set other type and other properties
...
nodeTypeTemplate.getPropertyDefinitionTemplates().add(tp);
ntmgr.registerNodeType(nodeTypeTemplate, true);
{code}
Afterwards I try to remove it via
{code}
NodeTypeManager ntmgr = session.getWorkspace().getNodeTypeManager();
NodeType nodeType = ntmgr.getNodeType("dmsmix:filecontent");
NodeTypeTemplate nodeTypeTemplate = ntmgr.createNodeTypeTemplate(nodeType);
List<PropertyDefinitionTemplate> pts = nodeTypeTemplate.getPropertyDefinitionTemplates();
Iterator<PropertyDefinitionTemplate> pit = pts.iterator();
while (pit.hasNext()) {
PropertyDefinitionTemplate pi = pit.next();
if (pi.getName().equals("dmsmix:owner")) {
pit.remove();
}
}
ntmgr.registerNodeType(nodeTypeTemplate, true);
{code}
and the following exception is thrown
{code}
org.modeshape.jcr.cache.NodeNotFoundInParentException: Cannot locate child node: 7d98ad9317f1e7/jcr:system/jcr:nodeTypes/{http???www.mycompany.com?dms?mix?1.0}filecontent/{http???www.mycompany.com?dms?mix?1.0}removeMe/String/1 within parent: 7d98ad9317f1e7/jcr:system/jcr:nodeTypes/{http???www.mycompany.com?dms?mix?1.0}filecontent
at org.modeshape.jcr.cache.document.SessionNode.getSegment(SessionNode.java:417)
at org.modeshape.jcr.cache.document.SessionNode.getPath(SessionNode.java:449)
at org.modeshape.jcr.cache.PathCache.getPath(PathCache.java:49)
at org.modeshape.jcr.cache.document.WritableSessionCache.persistChanges(WritableSessionCache.java:852)
at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:382)
at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:347)
at org.modeshape.jcr.SystemContent.save(SystemContent.java:112)
at org.modeshape.jcr.RepositoryNodeTypeManager.registerNodeTypes(RepositoryNodeTypeManager.java:523)
at org.modeshape.jcr.RepositoryNodeTypeManager.registerNodeType(RepositoryNodeTypeManager.java:377)
at org.modeshape.jcr.JcrNodeTypeManager.registerNodeType(JcrNodeTypeManager.java:489)
...
{code}
I have no clue what causes this exception. Can anyone "enlight" me?
Thanks, Niels