You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Anirban Majumdar <an...@altair.com> on 2010/01/21 06:22:32 UTC

Problem with Mandatory Properties for Child Nodes

Hello everyone,

 

I've come across somewhat similar posts in the archive, but they all
primarily seemed to be dealing with nt:resource.

The problem I'm facing is that when I have a mandatory property
specified in a child node, then JackRabbit throws a
ConstraintViolationException [mandatory property does not exist]
whenever I try to save the contents of the parent node.

To put it programmatically,

 

I have a parent node:

[av:someParent] > nt:base

+ av:children [av:childNodeType]

= av:childNodeType

Multiple

 

[av:childNodeType] > nt:unstructured

- av:name

mandatory

- av:value

 

 

I have a bean class for someParent node, which contains a List of
childNode instances. In each of the instances I explicitly save the
"name" property. Then using OCM when I persist the parent node instance
- ocm.insert(parentNodeObj) - even this goes through fine. At the line
where I save the transient state of the repository - ocm.save() - I get
the ConstraintViolationException.

 

Any assistance will be truly appreciated.

 

--------

anirban

 


Re: Problem with Mandatory Properties for Child Nodes

Posted by Alexander Klimetschek <ak...@day.com>.
On Thu, Jan 21, 2010 at 06:37, sunild <su...@coreobjects.com> wrote:
> Basically nt:unstructured is the node type which doesnot mandate any
> restriction.  Any property can be added without declaration.

Yes, but he can still add mandatory properties on top of the wildcards
in his subtype. This is a very valid use case - allow everything, but
these few properties must always exist. His nodetype definitions look
good to me.

> But you are in need of a node type where a particular property need to be
> mandatory.  Try extending nt:resource.  It will surely help.

No, nt:resource is quite specific in its use as a resource for
nt:files, so I wouldn't recommend that in general. And it doesn't
change his specific situation, which must be another issue. Normally,
the base node type is nt:base from which you don't have to explicitly
inherit from (like Object in Java).

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

RE: Problem with Mandatory Properties for Child Nodes

Posted by Anirban Majumdar <an...@altair.com>.
Hello Sunil,

Thanks for the input. I tried implementing your suggestion, but I ran
into a prior problem
[http://www.mail-archive.com/users@jackrabbit.apache.org/msg13861.html]
. This problem had actually led me to specify the child node's type as
nt:unstructured]. 
I also tried defining my child node type as a sub-type of
nt:childDefinitionType and nt:nodeType - none of them helped. 
I'm not sure, but I hope this issue is not linked to the
ObjectContentManager [OCM].

Anything else I can try?

--------
anirban

-----Original Message-----
From: sunild [mailto:sunil.dhage@coreobjects.com] 
Sent: Thursday, January 21, 2010 11:08 AM
To: users@jackrabbit.apache.org
Subject: Re: Problem with Mandatory Properties for Child Nodes

Hi Anirban Majumdar,

Basically nt:unstructured is the node type which doesnot mandate any 
restriction.  Any property can be added without declaration.

But you are in need of a node type where a particular property need to 
be mandatory.  Try extending nt:resource.  It will surely help.

[av:childNodeType] > nt:resource

- av:name  mandatory

- av:value

Best Regards,
Sunil Dhage



> Hello everyone,
>
>  
>
> I've come across somewhat similar posts in the archive, but they all
> primarily seemed to be dealing with nt:resource.
>
> The problem I'm facing is that when I have a mandatory property
> specified in a child node, then JackRabbit throws a
> ConstraintViolationException [mandatory property does not exist]
> whenever I try to save the contents of the parent node.
>
> To put it programmatically,
>
>  
>
> I have a parent node:
>
> [av:someParent] > nt:base
>
> + av:children [av:childNodeType]
>
> = av:childNodeType
>
> Multiple
>
>  
>
> [av:childNodeType] > nt:unstructured
>
> - av:name
>
> mandatory
>
> - av:value
>
>  
>
>  
>
> I have a bean class for someParent node, which contains a List of
> childNode instances. In each of the instances I explicitly save the
> "name" property. Then using OCM when I persist the parent node
instance
> - ocm.insert(parentNodeObj) - even this goes through fine. At the line
> where I save the transient state of the repository - ocm.save() - I
get
> the ConstraintViolationException.
>
>  
>
> Any assistance will be truly appreciated.
>
>  
>
> --------
>
> anirban
>
>  
>
>   


Re: Problem with Mandatory Properties for Child Nodes

Posted by sunild <su...@coreobjects.com>.
Hi Anirban Majumdar,

Basically nt:unstructured is the node type which doesnot mandate any 
restriction.  Any property can be added without declaration.

But you are in need of a node type where a particular property need to 
be mandatory.  Try extending nt:resource.  It will surely help.

[av:childNodeType] > nt:resource

- av:name  mandatory

- av:value

Best Regards,
Sunil Dhage



> Hello everyone,
>
>  
>
> I've come across somewhat similar posts in the archive, but they all
> primarily seemed to be dealing with nt:resource.
>
> The problem I'm facing is that when I have a mandatory property
> specified in a child node, then JackRabbit throws a
> ConstraintViolationException [mandatory property does not exist]
> whenever I try to save the contents of the parent node.
>
> To put it programmatically,
>
>  
>
> I have a parent node:
>
> [av:someParent] > nt:base
>
> + av:children [av:childNodeType]
>
> = av:childNodeType
>
> Multiple
>
>  
>
> [av:childNodeType] > nt:unstructured
>
> - av:name
>
> mandatory
>
> - av:value
>
>  
>
>  
>
> I have a bean class for someParent node, which contains a List of
> childNode instances. In each of the instances I explicitly save the
> "name" property. Then using OCM when I persist the parent node instance
> - ocm.insert(parentNodeObj) - even this goes through fine. At the line
> where I save the transient state of the repository - ocm.save() - I get
> the ConstraintViolationException.
>
>  
>
> Any assistance will be truly appreciated.
>
>  
>
> --------
>
> anirban
>
>  
>
>   


Re: Problem with Mandatory Properties for Child Nodes

Posted by Alexander Klimetschek <ak...@day.com>.
On Thu, Jan 21, 2010 at 06:22, Anirban Majumdar
<an...@altair.com> wrote:
> ...
> - av:name
> ...
> I explicitly save the "name" property

Maybe it's just a namespace issue, ie. you set the "name" property
(which is allowed because nt:unstructured allows you to add any
property), but not the "av:name" property. The exception is quite
clear: there is no "av:name" property presented, although it's defined
 as mandatory.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com