cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with thumbnail REST API

alex_chew
Champ in-the-making
Champ in-the-making
Hi,

Are there some restrictions while using thumbnail REST API? FireBug complains a "too many recursive calls" error while I am trying to get thumbnail of the same document from two different dashlets.  Below is the code fragment I used to retrieve thumbnail of a document.

var thumbnailUrl = Alfresco.constants.PROXY_URI + "api/node/" + issue.attachNodeRef.replace(":/", "") + "/content/thumbnails/doclib?c=queue&ph=true";

The requirement is:
Dashlet A will display all issues that assigned to current user. If the issue has attachments then the thumbnail will be displayed. The backend web script decides which attachment will be used.
Dashlet B will display all issues that created by current user. A thumbnail will be displayed if the issue has at least one attachment.

The detailed problem is:
It works well if I only deploy one of them to site dashboard. But when I deploy both of them the FireFox goes dead while I am trying to enter the site dashboad.

Is this caused by wrong arguments ? Any clues will be appreciated. Many thanks.

Best Regards,
Alex
1 REPLY 1

danlangford
Champ in-the-making
Champ in-the-making
i dont have an answer for you. but i was playing with the thumbnail REST api recently and figured i would drop a few thoughts

first i havent noticed many restrictions with this api

now when in debugging this issue realize its just a GET call so you can just put the url in your browsers address bar. then when you use firebug (or the Chrome Dev Tools which i like better) you dont have to wade through all those responses. you can just see the one you care about.

here is an example from my dev box (localhost links wont work, i just wanted to show you the patterns)
http://localhost:8080/share/proxy/alfresco/api/node/workspace/SpacesStore/e102e92c-4894-4e9c-86c2-de...

that should show you JSON with all the thumbnails that have already been generated. place the thumbnail name at the end of that url to get that thumbnail returned

http://localhost:8080/share/proxy/alfresco/api/node/workspace/SpacesStore/e102e92c-4894-4e9c-86c2-de...

if it hasnt been generated yet you get a 404 not found. if it has been you should get a 200 img/png

the preview names must be valid, registered ThumbnailDefinitions. default one are registered in the thumbnail-service-context.xml

using ?c=queue may return a 404 not Found until the thumbnail is generated. meaning you will have to call again. if you want to leave the connection open forcing the immediate creation and return of the thumbnail use ?c=force (subsequent calls to that url will not re-generate the preview, i dont think)

so since you are just hitting the thumbnail image preview in your browser address bar you can use your chrome dev tools or firebug to see the network responses. too many redirects error implies that the api is sending back redirects like 301 or 302. your dev tools can confirm that.

in fact i can check that right now on my box. i can find a node that has few previews…..

GET …/content/thumbnails/ returns 200 and json array showing that doclib was already made. (alfresco does that with images)
GET …/content/thumbnails/imgpreview?c=queue returns 404 not found.
call it again …. returns a 200 img/png. the first call said it couldnt find the preview, but since we asked it to be queued the second call found it already made. the time it takes for the thumbnail generator to get through the queue depends on the specs of your system and activity level on your install
GET …/content/thumbnails/webpreview?c=force returns 200 with the preview. unless it couldnt make it then you get a 500.
GET …/content/thumbnails/ now shows all the previews that have been generated
GET …/content/thumbnails/doclib this type of call without the c arg will show it if its been made, give you a 404 not found if it hasnt been but will not trigger any sort of thumbnail generation.

i didnt see any redirects (301 or 302) in any of my testing there. maybe you can use your dev tools to determine exactly which url is giving the too many redirects

you do not need the ph "placeholder" arg as alfresco does not currently use it according to their script description. script details can be found at {yourinstall}/alfresco/service/script/org/alfresco/repository/thumbnail/thumbnail.get however looking at the source code it appears to try to use it. i dunno i doubt you need it

good luck