lock Developer DevOps System Administrator Jahia 7.3 Jahia 8 Legacy

Find and unlock locked nodes


In some instances, it might be required to unlock a node that is currently locked. How is that done and is there a way to bulk unlock all locked nodes?


To list all the locked node, the following query can be used in the JCR Query Tool:

SELECT * FROM [nt:base] where ['j:locktoken'] is not null

To unlock individual nodes

You can click the node, click 'Show actions' from the right panel and click 'unlock node' or 'unlock tree'.

To bulk unlock nodes

A script can be written to programmatically get and unlock the nodes. Here is a sample Groovy script:


import org.jahia.api.Constants
import org.jahia.tools.patches.LoggerWrapper
import org.jahia.services.content.JCRCallback
import org.jahia.services.content.JCRNodeWrapper
import org.jahia.services.content.JCRSessionWrapper
import org.jahia.services.content.JCRTemplate
import org.jahia.services.content.JCRPublicationService
import javax.jcr.NodeIterator
import javax.jcr.RepositoryException
import javax.jcr.query.Query
def log = log;
final String jNodename = "j:nodename"
String nodeName

JCRTemplate.getInstance().doExecuteWithSystemSession(null, Constants.EDIT_WORKSPACE, new JCRCallback() {
    Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
        final String stmt = "SELECT * FROM [nt:base] where ['j:locktoken'] is not null"
        final NodeIterator iteratorSites = session.getWorkspace().getQueryManager().createQuery(stmt, Query.JCR_SQL2).execute().getNodes()
        while (iteratorSites.hasNext()) {
            JCRNodeWrapper node = iteratorSites.nextNode() as JCRNodeWrapper
            // to unlock the node
            nodeName = node.getPropertyAsString(jNodename)
            log.info("unlock : "+nodeName)
        return null