DevOps System Administrator Jahia 7.3 Jahia 8

Howto remove mixin in a subtree


After a wrong manipulation, all nodes of a subtree have the mixin jmix:markedForDeletion. Is there a way to remove this mixin (or any mixin) from a subtree?


You can do it by manually using the JCR repository browser from the tools at http://localhost:8080/modules/tools/jcrBrowser.jsp

First, you need to click on the show action checkbox then click on the small [x] after the mixin name.


If you want to do it on a whole subtree, you may prefer to play a groovy script from the Groovy console http://localhost:8080/tools/groovyConsole.jsp that could look like this:

import org.jahia.api.Constants

import javax.jcr.NodeIterator
import javax.jcr.RepositoryException
import javax.jcr.query.Query
boolean doIt = false;
def logger = log;
String mixin = "jmix:markedForDeletion";
def JahiaSite site ="bostik_global");

for (Locale locale : site.getLanguagesAsLocales()) {
    JCRTemplate.getInstance().doExecuteWithSystemSession(null, Constants.EDIT_WORKSPACE, locale, new JCRCallback() {
        Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
            def q = "SELECT * FROM [" + mixin + "] where isdescendantnode('/sites/my-site/home/footer')";

            NodeIterator iterator = session.getWorkspace().getQueryManager().createQuery(q, Query.JCR_SQL2).execute().getNodes();
            while (iterator.hasNext()) {
                final JCRNodeWrapper node = (JCRNodeWrapper) iterator.nextNode();
      "Remove mixin " + mixin + " for " + node.getPath());
            if (doIt) {
            return null;

This script simply searches the all nodes of the mixin type, under a certain path.

So, you may need to alter the mixin to search for, as the descendant path (in the query)