jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eder, Johann" <j...@manz.at>
Subject AW: Recursive Node Typs
Date Fri, 26 Aug 2011 12:09:45 GMT
Hi Stefan,

thanks for your help. The import of the cnd file with recursive node typs works now.

Cheers 
Johann

-----Ursprüngliche Nachricht-----
Von: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com] 
Gesendet: Donnerstag, 11. August 2011 15:44
An: users@jackrabbit.apache.org
Betreff: Re: Recursive Node Typs

On Tue, Aug 9, 2011 at 4:57 PM, Eder, Johann <joed@manz.at> wrote:
>
> Hi Stefan,
>
> now I have set up a Jackrabbit 2.2.7 enviroment (sooner or later we have to upgrade)
and tried to import the cnd file (see last mail below) but I got the following exceptions:
>
> ------------------------------------
> org.apache.jackrabbit.commons.cnd.ParseException: Error setting node type name default:li
(cnd input stream, line 9)
>        at org.apache.jackrabbit.commons.cnd.Lexer.fail(Lexer.java:219)
>        at org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader.doNodeTypeName(CompactNodeTypeDefReader.java:268)
>        at org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader.parse(CompactNodeTypeDefReader.java:211)
>        at org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader.<init>(CompactNodeTypeDefReader.java:163)
>        at org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader.<init>(CompactNodeTypeDefReader.java:139)
>        at org.apache.jackrabbit.commons.cnd.CndImporter.registerNodeTypes(CndImporter.java:141)
>        at
> ...
> Caused by: javax.jcr.nodetype.ConstraintViolationException: javax.jcr.NamespaceException:
default: is not a registered namespace prefix.
>        at org.apache.jackrabbit.spi.commons.nodetype.NodeTypeTemplateImpl.setName(NodeTypeTemplateImpl.java:119)
>        at org.apache.jackrabbit.commons.cnd.TemplateBuilderFactory$NodeTypeTemplateBuilder.setName(TemplateBuilderFactory.java:120)
>        at org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader.doNodeTypeName(CompactNodeTypeDefReader.java:266)
>        ... 25 more ....
> ----------------------------------
>
> Here is the snippet I used to import the cnd:
> ------------------------------
>    public static void importNodeTypes(Session s, String filename) throws Exception
{
>
>        log.info( "importing nodetypedefs ...");
>
>        FileReader cnd = new FileReader(filename);
>
>        CndImporter.registerNodeTypes(cnd, "cnd input stream", s.getWorkspace().getNodeTypeManager(),
s.getWorkspace().getNamespaceRegistry(), s.getValueFactory(), true);
>
>        log.info( "Done importing nodetypedefs.");
>    }
> -----------------------------
>
> I also have tried to register the namespace with
> s.getWorkspace().getNamespaceRegistry().registerNamespace("default", "");

the 'empty' namespace is reserved, see [0].

either specify a non-empty namespace uri
or remove the 'default' namespace declaration
and in your cnd.

cheers
stefan

[0] http://www.day.com/specs/jcr/2.0/3_Repository_Model.html#3.5.1.1
Empty Prefix and Empty Namespace


