jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jaka Jaksic (JIRA)" <j...@apache.org>
Subject [jira] Created: (JCR-493) Primary item inheritance or redefinition in CND
Date Fri, 21 Jul 2006 22:20:13 GMT
Primary item inheritance or redefinition in CND

                 Key: JCR-493
                 URL: http://issues.apache.org/jira/browse/JCR-493
             Project: Jackrabbit
          Issue Type: Improvement
          Components: nodetype
    Affects Versions: 1.0.1
            Reporter: Jaka Jaksic
            Priority: Minor

Jackrabbit does not support primary item inheritance among node types. The JCR spec does not
require this, although I think it would be correct. From object methodology's point of view,
a subtype should have all features of its supertype, but currently a subtype of a node type
that has a primary item defined (e.g. nt:resource) has NO primary item, therefore the subtype
can not be used in generic procedures written for its supertype, which breaks the rules of
object orientation. (There may also be other properties besides primary item which are not

Because the JCR spec (section 6.7.8) does not specify exactly how inheritance (especially
of multiple types) should be handled, there is another possible solution to this problem,
which is more Jackrabbit specific: to simply redefine the primary item in each subtype. This
works well if the primary item is set directly thorough NoteTypeDef.setPrimaryItemName() method.
But it produces an error if the subtype's is defined, together with the primary item, in a
CND file and imported with CompactNodeTypeDefReader.

A CND like the following produces "ambigous property definition" exception (EffectiveNodeType.internalMerge(),
line 1051):
[foo:myResource] > nt:resource
  - jcr:data (binary) mandatory

It would be nice if it was possible to define node types like this entirely in CND, not having
to add the primary items manually. Even better would be if there was proper node type inheritance,
but since this is not a JCR requirement, you just do what you think is best.

I created a simple solution for myself, which provides me node type inheritance (not handling
potential conflicts among multiple supertypes):

    private static void inheritPrimaryItemName(final NodeTypeDef ntd, final NodeTypeRegistry
ntReg) {
        if (ntd.getPrimaryItemName() != null) return;
        for (QName superNodeTypeName : ntd.getSupertypes()) {
            try {
                NodeTypeDef superNtd = ntReg.getNodeTypeDef(superNodeTypeName);
                QName piName = superNtd.getPrimaryItemName();
                if (piName != null) {
            } catch (NoSuchNodeTypeException e) {}

I call this during the CND import procedure for every imported node type .

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message