Yes, it seems like I was thinking. I should create my own type like Guo Du propose and make some kind of wrapper like Tobias propose. I wanted to make sure there was not something I missed before working on a solution.

I was looking for something like changing the default behavior of nt:structured, but I think it may cause problems since /jcr:system & friends use SNS.


thank you,


Frank


Le 09-11-13 à 17:06, Guo Du a écrit :

2009/11/13 François Cassistat <[email protected]>:
Is there an easy way to disallow SNS other than defining a new node type and setting all new nodes in this type, so I can get ItemExistException on save to prevent SNS from happening?

The nt:folder doesn't allow SNS. If your application doesn't like
nt:folder, you may create a custom node type like following sample.
It's the same as nt:unstructured except the SNS validation.

        <nodeType name="nt:nosamesiblings"
                  isMixin="false"
                  hasOrderableChildNodes="true">
            <supertypes>
                <supertype>nt:base</supertype>
            </supertypes>
            <childNodeDefinition name="*"
defaultPrimaryType="nt:xunstructured" sameNameSiblings="false"
                          autoCreated="false" mandatory="true"
                          onParentVersion="IGNORE" protected="false"/>
            <propertyDefinition name="*"
                                requiredType="undefined"
                                autoCreated="false"
                                mandatory="false"
                                onParentVersion="COPY"
                                protected="false"
                                multiple="false"/>
            <propertyDefinition name="*"
                                requiredType="undefined"
                                autoCreated="false"
                                mandatory="false"
                                onParentVersion="COPY"
                                protected="false"
                                multiple="true"/>
        </nodeType>

As this node type could be interesting for some people, it might be
good to provide by default.

-Guo


Le 09-11-13 à 17:21, Tobias Bocanegra a écrit :

hi,

2009/11/13 François Cassistat <[email protected]>:
David's Model gives good advices and I already followed his suggestions.

However, there is something I don't understand. He says "Learn to love nt:unstructured (& friends) in development." (and I think he is right) and later, "Beware of Same Name Siblings (SNS)". But, in the documentation, nt:unstructured allows SNS.

Is there an easy way to disallow SNS other than defining a new node type and setting all new nodes in this type, so I can get ItemExistException on save to prevent SNS from happening?

unfortunately not an easy one like changing the configuration. i see
the following options:
1) create your own "nt:unstructured"
2) create a wrapper around the JCR interface and do the check yourself
in 'addNode() and move()'. theoretically there are many more places
you need to check - but those are the most common ones.
3) hack the builtin_nodtypes.cnd and change the definition of
nt:unstructured. but i strongly discourage doing this. you're probably
have a lot of problems later.

regards, toby

Reply via email to