jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jaka Jaksic" <jaka.jak...@telemach.net>
Subject Primary item inheritance
Date Thu, 20 Jul 2006 09:44:35 GMT
Hi!

We define our repository structure using a CND file. In it we override
several built-in node types, namely nt:file and nt:resource. The problem is
that the subtypes don't inherit the primary item definition, so the
resulting types have no primary item. And we can't simply redefine the
primary item property because of an "ambigous definition" error.

Is this a bug or by desing? How are primary item definitions supposed to be
inherited, if at all? If they are supposed to be inherited, what would
happen in case of multiple inheritance, if more than one supertype defines
the primary item?

For a workaround I call the following method during CND import to achieve
primary item inheritance:

    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) {
                    ntd.setPrimaryItemName(piName);
                    return;
                }
            } catch (NoSuchNodeTypeException e) {}
        }
    }


Regards,
Jaka


Mime
View raw message