Calculate Site Size in Alfresco

Alfresco share is a collaboration platform on top of alfresco repository. In previous articles we had seen what features it provides. We had also seen some of the customization in alfresco share. Let us consider a case where organization started using Alfresco share heavily and using all its collaboration features. There are multiple sites already created and users are using them to store their contents. Now once contents being added to the site, its size grows and, in the backend, content store size on the hard disk also increased. There is a requirement where the admin wants to know the actual size or hard disk space occupied by a particular site. How could we do that?

Recently there was a thread on alfresco forum where one user had this kind of requirement and he had implemented it successfully as I found this very useful use case and alfresco does not provide any out of box support for this I though it worth sharing solution.

Using CMIS we can implement it as follow

This is a Groovy script from the CMIS & Apache Chemistry in Action book that dumps the descendants of a folder:

public void getDimension(Noderef site) throws Exception{

String parentFolder = "documentLibrary";

Session session = CmisUtil.createCmisSession(ALFRESCO_USER, ALFRESCO_PWD, ALFRESCO_CMIS_URL);

RepositoryCapabilities caps =  session.getRepositoryInfo().getCapabilities();

Folder folder = CmisUtil.getFolderInSite(session, parentFolder, site);

               if (!caps.isGetDescendantsSupported()) {

                       throw new Exception("\n Warning: getDescendants " +

                           "not supported in this repository");

               } else {

                       System.out.println("\ngetDescendants " +

                           "is supported on this repository.");

               for (Tree<FileableCmisObject> t : folder.getDescendants(-1)) {

                       printTree(t , "");


System.out.println("\nSize of " + folder.getName() + ": " + size);



private static void printTree(Tree<FileableCmisObject> tree,

                      String tab) throws Exception {

        long value = 0;

        for(Property<?> property : tree.getItem().getProperties()){

               String queryName = property.getQueryName();

                 if (queryName.equalsIgnoreCase("cmis:contentStreamLength")){

                       Object obj = property.getFirstValue();

                       BigInteger bi = (BigInteger) obj;

                       value = bi.longValue();

                       size = size + value;


System.out.println("Size of Site " + tree.getItem().getName() + ": " + value);

            for (Tree<FileableCmisObject> t:  tree.getChildren()) {

                       printTree(t, tab + "  ");



This could be consumed in dashlet and we could create nice dashlet which shows space occupied by each site. In above code we are passing hard coded site noderef which could be replaced by site name and then search noderef based on siteid to make it dynamic and generic. Thank you Jeff and fedemori for sharing such valuable information.


Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight


I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

Your email address will not be published. Required fields are marked *