How to transfer nodeType definition from a module to another?
Question
Sometimes, when some refactoring is needed, we have to transfer definitions from a module to another. Let's have an example:
Answer
Initial situation
Imagine that we have a moduleB that depend on moduleA because it uses a mixin declared in moduleA
moduleA definitions.cnd (v1)
[jmix:mycomponents] > jmix:droppableContent, jmix:editorialContent mixin
moduleB definitions.cnd (v1)
[jnt:mycomponent] > jnt:content , jmix:mycomponents, mix:title
- text (string) internationalized
moduleB pom.xml (v1) extract
<jahia-depends>default,moduleA</jahia-depends>
As we can see there is a dependency from the moduleB to the moduleA, because the moduleB use the definition of a mixin declared in the moduleA (the definition of the mixin jmix:mycomponents )
If you look at the http://localhost:8080/modules/tools/definitionsBrowser.jsp page, then you can see that the jmix:mycomponents is defined in the moduleA
Let's move our mixin
Now, imagine that we have to move the definition of this mixin jmix:mycomponents to a third module, the moduleC
This means that we need to update our modules:
moduleA definitions.cnd (v2)
// jmix:mycomponents move in moduleC
moduleC definitions.cnd (v1)
[jmix:mycomponents] > jmix:droppableContent, jmix:editorialContent mixin
moduleB definitions.cnd (v2)
the cnd remain the same; only de dependance in the pom.xml is updated
[jnt:mycomponent] > jnt:content , jmix:mycomponents, mix:title
- text (string) internationalized
moduleB pom.xml (v2) extract
<jahia-depends>default,moduleC</jahia-depends>
So now, the moduleB depends on the moduleC.
Procedure to do on an existing platform
This is for the basis, but in practice, we need to do more on existing sites. Here is the procedure:
- stop
moduleAv1 andmoduleBv1 - remove
moduleAv1 andmoduleBv1 - install
moduleAv2 andmoduleBv2 - install
moduleCv1 - execute the following query on the database: (it can be executed from the tools)
delete FROM jahia_nodetypes_provider - restart the processing server
- start
moduleAv2,moduleBv2,moduleCv1 - Restart other cluster nodes
Now the definition of the myprojectmix:component is done threw the moduleC instead of the moduleA, as you can see in the http://localhost:8080/modules/tools/definitionsBrowser.jsp