Registering node type with property definitions without validation?
bjornbal Jan 21, 2014 7:02 AMWhen I try to add a new nodetype with for example the type as LONG, I try to add another property definition with constraints. But now I add this constraint as a non-long type (f.e. a simple string like 'hello'). I expected to receive an exception.
I do, when I call session.save() after registerNodeType in the nodeTypeManager, still I am unsure why I need to explicitly call the session.save() to receive this exception since I see a save call in the registerNodeType method. In examples on the net this session.save() is not even called.
But now here comes the issue, when I run the unit test including session.save() where I get the expected exception thrown. But now I add this, this fails:
// First you have 53 node types assertEquals("The size of the total node types is not correct", 53, nodeTypeManager.getAllNodeTypes().getSize()); nodeTypeManager.registerNodeType(nodeTypeTemplate, false); // Save should throw an exception try { session.save(); fail("Should have thrown a RepositoryException!"); } catch (RepositoryException ex) { assertEquals("The thrown cause class should be the same", NumberFormatException.class, ex.getCause().getClass()); } // Then it should stay at 53! assertEquals("The size of the total node types is not correct", 53, nodeTypeManager.getAllNodeTypes().getSize());
It all goes fine, until the last line. This assertion fails. There are 54 node types instead of 53! I believe this behavoir is not intended.
When I try to call to fetch data, I get the following exception and this is the point where you see the data turned inconsistent.
This log appears:
java.lang.NumberFormatException: For input string: "fqdsf" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Long.parseLong(Long.java:410) at java.lang.Long.parseLong(Long.java:468) at org.modeshape.jcr.JcrPropertyDefinition$LongConstraintChecker.parseValue(JcrPropertyDefinition.java:846) at org.modeshape.jcr.JcrPropertyDefinition$LongConstraintChecker.parseValue(JcrPropertyDefinition.java:826) at org.modeshape.jcr.JcrPropertyDefinition$RangeConstraintChecker.parseValueConstraint(JcrPropertyDefinition.java:692) at org.modeshape.jcr.JcrPropertyDefinition$RangeConstraintChecker.<init>(JcrPropertyDefinition.java:620) at org.modeshape.jcr.JcrPropertyDefinition$LongConstraintChecker.<init>(JcrPropertyDefinition.java:831) at org.modeshape.jcr.JcrPropertyDefinition.createChecker(JcrPropertyDefinition.java:470) at org.modeshape.jcr.JcrPropertyDefinition.getMinimumValue(JcrPropertyDefinition.java:332) at org.modeshape.jcr.NodeTypeSchemata.addAllNodesTable(NodeTypeSchemata.java:230) at org.modeshape.jcr.NodeTypeSchemata.<init>(NodeTypeSchemata.java:138) at org.modeshape.jcr.RepositoryNodeTypeManager.getRepositorySchemata(RepositoryNodeTypeManager.java:293) at org.modeshape.jcr.JcrRepository$RepositoryMonitorFactory.indexingMonitor(JcrRepository.java:1917) at org.modeshape.jcr.JcrRepository$RepositoryMonitorFactory.createMonitor(JcrRepository.java:1912) at org.modeshape.jcr.txn.Transactions.newMonitor(Transactions.java:243) at org.modeshape.jcr.txn.SynchronizedTransactions$SynchronizedTransaction.<init>(SynchronizedTransactions.java:165) at org.modeshape.jcr.txn.SynchronizedTransactions.begin(SynchronizedTransactions.java:77) at org.modeshape.jcr.cache.RepositoryCache.runInTransaction(RepositoryCache.java:468) at org.modeshape.jcr.cache.RepositoryCache.workspace(RepositoryCache.java:836) at org.modeshape.jcr.cache.RepositoryCache.getWorkspaceCache(RepositoryCache.java:1047) at org.modeshape.jcr.JcrSession.<init>(JcrSession.java:180) at org.modeshape.jcr.JcrXaSession.<init>(JcrXaSession.java:49) at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:693) at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:155) at be.admb.jcr.modeshape.manager.jcr.impl.JcrSessionFactory.getSession(JcrSessionFactory.java:77) at be.admb.jcr.modeshape.manager.jcr.util.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:77) at be.admb.jcr.modeshape.manager.jcr.util.SessionFactoryUtils.getSession(SessionFactoryUtils.java:109) at be.admb.jcr.modeshape.manager.jcr.impl.JcrTemplate.execute(JcrTemplate.java:77) at be.admb.jcr.modeshape.manager.dao.impl.JcrDaoImpl.getCompleteNode(JcrDaoImpl.java:77) at be.admb.jcr.modeshape.manager.service.impl.JcrServiceImpl.getNode(JcrServiceImpl.java:67)
I suppose this is a bug. If wished I can report this to JIRA including an unit test.
Note: The server does start up, but I need to wipe out the MySQL data since it is completely unusable now. I cannot even unregister the nodetype, it throws the same exception.