eXo Add-ons: Intranet Trash Cleaner

eXo Platform Blog

When using File Explorer to manage your documents on the Intranet, were you under the impression that any files or folders that you deleted would be permanently removed from the database, never to be seen again? In fact, that isn’t true: your files/folders will actually be moved to the Trash folder and will stay there until you want to restore them and ask an Admin to do it for you.

But what if you really don’t need these files/folders any more? You will definitely forget about them, and the Admin does not care about files/folders in the Trash unless you ask for them. So, the Trash stores everything that has ever been removed, and gets bigger and bigger every day. This may become a problem because the size of the Trash folder continues to increase, yet its contents are almost entirely useless and out of date.

To solve this problem and add more value to our own intranet, the team has implemented a configurable job to clean the Trash folder automatically after a time. This job is provided as an add-on for the eXo Platform. Feel free to take a look at the source code on GitHub: https://github.com/exo-addons/intranet-extras.

To deploy the Trash cleaner job, you just have to check out the add-on source code from GitHub and run the build command to generate jar and ear packages, which you can then easily deploy. For more details, please refer to the project’s README.

The job will scan the Trash folder and check the deletion date of each file and folder. If files/folders have been in the Trash for longer than a specified value (for instance, 30 days), they will be permanently removed. You can find the implementation of the job in the CleanerTrashJob.java file. There are two variables that must be configured before running the job:

• The job interval time: This is configured via the variable intranet.emptytrashjob.cron.period. Set the value of this variable in the configuration.properties file to the number of milliseconds required. For example, if you want the job to run once a day, the value must be set to 24*60*60*1000 = 86400000:


• The expiry time: The expiry of files/folders in the Trash is set via valid.time.in.trash with a day count. For example, if you want the job to remove files/folders that have been in the Trash for more than 30 days:


Once the package has been deployed and configured, start up your server and you will see how the job helps you to clean up your Trash folder. But do be sure to inform your users clearly that their deleted files and folders cannot be restored from the Trash after expiry.

Submit your own eXo Add-ons!

If you are a developer and you have worked on something you would like to share with the eXo community, eXo Add-ons is the best place to host your code. And rest assured: you will remain the owner of your project. We won’t claim any IP or other rights. It’s your stuff, just a bit more visible.

It’s very easy to get your own repository on eXo Add-ons. Just drop us a request and we’ll get you ready.

Related Posts
Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>