>
> but with the same error.
> There is only one workspace.
>
>
> Any hint is appreciated.
>
> Cheers
> Johann
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com]
> Gesendet: Donnerstag, 4. August 2011 15:13
> An: users@jackrabbit.apache.org
> Betreff: Re: Recursive Node Typs
>
> On Thu, Aug 4, 2011 at 2:41 PM, Eder, Johann <joed@manz.at> wrote:
>> Hi Stefan,
>>
>> thanks for the snippet.
>> I guess it works fine with Jackrabbit 2.x.
>>
>> We still use Jackrabbit 1.4.5. Is there a way to import the cnd file successfully?
>
> you'd had saved me some time if you had made it clear that you're
> refering to a 3-year old release... :(
>
> and no, i don't know the answer to your question.
>
> cheers
> stefan
>
>>
>> Cheers
>> Johann
>>
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com]
>> Gesendet: Mittwoch, 3. August 2011 18:38
>> An: users@jackrabbit.apache.org
>> Betreff: Re: Recursive Node Typs
>>
>> On Tue, Aug 2, 2011 at 10:06 AM, Eder, Johann <joed@manz.at> wrote:
>>> Hi Stefan,
>>>
>>> Thanks for the hints.
>>>
>>> I guess I have not made myself clear.
>>>
>>> I have a method which imports the NodeTypDef via cnd file perfectly.
>>> But when I try to import and register Nodes like
>>>
>>> ----------
>>> <mix = 'http://www.jcp.org/jcr/mix/1.0'>
>>> <nt = 'http://www.jcp.org/jcr/nt/1.0'>
>>> <jcr = 'http://www.jcp.org/jcr/1.0'>
>>> <sys = 'http://onlaw.at/sys'>
>>> <default =''>
>>>
>>> [sys:base] >  nt:base, mix:referenceable
>>>
>>> [default:li] > sys:base
>>> orderable mixin
>>> + default:ul (default:ul)=default:ul multiple
>>> + * (nt:unstructured)=nt:unstructured multiple
>>>
>>> [default:ul] > sys:base
>>> orderable
>>> - *
>>> + default:li (default:li)=default:li multiple
>>>
>>> [default:ol] > sys:base
>>> orderable
>>> - *
>>> + default:li (default:li)=default:li multiple
>>>
>>> [sys:Text] > sys:base
>>> - *
>>> + default:ol (default:ol)=default:ol multiple
>>> + default:ul (default:ul)=default:ul multiple
>>> ---------
>>>
>>> I get an error:
>>> ...
>>> INFO NodeTypeImporter:63 - DEBUG [registerCustomNodeTypes:L3] to register...li
>>> ERROR NodeTypeImporter:68 - org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException:
[{}li#{}ul] invalid default
>>>  primary type '{}ul'
>>> ...
>>>
>>> This is clear to me, because ul is unknown.
>>>
>>> So my question is how to change the cnd file in a way that
>>> ul can be a child of li and li can be a child of ul ?
>>
>> i was able to successfully register your cnd node type definitions
>> using the following
>> snippet:
>>
>>            Reader cnd = new FileReader("/path/to/file.cnd");
>>            CndImporter.registerNodeTypes(cnd, "cnd input stream",
>> wsp.getNodeTypeManager(), wsp.getNamespaceRegistry(),
>>                    session.getValueFactory(), true);
>>
>> cheers
>> stefan
>>
>>>
>>> Thanks.
>>>
>>> Cheers
>>> Johann
>>>
>>>
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com]
>>> Gesendet: Montag, 1. August 2011 17:22
>>> An: users@jackrabbit.apache.org
>>> Betreff: Re: Recursive Node Typs
>>>
>>> On Mon, Aug 1, 2011 at 4:24 PM, Eder, Johann <joed@manz.at> wrote:
>>>> Hi,
>>>>
>>>> Is it expected to be possible to create circular node type dependencies?
>>>
>>> yes (except if the circular dependencies are declared as 'autocreate'...).
>>>
>>>>
>>>> Example:
>>>> Node type A has B nodes, and node type B has A nodes.
>>>>
>>>> In the NodeTypDef I have ul and li elements. ul can be a child of li and
li can be a child of ul.
>>>>
>>>> ...
>>>> <jcr = 'http://www.jcp.org/jcr/1.0'>
>>>> <sys = 'http://onlaw.at/sys'>
>>>> <default =''>
>>>>
>>>> [sys:base] >  nt:base, mix:referenceable
>>>>
>>>> [default:li] > sys:base
>>>> orderable mixin
>>>> + * (nt:unstructured)=nt:unstructured multiple
>>>>
>>>> [default:ul] > sys:base
>>>> orderable
>>>> - *
>>>> + default:li (default:li)=default:li multiple
>>>>
>>>> [default:ol] > sys:base
>>>> orderable
>>>> - *
>>>> + default:li (default:li)=default:li multiple
>>>>
>>>> [sys:Text] > sys:base
>>>> - *
>>>> + default:ol (default:ol)=default:ol multiple
>>>> + default:ul (default:ul)=default:ul multiple
>>>> + default:table (default:table)=default:table multiple
>>>> + * (default:p)=default:p multiple
>>>>
>>>> ...
>>>>
>>>> If yes, how to do it?
>>>
>>> declare all related/required node tyes in the same cnd file
>>> and register them (see [1]).
>>>
>>> cheers
>>> stefan
>>>
>>> [1] http://wiki.apache.org/jackrabbit/ExamplesPage#Register_a_Node_Type_.5BCND.5D
>>>
>>>
>>>>
>>>> Thanks for any hints.
>>>>
>>>> Johann
>>>>
>>>>
>>>
>>
>

Mime
View raw message