jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: How to disallow node from having same name siblings?
Date Wed, 21 May 2008 10:30:23 GMT

On Wed, May 21, 2008 at 11:55 AM, saurav gangulyy
<vijay_makhija@yahoo.com> wrote:
> Can u plz illustrate this with example code?
> Node nod = root.addNode("par7");
> Node chld = nod.addNode("chld1");
> wht do I need to do in order to ensure 'chld1' can't be added again?

You can define a custom node type for the "par7" node or use a
standard one like nt:folder that doesn't allow same name siblings.

For example:

    Node node = root.addNode("par7", "nt:folder");
    Node child = node.addNode("child1", "nt:file");

Note that nt:folder only allows nt:hierarchyNode children, so you need to:

a) make your content fit the nt:folder/nt:file structure (not that
nt:file allows an unstructured jcr:content child node),
b) add custom node types that extend nt:hierarchyNode, or
c) use a custom node type instead of nt:folder.


Jukka Zitting

View raw message