Alfresco data export

Recently I come across one of the requirement where client wanted to export detail about all the contents which are stored in Alfresco. I had though of following options of to implement it.

Create a Javabased webscript which will use the Alfresco foundation APIs to do the job.

The other option was to create Javascript based webscript which will use Alfresco javascript APIs to do the job.

I have decided to go with second option reasons were as follow.

  • It was one time export, so need not to worry about features like security and reliability, maintainability and all those things.
  • Alfresco javascript has all required api which will be enough to carry out activity.
  • It is always faster to created javascript based webscript as we can quickly do the development without need to restart the server and It was production instance so data items inside.I need to make sure I do it with minimum downtime.

All above points you could probably used as deciding factor between javascript and java based wescript. When to go with javascript and when to go for java.

Here is the script which I have created as a part of export process.

var CSVFile=companyhome.createFile(filename);
var mainnode=space;
var str;
var header="FileName,FileID,FolderPath"+'\r\n';

function iteratenode(childarray){
	for each (m in childarray)
	  var nodepath=m.displayPath.replace("/Company Home/","");","","+nodepath +'\r\n';
	   }else if(m.isContainer){

This is not the optimized version of script there is scope for improvement in terms of logic for iteration.

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.

4 Comments on Alfresco data export

  1. Frédéric Maguin says:

    Why don’t you use recursivity right from the begining ?
    On line 6, use iteratenode(mainnode.children);
    This will simplify your script by avoiding code duplication.

  2. Bindu Wavell says:

    FYI, if you run this somewhere where str ends up being more than 10M, the script will become extremely slow as each string operation will have to re-allocate memory and that takes a heck of a long time in rhino.

    • mitpatoliya says:

      Yeah Bindu, Thanks for pointing that out.
      As I have specified in this article, this was really a one time job for me and I do not wanted to waste time in creating java based utility which could have handled that scenario.
      I have taken divide and conquer approach here where I had various parent folders under root folder. So, I had run this scrip on those folders individually and every time I had created new file. This way I was able avoid that situation.

Leave a Reply

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