> look at using
> the getChildNodeDefinitions() while drawing the form
this is what I am/was after at.

> For example, on an nt:file node, the user simply
> shouldn't see the "new sub-node" button.
again, this was my intention

I will follwow your advice
Thx
Clemens


> -----Original Message-----
> From: Justin Edelson [mailto:[email protected]]
> Sent: Thursday, September 09, 2010 8:01 PM
> To: [email protected]
> Subject: Re: adding a subnode to a resource/node which has a
> dot('.') in
> its name does not work
>
>
>
>
> On 9/9/10 10:28 AM, Clemens Wyss wrote:
> > there is also the
> >   NodeType#canAddChildNode(java.lang.String childNodeName)
> > method. So, shouldn't/couldn't it be:
> >
> > if ( node.getPrimaryNodeType().
> >         canAddChildNode("hello"))
> > {
> >     for(NodeType mixin: node.getMixinNodeTypes()) {
> >       if (nodeType.canAddChildNode("hello")) {
> >         return obamaSlogan;
> >       }
> >     }
> > }
> > return noChance;
> The two-argument version is more precise. For example, if node is of
> type nt:folder (and doesn't have any mixins):
>
> node.getPrimaryNodeType().canAddChildNode("foo") - returns true
> node.getPrimaryNodeType().canAddChildNode("foo", "nt:file") -
> returns true
> node.getPrimaryNodeType().canAddChildNode("foo", "nt:unstructured") -
> returns false
>
> In the context of the explorer, I really think you should
> look at using
> the getChildNodeDefinitions() while drawing the form rather than
> checking if a node is addable after the user has submitted the form (I
> think that's what you're talking about).
>
> The check above will be done by the repository anyway, so there's no
> need for you to do it manually. What you can do is prevent
> the user from
> trying to create a child node (or property for that matter) which will
> fail. For example, on an nt:file node, the user simply
> shouldn't see the
> "new sub-node" button.
>
> >
> > AND why doesn't Node have a convenience method canAddChildNode():
> Something like this would probably fit nicely into the JCR
> Commons library.
>
> Justin
>
> >
> > public boolean canAddChildNode() {
> > if ( this.getPrimaryNodeType().
> >         canAddChildNode("hello"))
> > {
> >     for(NodeType mixin: this.getMixinNodeTypes()) {
> >       if ( nodeType.canAddChildNode("hello")) {
> >         return true;
> >       }
> >     }
> > }
> > return false;
> > }
> >
> >> -----Original Message-----
> >> From: Felix Meschberger [mailto:[email protected]]
> >> Sent: Thursday, September 09, 2010 3:57 PM
> >> To: [email protected]
> >> Subject: Re: adding a subnode to a resource/node which has a
> >> dot('.') in
> >> its name does not work
> >>
> >>
> >> Hi,
> >>
> >> There is but it is a bit complicated. You have to check the
> >> primary and
> >> mixin node types of the parent node to be.
> >>
> >>    String childName;
> >>    String childPrimaryNodeType;
> >>
> >>    if (node.getPrimaryNodeType().
> >>         canAddChildNode(childName, childPrimaryNodeType)) {
> >>       return yesWeCan;
> >>    }
> >>
> >>    for(NodeType mixin: node.getMixinNodeTypes()) {
> >>      if (nodeType.canAddChildNode(childName,
> childPrimaryNodeType)) {
> >>        return yesWeCan;
> >>      }
> >>    }
> >>
> >>    return noChance;
> >>
> >> Same can be done for properties with the methods
> >> NodeType.canSetProperty(...).
> >>
> >> Hope this helps.
> >>
> >> Regards
> >> Felix
> >>
> >>
> >> On 09.09.2010 15:33, Clemens Wyss wrote:
> >>> Coming back to my permission question:
> >>> is there no way (no need) to determine whether a given
> >> nodetype allows adding subnodes?
> >>>
> >>>> The nt:file nodetype (without any other
> >>>> mixin node types assigned to the node) only supports one
> >> single child
> >>>> node whose name is "jcr:content".
> >>> where/how is this declared?
> >>>
> >>>> -----Original Message-----
> >>>> From: Felix Meschberger [mailto:[email protected]]
> >>>> Sent: Thursday, September 09, 2010 3:17 PM
> >>>> To: [email protected]
> >>>> Subject: Re: adding a subnode to a resource/node which has a
> >>>> dot('.') in
> >>>> its name does not work
> >>>>
> >>>>
> >>>> Hi,
> >>>>
> >>>> On 09.09.2010 15:11, Clemens Wyss wrote:
> >>>>> so this use case should cause an error?
> >>>>
> >>>> Yes, that's expected, but ...
> >>>>
> >>>>>
> >>>>> AND on the server side
> >>>>>   session.checkPermission(path, "add_node"); // path being:
> >>>> "/sling-logo.png"
> >>>>> should return false, right?
> >>>>
> >>>> No. It is not a question of permission. It is a question
> of how the
> >>>> nt:file nodetype is defined: The nt:file nodetype (without
> >> any other
> >>>> mixin node types assigned to the node) only supports one
> >> single child
> >>>> node whose name is "jcr:content".
> >>>>
> >>>> So the actual error message is something like
> >>>> "javax.jcr.nodetype.ConstraintViolationException: No child node
> >>>> definition for 1_1284038191454 found in node /sling-logo.png"
> >>>>
> >>>> Regards
> >>>> Felix
> >>>>
> >>>>>
> >>>>> Regards
> >>>>> Clemens
> >>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: Felix Meschberger [mailto:[email protected]]
> >>>>>> Sent: Thursday, September 09, 2010 3:02 PM
> >>>>>> To: [email protected]
> >>>>>> Subject: Re: adding a subnode to a resource/node which has a
> >>>>>> dot('.') in
> >>>>>> its name does not work
> >>>>>>
> >>>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>> I can confirm this behaviour with the trailing "/*".
> >>>>>>
> >>>>>> If you POST to "http://localhost:8080/sling-logo.png/";
> >> -- note the
> >>>>>> trailing slash without an astersik ! -- your actually
> >> get a failure
> >>>>>> which is expected in this case because you cannot add any
> >>>> node below a
> >>>>>> plain nt:file node as the sling-logo.png is.
> >>>>>>
> >>>>>> Would you mind posting an issue for this ? Thanks alot.
> >>>>>>
> >>>>>> Regards
> >>>>>> Felix
> >>>>>>
> >>>>>> On 09.09.2010 10:36, Clemens Wyss wrote:
> >>>>>>> before entering a bug(?) in jira, I would like to discuss
> >>>>>> this issue here.
> >>>>>>>
> >>>>>>> When I (try) add a subnode to a resource which has a dot
> >>>>>> ('.') in its name, it doesn't work AND a 200-response is
> >>>>>> sent, indicating that content without the dot and extension
> >>>>>> was modified.
> >>>>>>>
> >>>>>>> E.g. (with Sling Explorer):
> >>>>>>> select node "/sling-logo.png"
> >>>>>>> type 'juhu' into "Name hint" field
> >>>>>>> click 'new sub-node'
> >>>>>>>
> >>>>>>> --> Response:
> >>>>>>> Content modified /sling-logo
> >>>>>>> Status  200
> >>>>>>> Message         OK
> >>>>>>> Location        /sling-logo
> >>>>>>> Parent Location         /
> >>>>>>> Path    /sling-logo
> >>>>>>> Referer         http://localhost:8080/.explorer.html
> >>>>>>>
> >>>>>>> This very POST-request is sent to
> >>>>>> http://localhost:8080/sling-logo.png/*
> >>>>>>>
> >>>>>>> Feature or bug?
> >>>>>>
> >>>>
> >>
>
>

Reply via email to