jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting (JIRA)" <j...@apache.org>
Subject [jira] Created: (JCR-2315) Handling of an unspecified item definition template name
Date Mon, 21 Sep 2009 16:59:16 GMT
Handling of an unspecified item definition template name
--------------------------------------------------------

                 Key: JCR-2315
                 URL: https://issues.apache.org/jira/browse/JCR-2315
             Project: Jackrabbit Content Repository
          Issue Type: Improvement
          Components: jackrabbit-spi-commons, nodetype
            Reporter: Jukka Zitting
            Priority: Minor


The code below currently leads to a NPE in registerNodeType() due to the missing name of the
wildcard node definition. Uncommenting the setName() call fixes the issue.

    NodeTypeManager manager = ...;
    NodeTypeTemplate type = manager.createNodeTypeTemplate();
    NodeDefinitionTemplate wildcard = manager.createNodeDefinitionTemplate();
    // wildcard.setName("*");
    type.getNodeDefinitionTemplates().add(wildcard);
    manager.registerNodeType(type, false);

Whatever we do, the code should not throw a NullPointerException. There are basically two
valid approaches:

1) Throw an exception in registerNodeType() if the name of an item definition has not been
specified.

2) Treat item definitions with unspecified names as residual.

Note that a ItemDefinition.getName() is explicitly specified to return null (instead of "*")
when the name has not been set, which seems to suggest that option 1 above is the correct
behaviour. On the other hand, the respective setName() call is specified to accept only a
"syntactically valid JCR name", which would suggest option 2 as the correct alternative.

Personally I tend to like option 2 better, as that's also how I intuitively was using the
API when I ran into the NPE error. That approach was also what Jackrabbit used to do before
the node type handling was recently merged with the SPI code.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message