You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Michael Singer <ja...@it-specialist.at> on 2006/02/01 11:44:02 UTC

Behavior of CompactNodeTypeDefReader in contribution nt-ns-util

Hi list,

I wrote a simple program which uses the nt-ns-util contribution to
register custom node types written in CND language.

I defined the following (very simple) custom node types:

<test = 'http://foo.bar/test'>
[test:firstnodetype]
+ test:secondnodetype mandatory

<test = 'http://foo.bar/test'>
[test:secondnodetype] > test:firstnodetype
+ test:thirdnodetype

<test = 'http://foo.bar/test'>
[test:thirdnodetype] > test:secondnodetype
- test:catalog (string)  < 'URI', 'URN', 'DOI', 'ISBN', 'ISSN'
- test:entry (string) m


In the resulting custom_nodetypes.xml each of the custom nodes has a
supertype of "nt:base" but I didn't explicitely define a supertype of
"nt:base" for [test:secondnodetype] and [test:thirdnodetype].

I think this behavior is wrong since the method getDeclaredSupertypes()
of class NodeType always returns "nt:base" plus the explicitely declared
Supertype (which it e.g. does not for "nt:folder").

I changed the code to avoid the creation of "nt:base" supertypes if not
explicitely declared (if no supertype is declared "nt:base" still gets
created). This patch will do the change:

