hi jaka
On 7/21/06, Jaka Jaksic <[EMAIL PROTECTED]> wrote:
Hi Stefan!
Yes, setting the primary item directly in the node type definition works
fine (in fact, that's the way I'm doing it now).
But an error occurs if you try to define a subtype's primary item in a CND
file and import it 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.
agreed, please create a jira issue:
http://issues.apache.org/jira/secure/CreateIssue!default.jspa
cheers
stefan
-----Original Message-----
From: Stefan Guggisberg [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 20, 2006 3:58 PM
To: [email protected]
Subject: Re: Primary item inheritance
hi jaka
On 7/20/06, Jaka Jaksic wrote:
> 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.
strange, i quickly tested this with the following code snippet:
NodeTypeRegistry ntReg = ((NodeTypeManagerImpl)
wsp.getNodeTypeManager()).getNodeTypeRegistry();
NodeTypeDef ntd = new NodeTypeDef();
ntd.setName(new QName("", "myResource"));
ntd.setSupertypes(new QName[]{QName.NT_RESOURCE});
ntd.setPrimaryItemName(QName.JCR_MIMETYPE);
List ntDefs = new ArrayList();
ntDefs.add(ntd);
ntReg.registerNodeTypes(ntDefs);
Node n = root.addNode("foo", "myResource");
n.setProperty("jcr:mimeType", "application/octet-stream");
Item pi = n.getPrimaryItem(); // -> returns /foo/jcr/mimeType
i.e. i was able to register and use a subtype of nt:resource that specifies
a custom primary item (jcr:mimeType).
please provide a simple test case that demonstrates your issue.