jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: Issue while re-registering node types
Date Mon, 16 Aug 2010 18:41:49 GMT
On Mon, Aug 16, 2010 at 19:18, Davide Maestroni
<davide.maestroni@gmail.com> wrote:
> Yes, it could definitely be the same issue, and I see that unfortunately no
> one fixed it...
> Do you happen to know any workaround? I tried to look into Jackrabbit 2.1.0.
> but I could not find any major modifications in the related classes.
> This is a real show stopper in case I want to change the node type
> definitions of an existing repository.

Instead of the commons CND importer utility, you can read the node
type templates from the CND, and then re-register them one by one.
Then you can unregister the node types first and then add the new
ones, which should work for all "conflicting" cases.

Here is the code I used for a node type upgrade utility. Something
like this gives you the templates (non-jcr-api classes are from

    import org.apache.jackrabbit.commons.cnd.*;

    InputStream in =  ... // cnd input stream

    NodeTypeManager nodeTypeManager =
    ValueFactory valueFactory = session.getValueFactory();
    NamespaceRegistry namespaceRegistry =

    DefinitionBuilderFactory<NodeTypeTemplate, NamespaceRegistry> factory =
        new TemplateBuilderFactory(nodeTypeManager, valueFactory,

    CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry> cndReader =
        new CompactNodeTypeDefReader<NodeTypeTemplate,
NamespaceRegistry>(new InputStreamReader(in), "nodetypes.cnd",

    List<NodeTypeTemplate> templates = cndReader.getNodeTypeDefinitions();

Then you can iterate over the template, find already registered node types via:


and unregister (remove) and register (add) the types via:

    nodeTypeManager.unregisterNodeTypes() and registerNodeTypes()

Hope that helps,

Alexander Klimetschek

View raw message