Clean JCR garbage collection

This groovy script triggers the repository garbage collection. Jackrabbit is not triggering it automatically. So you can automate this through a scheduled task.

Trigger it for all repository

This script is using the original command which the repository tools app provides.

cm = info.magnolia.commands.CommandsManager.getInstance()
command = cm.getCommand('tools', 'garbageCollector')
command.execute(ctx)

Trigger it for one repository

If you only want to trigger a garbage collector for one specific workspace you could use the following groovy script:

import org.apache.jackrabbit.core.RepositoryImpl;
import info.magnolia.context.MgnlContext;

rpi = MgnlContext.getJCRSession("dam").getRepository();
gc = rpi.createDataStoreGarbageCollector();
gc.mark();
gc.sweep();
gc.close();