Index:
Z:/_DATA/workspace/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
===================================================================
---
Z:/_DATA/workspace/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
(revision 374032)
+++
Z:/_DATA/workspace/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
(working copy)
@@ -206,7 +206,7 @@
             // add nt:base to superclasses if not mixin
             if (!ntd.isMixin()) {
                 HashSet superTypes = new
HashSet(Arrays.asList(ntd.getSupertypes()));
-                if (!superTypes.contains(QName.NT_BASE)) {
+                if (superTypes.size() == 0) {
                     superTypes.add(QName.NT_BASE);
                     ntd.setSupertypes((QName[]) superTypes.toArray(new
QName[superTypes.size()]));
                 }

Can someone tell me if I am missing something?

-- 
kind regards

Michael

Re: Behavior of CompactNodeTypeDefReader in contribution nt-ns-util

Posted by Michael Singer <ja...@it-specialist.at>.
this issue arraised due to my weird implementation of building a
NodeType-Dependancy Tree ;-)

I am adding each Type to its declared SuperTypes (encapsulated as
TreeNodes of course) and this generated tree looks realy strange because
every type is added to nt:base AND its declared SuperTypes.

Anyway, thank you for fixing it...

Tobias Bocanegra wrote:
> hi michael,
> you are right. this extra declaration is not needed (but does not do
> any harm neither). i will fix this. thanks for reporting this.
> 
> regads, toby
> 
> On 2/1/06, Michael Singer <ja...@it-specialist.at> wrote:
>> Hi list,
>>
>> I wrote a simple program which uses the nt-ns-util contribution to
>> register custom node types written in CND language.
>>
>> I defined the following (very simple) custom node types:
>>
>> <test = 'http://foo.bar/test'>
>> [test:firstnodetype]
>> + test:secondnodetype mandatory
>>
>> <test = 'http://foo.bar/test'>
>> [test:secondnodetype] > test:firstnodetype
>> + test:thirdnodetype
>>
>> <test = 'http://foo.bar/test'>
>> [test:thirdnodetype] > test:secondnodetype
>> - test:catalog (string)  < 'URI', 'URN', 'DOI', 'ISBN', 'ISSN'
>> - test:entry (string) m
>>
>>
>> In the resulting custom_nodetypes.xml each of the custom nodes has a
>> supertype of "nt:base" but I didn't explicitely define a supertype of
>> "nt:base" for [test:secondnodetype] and [test:thirdnodetype].
>>
>> I think this behavior is wrong since the method getDeclaredSupertypes()
>> of class NodeType always returns "nt:base" plus the explicitely declared
>> Supertype (which it e.g. does not for "nt:folder").
>>
>> I changed the code to avoid the creation of "nt:base" supertypes if not
>> explicitely declared (if no supertype is declared "nt:base" still gets
>> created). This patch will do the change:
>>
>> Index:
>> Z:/_DATA/workspace/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
>> ===================================================================
>> ---
>> Z:/_DATA/workspace/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
>> (revision 374032)
>> +++
>> Z:/_DATA/workspace/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
>> (working copy)
>> @@ -206,7 +206,7 @@
>>             // add nt:base to superclasses if not mixin
>>             if (!ntd.isMixin()) {
>>                 HashSet superTypes = new
>> HashSet(Arrays.asList(ntd.getSupertypes()));
>> -                if (!superTypes.contains(QName.NT_BASE)) {
>> +                if (superTypes.size() == 0) {
>>                     superTypes.add(QName.NT_BASE);
>>                     ntd.setSupertypes((QName[]) superTypes.toArray(new
>> QName[superTypes.size()]));
>>                 }
>>
>> Can someone tell me if I am missing something?
>>
>> --
>> kind regards
>>
>> Michael
>>
> 
> 
> --
> -----------------------------------------< tobias.bocanegra@day.com >---
> Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
> T +41 61 226 98 98, F +41 61 226 98 97
> -----------------------------------------------< http://www.day.com >---

-- 
kind regards

Michael

Re: Behavior of CompactNodeTypeDefReader in contribution nt-ns-util

Posted by Tobias Bocanegra <to...@day.com>.
hi michael,
you are right. this extra declaration is not needed (but does not do
any harm neither). i will fix this. thanks for reporting this.

regads, toby

On 2/1/06, Michael Singer <ja...@it-specialist.at> wrote:
> Hi list,
>
> I wrote a simple program which uses the nt-ns-util contribution to
> register custom node types written in CND language.
>
> I defined the following (very simple) custom node types:
>
> <test = 'http://foo.bar/test'>
> [test:firstnodetype]
> + test:secondnodetype mandatory
>
> <test = 'http://foo.bar/test'>
> [test:secondnodetype] > test:firstnodetype
> + test:thirdnodetype
>
> <test = 'http://foo.bar/test'>
> [test:thirdnodetype] > test:secondnodetype
> - test:catalog (string)  < 'URI', 'URN', 'DOI', 'ISBN', 'ISSN'
> - test:entry (string) m
>
>
> In the resulting custom_nodetypes.xml each of the custom nodes has a
> supertype of "nt:base" but I didn't explicitely define a supertype of
> "nt:base" for [test:secondnodetype] and [test:thirdnodetype].
>
> I think this behavior is wrong since the method getDeclaredSupertypes()
> of class NodeType always returns "nt:base" plus the explicitely declared
> Supertype (which it e.g. does not for "nt:folder").
>
> I changed the code to avoid the creation of "nt:base" supertypes if not
> explicitely declared (if no supertype is declared "nt:base" still gets
> created). This patch will do the change:
>
> Index:
> Z:/_DATA/workspace/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
> ===================================================================
> ---
> Z:/_DATA/workspace/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
> (revision 374032)
> +++
> Z:/_DATA/workspace/nt-ns-util/src/main/java/org/apache/jackrabbit/core/nodetype/compact/CompactNodeTypeDefReader.java
> (working copy)
> @@ -206,7 +206,7 @@
>             // add nt:base to superclasses if not mixin
>             if (!ntd.isMixin()) {
>                 HashSet superTypes = new
> HashSet(Arrays.asList(ntd.getSupertypes()));
> -                if (!superTypes.contains(QName.NT_BASE)) {
> +                if (superTypes.size() == 0) {
>                     superTypes.add(QName.NT_BASE);
>                     ntd.setSupertypes((QName[]) superTypes.toArray(new
> QName[superTypes.size()]));
>                 }
>
> Can someone tell me if I am missing something?
>
> --
> kind regards
>
> Michael
>


--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---