Skip to content

Instantly share code, notes, and snippets.

@molaschi
Created February 15, 2012 16:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save molaschi/1837029 to your computer and use it in GitHub Desktop.
Save molaschi/1837029 to your computer and use it in GitHub Desktop.
Run datastore garbage collector on magnolia project via groovy shell
import info.magnolia.context.MgnlContext
// fill "repositories" list with one workspace for each repository defined in your repositories.xml jackrabbit configuration file
// (if you have different repositories using the same datastore modify this script according to http://wiki.apache.org/jackrabbit/DataStore#line-212)
def repositories = ["website", "media"]
def removedDataStoreEntries = 0
repositories.each() { repo ->
def session = MgnlContext.getHierarchyManager(repo).getWorkspace().getSession()
def gc = session.createDataStoreGarbageCollector()
try {
gc.mark()
removedDataStoreEntries += gc.sweep()
}
finally {
gc.close()
}
}
return removedDataStoreEntries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment