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;

AND why doesn't Node have a convenience method canAddChildNode():

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