jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From saurav gangulyy <vijay_makh...@yahoo.com>
Subject Re: How to disallow node from having same name siblings?
Date Wed, 21 May 2008 12:42:41 GMT

Hi,
     I get following exception at line 5 on execution of code:
          1    Repository repository = new TransientRepository();	
	  2    Session ses = repository.login(new
SimpleCredentials("username","password".toCharArray()));
          3  Node node = root.addNode("par7", "nt:folder");
	  4 Node child = node.addNode("child1", "nt:file");    
	  5 ses.save();
javax.jcr.nodetype.ConstraintViolationException: /par7/child1: mandatory
child node {http://www.jcp.org/jcr/1.0}content does not exist
Can u plz tell reason for the same?

 Regards,
Vijay 

Jukka Zitting wrote:
> 
> Hi,
> 
> 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.
> 
> BR,
> 
> Jukka Zitting
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-disallow-node-from-having-same-name-siblings--tp17358205p17364196.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message