Magnolia Tools module is a collection of useful tools for manipulating repository content.

Download

Download the module from Magnolia Store or Nexus repository.

Installing

Magnolia Tools is an Enterprise module. The module JAR files are available in the add-ons folder under the Magnolia installation directory. To install the module, copy the JAR files to /WEB-INF/lib. See general module installation instructions.

Uninstalling

See the general module uninstalling instructions and advice.

RemoveNode

Used from command line or bean shell to remove corrupted nodes from a repository.

Using from BeanShell or Groovy Console

Log into BeanShell and execute the following script, adapting it to your specific case (workspace and node UUID):

import info.magnolia.context.*;
import info.magnolia.*;
import info.magnolia.tools.*;
hm = MgnlContext.getSystemContext().getHierarchyManager("website"); // Change to appropriate workspace
node = hm.getContentByUUID("be09e353-bd5c-45c2-be45-9324615720ca").getJCRNode(); // Change to get the appropriate node
PersistenceManagerUtil.deleteNode(node, true, false);

Using from command prompt

Execute the bin/removenode script provided in the add-ons folder:

./bin/removenode\
 --webapp ~/tmp/current/webapps/magnoliaPublic\
 --workspace website\
 --uuid be09e353-bd5c-45c2-be45-9324615720ca\
 --cleanupversions\
 --detachonly

The first of the two boolean parameters above is for the cleanupversions option. If set, the tool will try to retrieve and delete versions. The second boolean parameter is for detachonly and should be used when the node can't be deleted even with this tool. With this set the tool will only try to detach the node from the hierarchy but will not attempt to remove it from the backend store. It also means that the node's UUID will no longer be available and previously exported content with such UUID can't be imported again without changing the UUID.

After removing the node (using BeanShell or command line), you need to reindex the workspace:

  1. Shut down Magnolia.
  2. Delete the repositories/magnolia/workspaces/<affected workspace>/index directory.
  3. Restart Magnolia.

If you are using any kind of pooled or JNDI PersistenceManager which is configured in your container, you need to change the configuration to connect to the backing database directly with one of the core persistence managers to be able run the script from the command prompt since Magnolia Tools is not aware of your container's JNDI configuration. Depending on the PersistenceManager implementation, you might be able expose this configuration by setting system properties too.

DataStore garbage collection

Command to run throught the DataStore and remove all items without reference to clean the repository.

To run garbage collection:

  1. Go to Tools > Magnolia Tools.
  2. Click Clear all repositories to run garbage collection over all data store repositories or select a specific repository and click Clear repository.

Garbage collection on system startup

If you have the Scheduler module installed you can execute the garbage collection command on Magnolia startup. By default this functionality is disabled. To make it work add magnolia.datastoreGC.enabled to your system properties and set it's value to true.

Scheduled job

As any other command, data store garbage collection can be configured as a scheduled job for periodic launches. See Scheduler configuration for instructions on configuring scheduled jobs. The command is in /modules/tool/commands/tools/garbageCollector. If you pass the repository parameter then garbage collection will be done for the specified repository only. When the repository parameter is left out all repositories are cleaned.

Troubleshooting

XML Parser API library conflict

Magnolia 4.4.3 and 4.4.4 (both CE and EE bundles) there is a conflict with xmlParserAPIs-2.6.2 library when running Magnolia Tools in the shell. The workaround is to remove xmlParserAPIs-2.6.2 library from your WEB-INF/lib folder.

#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))