Clean up scripts using Groovy

Magnolia Groovy module adds Groovy capabilities to Magnolia. Groovy is a popular dynamic language for the JVM. To know more about it, visit the Groovy official website which has many tutorials and documentation both for beginners and advanced users of the language.

The module provides:

  • A web based Unix-like console where you can access contents in Magnolia repositories in a groovyish way

  • A scripts repository where you can store your scripts

  • The ability to plug in Groovy classes into Magnolia at runtime, without the need for deploying them and restarting the servlet container.

All these tools make for a more agile approach to coding and maintaining Magnolia-based websites.

For more information, see Groovy module.

Archive resolved tasks

  • Sample script

  • Console output

archived 10 tasks
Alternatively, use the Tasks Cleaner module instead of the Groovy script above.

Clear notifications

Clear all the notifications for a given user.

  • Sample script

  • Console output

Example of usage
clearNotificationsForUser('superuser'); (1)
1 Notifications removed for superuser.
archived 7 notifications

Remove messages

Removes all messages from the specified user.

  • Sample script

  • Console output

Example of usage
removeMessages("superuser"); (1)
1 Messages removed for superuser.
messages of superuser removed
[/superuser/0]

Unused assets

This script shows a list of assets that aren’t referenced from any page.

  • Sample script

  • Console output

found 90 unused assets
shark_brian_warrick_0824.JPG
ash-edmonds-441220-unsplash
ruben-mishchuk-571314-unsplash
vietnam_jan_16323513143_82062f3a9a_k.jpg
...

List all assets and their sizes

This script lists all assets printing the node and the size in MB.

  • Sample script

  • Console output

Asset: /travel-demo/social-icons/google-plus.png
Size(Mb) : 0.010852813720703125
Asset: /travel-demo/social-icons/fb.png
Size(Mb) : 0.00937175750732421875
Asset: /travel-demo/social-icons/linkedin.png
Size(Mb) : 0.0100536346435546875
...

Number of active sessions

Get the number of active sessions in Magnolia in Tomcat (you can’t find the number of concurrent users, but this might help estimate it).

  • Sample script

  • Console output

Current jobs in execution

This script shows how many jobs are running when it is executed.

  • Sample script

  • Console output

Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the Performance tuning guide docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules