You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Kamil Nezval <ka...@xitee.com> on 2011/04/15 13:29:15 UTC
Create readonly property
Hi,
I'm trying to register my own node that contains a read-only property (set
only when the node is created). So my CND definition looks like this:
[test:nodeDef] > mix:versionable
- test:protectedproperty (STRING) protected mandatory
But then I do not know how to create the node and insert it into my
repository. Because when I try this:
Node rootnode = session.getRootNode();
Node testNode = rootnode.addNode("testNode", "test:nodeDef");
testnode.setProperty("test:protectedproperty", "my text");
session.save();
I get an error "javax.servlet.ServletException:
javax.jcr.nodetype.ConstraintViolationException: Unable to perform
operation. Node is protected."
So is there a way how to create a node, set its properties and then insert
it into a repository? Or how should I reach my goal?
Thanks a lot for any help.
Regards
Kamil
RE: Create readonly property
Posted by Kamil Nezval <ka...@xitee.com>.
Hi,
Really nobody knows a solution? I suppose there is an API in a jackrabbit
library that allows it, but I haven't found any so far. Could anybody please
help me? Thanks a lot.
Kamil
-----Original Message-----
Hi,
I'm trying to register my own node that contains a read-only property (set
only when the node is created). So my CND definition looks like this:
[test:nodeDef] > mix:versionable
- test:protectedproperty (STRING) protected mandatory
But then I do not know how to create the node and insert it into my
repository. Because when I try this:
Node rootnode = session.getRootNode();
Node testNode = rootnode.addNode("testNode", "test:nodeDef");
testnode.setProperty("test:protectedproperty", "my text");
session.save();
I get an error "javax.servlet.ServletException:
javax.jcr.nodetype.ConstraintViolationException: Unable to perform
operation. Node is protected."
So is there a way how to create a node, set its properties and then insert
it into a repository? Or how should I reach my goal?
Thanks a lot for any help.
Regards
Kamil
Re: Create readonly property
Posted by Alexander Klimetschek <ak...@adobe.com>.
On 15.04.11 04:29, "Kamil Nezval" <ka...@xitee.com> wrote:
>I'm trying to register my own node that contains a read-only property (set
>only when the node is created). So my CND definition looks like this:
>
>[test:nodeDef] > mix:versionable
>- test:protectedproperty (STRING) protected mandatory
>
>But then I do not know how to create the node and insert it into my
>repository. Because when I try this:
>
>Node rootnode = session.getRootNode();
>Node testNode = rootnode.addNode("testNode", "test:nodeDef");
>testnode.setProperty("test:protectedproperty", "my text");
>session.save();
>
>I get an error "javax.servlet.ServletException:
>javax.jcr.nodetype.ConstraintViolationException: Unable to perform
>operation. Node is protected."
Protected properties/nodes are only available to the implementation, you
can't define custom ones (as protected means that you can't change them
through the JCR API).
This was asked multiple times already:
http://markmail.org/message/x6meweddg4bys6tr
Regards,
Alex
--
Alexander Klimetschek
Developer // Adobe (Day) // Berlin - Basel