Alfresco: Calculate folder size using Java based WebScript

I was assigned to a training task to write a web script for calculating the size of a folder or a file. But you need to go through all the nodes recursively. If you don’t calculate it recursively in folders you won’t get accurate folder size.


For this project, I generated the Alfresco 5 All-in-One maven project. You really don’t want Alfresco  Share module in this project. But I included it because you may need to find a NodeRefId. It would be easier with Share.  The source code of this project is available at GitHub.




Create above files in below locations of your maven project. 

How to test the web script?

Take a terminal. Navigate to project folder. And type below command.

$ mvn clean install -Prun -Dmaven.test.skip

It may take a while to start the Alfresco Repository and Share server. Wait till it finishes completely. 

Then open a web browser and go to http://localhost:8080/share. Then login. Go to Document library.

Find a folder and click on “View Details”. Then copy NodeRef from browser as shown below.

Open a new tab and type below URL. (Replace with the NodeRef you copied from Alfresco Share interface.)


If you have followed the instruction properly, you will get a page like below.

If you have any questions regarding these examples, please comment!!! Enjoy Alfresco!

· webscript, Java, recursive, folder, alfresco