jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Brooking <public+jackrab...@charlie.brooking.id.au>
Subject Re: How to modify CND in live repository
Date Sat, 21 Mar 2009 02:01:01 GMT
Matt Fulford wrote:
> Is the only way to make a change to the repository CND file:
> 1. export data
> 2. clear/initialize repository
> 3. register modified CND
> 4. re-import data
>
> Or can I update some file 'on the fly'?
>   

See registerNodeTypes in NodeTypeManagerImpl:

  NodeTypeManagerImpl manager = (NodeTypeManagerImpl)
    session.getWorkspace().getNodeTypeManager();
  NodeType[] nodeTypes = manager.registerNodeTypes(
    in, // input stream for new CND file
    NodeTypeManagerImpl.TEXT_X_JCR_CND,
    true  // reregister existing node types
  );

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

I have found this to work even when existing nodes have types being 
replaced. You can write "migration" code that does the nodetype 
reregistration (above) and then makes the relevant changes to content. 
When you call save, nodes are validated against the new node types.

Later
Charlie

Mime
View raw message