cancel
Showing results for 
Search instead for 
Did you mean: 

getFolderTree and recursion

nverwer
Champ in-the-making
Champ in-the-making
(Alfresco community edition 4.0.0 b)
I am trying to get a complete tree listing of a folder, and it looks like the CMIS api getFolderTree (http://wiki.alfresco.com/wiki/CMIS_Web_Scripts_Reference#Get_Folder_Hierarchy_.28getFolderTree.29) is the right way to go. However, this will only return one level of the tree, regardless of the setting of the depth parameter.

Upon investigation, I found the webscript atomentry.lib.atom.ftl. On line 126 there is a comment saying "recurse for depth greater than 1", and below that there is "[#if maxdepth == -1 || depth < maxdepth]". However, when I print maxdepth and depth, they are always equal to 1, so the condition is never satisfied, and the listing never recurses.
It seems that the depth parameter is not passed on correctly, although this should happen in tree.get.atomfeed.ftl (line 25), if my understanding is correct.

If I change the above condition so that it is always true, I run into another problem. Freemarker complains that "Expression feedLib is undefined" in "user-directive feedLib.feed".
I can solve that by including [#import "/org/alfresco/cmis/lib/atomfeed.lib.atom.ftl" as feedLib/] in atomentry.lib.atom.ftl, but that does not feel like the right thing to do.

After making these changes, I do get a recursive tree listing, but it seems that, beeing an Alfresco newbie, I am missing something. Is there anyone who is willing to shed some light on this?
3 REPLIES 3

jpotts
World-Class Innovator
World-Class Innovator
Starting with Alfresco 4, the old web script-based CMIS implementation which you will be using if you use the old CMIS ATOM service URL (http://localhost:8080/alfresco/s/api/cmis) is deprecated. Instead, you should use the OpenCMIS-based implementation, which you get to by using this URL: http://localhost:8080/alfresco/cmisatom.

I just ran a quick test using cmislib against Alfresco 4.0.b Community and noticed that when I use the deprecated URL, I only get the first level on a getTree call. But when I use the new OpenCMIS-based URL, I get the full tree.
>>> client = CmisClient('http://localhost:8080/alfresco/cmisatom', 'admin', 'admin')
>>> repo = client.defaultRepository
>>> folder = repo.getObjectByPath('/test')
>>> tree = folder.getTree()
>>> for res in tree:
…     res.name

u'sub1'
u'sub11'
u'sub111'
u'sub112'
u'sub12'
u'sub2'
u'sub3'
>>> client = CmisClient('http://localhost:8080/alfresco/s/api/cmis', 'admin', 'admin')
>>> repo = client.defaultRepository
>>> folder = repo.getObjectByPath('/test')
>>> tree = folder.getTree()
>>> for res in tree:
…     res.name

u'sub2'
u'sub3'
u'sub1'
There are other differences between the two implementation as well, so please do use the new one if possible.

Jeff

nverwer
Champ in-the-making
Champ in-the-making
Thank you Jeff, this is very helpful information.
I do wonder if I could have known this. The services listing from Alfresco …/alfresco/service/ happily lists the deprecated CMIS services.

Best regards, Nico

jpotts
World-Class Innovator
World-Class Innovator
There is a Jira to get those marked as deprecated. Looks like it is fixed in 4.0.1.

Jeff