You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by ChadDavis <ch...@gmail.com> on 2010/01/24 01:19:21 UTC

node type registration behavour

I'm using the following line of code to register custom node types,
Jackrabbit-2.0-beta3.

manager.registerNodeTypes(new FileInputStream("./nodeTypes.cnd"),
JackrabbitNodeTypeManager.TEXT_X_JCR_CND);

This works great, but not exactly as I expected.  I expected that I
could keep a single node type file, and add to it when I wanted to add
another custom node type.  However, this doesn't work.  It seems that
if a node type is already registered, the whole process fails.  No
errors or anything, but none of the node types are registered.  In
other words, the .cnd file has to be completely full of new node
types, or none of them are loaded.  Shouldn't the behavour be that it
skips already registered types, but continues to scan the file for
other node types that haven't been registered yet?

Re: node type registration behavour

Posted by ChadDavis <ch...@gmail.com>.
Thanks.  Perfect.

On Mon, Jan 25, 2010 at 3:34 PM, Justin Edelson <ju...@gmail.com> wrote:
> On 1/25/10 5:14 PM, ChadDavis wrote:
>>>
>>> IMO no ;) but there following method pretty much does what you'e
>>> looking for:
>>>
>>>
>>> http://jackrabbit.apache.org/api/1.6/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.html#registerNodeTypes(java.io.InputStream,%20java.lang.String,%20boolean)
>>>
>>
>> That method no longer exists in 2.0.  Seems like this method has been
>> replaced by methods that only work on NodeTypeDefinitions, and I don't
>> see any methods anywhere to produce those objects from a .cnd of xml
>> file.
>>
>> Please point me to the API if there's a way to do this in 2.0.
>>
>>
>
> I believe the correct call in 2.0 is
> org.apache.jackrabbit.commons.cnd.CndImporter. registerNodeTypes():
> http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CndImporter.java?revision=816120&view=markup
>
> Justin
>
>>> cheers
>>> stefan
>>>
>>>
>>>>
>>>>
>>>
>>>
>
>

Re: node type registration behavour

Posted by Justin Edelson <ju...@gmail.com>.
On 1/25/10 5:14 PM, ChadDavis wrote:
>> IMO no ;) but there following method pretty much does what you'e
>> looking for:
>>
>> http://jackrabbit.apache.org/api/1.6/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.html#registerNodeTypes(java.io.InputStream,%20java.lang.String,%20boolean)
>>      
> That method no longer exists in 2.0.  Seems like this method has been
> replaced by methods that only work on NodeTypeDefinitions, and I don't
> see any methods anywhere to produce those objects from a .cnd of xml
> file.
>
> Please point me to the API if there's a way to do this in 2.0.
>
>    
I believe the correct call in 2.0 is 
org.apache.jackrabbit.commons.cnd.CndImporter. registerNodeTypes(): 
http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CndImporter.java?revision=816120&view=markup

Justin

>> cheers
>> stefan
>>
>>      
>>>        
>>      


Re: node type registration behavour

Posted by ChadDavis <ch...@gmail.com>.
>
> IMO no ;) but there following method pretty much does what you'e
> looking for:
>
> http://jackrabbit.apache.org/api/1.6/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.html#registerNodeTypes(java.io.InputStream,%20java.lang.String,%20boolean)

That method no longer exists in 2.0.  Seems like this method has been
replaced by methods that only work on NodeTypeDefinitions, and I don't
see any methods anywhere to produce those objects from a .cnd of xml
file.

Please point me to the API if there's a way to do this in 2.0.

>
> cheers
> stefan
>
>>
>

Re: node type registration behavour

Posted by Stefan Guggisberg <st...@gmail.com>.
On Sun, Jan 24, 2010 at 1:19 AM, ChadDavis <ch...@gmail.com> wrote:
> I'm using the following line of code to register custom node types,
> Jackrabbit-2.0-beta3.
>
> manager.registerNodeTypes(new FileInputStream("./nodeTypes.cnd"),
> JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
>
> This works great, but not exactly as I expected.  I expected that I
> could keep a single node type file, and add to it when I wanted to add
> another custom node type.  However, this doesn't work.  It seems that
> if a node type is already registered, the whole process fails.  No
> errors or anything, but none of the node types are registered.

the said method should IMO throw an exception in such a situation.
please report a jira issue if it doesn't.

> In
> other words, the .cnd file has to be completely full of new node
> types, or none of them are loaded.  Shouldn't the behavour be that it
> skips already registered types, but continues to scan the file for
> other node types that haven't been registered yet?

IMO no ;) but there following method pretty much does what you'e
looking for:

http://jackrabbit.apache.org/api/1.6/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.html#registerNodeTypes(java.io.InputStream,%20java.lang.String,%20boolean)

cheers
stefan

>