cancel
Showing results for 
Search instead for 
Did you mean: 

Regenerate SWF previews

cybertoast
Champ in-the-making
Champ in-the-making
Is there a way to force Alfresco to regenerate the swf preview files? I have some previews that are corrupted thanks to installing swftools 0.8.1 (instead of 0.9.0) - the problem with 0.8.1 is previews that just loop through all the pages without stopping. I want to delete these previews and have Alfresco re-create new swf files. I know I can do it by uploading a new version of the document, and that works fine. But I need to be able to make the change for a lot of documents, and I don't really want new versions just for a corrected preview.

Any document I previewed for the first time after upgrading to swftools 0.9.0 is fine, so it's only the docs that have existing older previews that need to be corrected. Is there a way to do this?
9 REPLIES 9

kbonnet
Champ in-the-making
Champ in-the-making
Hi Cybertoast,

I had the same issue. I made a webscript where i could look up the child associations of type thumbnail and gave the ability to remove the child node with name "webpreview". This is the flash file. When requesting the preview again, it is regenerated and ok.

I did this on a per-node basis in a webscript. You can write a javascript too for this and execute it on batches.

Hope this helps.

Koen

bertrandf
Champ on-the-rise
Champ on-the-rise
You can execute a script (regenerateWebpreview.js for example) :
nodes = search.luceneSearch("@cm\\:thumbnailName:\"webpreview\"");
for (var i=0; i<nodes.length; i++) {
  nodes[i].remove();
}

kbonnet
Champ in-the-making
Champ in-the-making
nicely done!  :!:

cybertoast
Champ in-the-making
Champ in-the-making
Very helpful BertrandF. Thanks.

sjeandroz
Champ in-the-making
Champ in-the-making
hello,

This script deletes all webpreview, but is it possible, in a script,  to regenerate all webpreviews?

thanks

Sjeandroz

loftux
Star Contributor
Star Contributor
Here is an example of a script that update alread existing thumbnails and previews.
It is called recursively from the node you run it (in Alfresco Explorer).
It will probably put quite a load on your server so be careful if you have a large repo.

//This script iterates the current folder and subfolders
//and creates a simple log file in userhome directory of the process.
var counter=0;
var logmessage="LOG OF TASKS\n";
var errmessage="ERRORS\n";

if(space.isContainer)
{
   update(space);
}

logfile = userhome.createFile("Thumbnails refresh Log " + userhome.children.length +".txt");
logfile.content=logmessage + "UPDATED: "+counter.toString() +"\n" + errmessage;
logfile.properties.encoding = "UTF-8";
logfile.properties.mimetype = "text/plain";
logfile.properties.title = "Thumbnails refresh Log";
logfile.properties.description = "This is a log file for Thumbnails refresh";
logfile.save();
logger.log("LX UPDATE \n" + logmessage +"\nUPDATED: "+counter.toString() +"\n" + errmessage);

function update(node)
{
   for each (n in node.children)
   {
      if(n.isDocument)
      {
         try {
            var webpreview = n.getThumbnail("webpreview");
            if(webpreview){
                //logmessage += "LX Thumbnail for " + n.name+ " "+ webpreview.name +"\n";
                webpreview.update();
            }            
         } catch (e) {
            // TODO: handle exception
         }
         try {
            var doclib = n.getThumbnail("doclib");
            if(doclib){
               doclib.update();
            }
         } catch (e) {
            // TODO: handle exception
         }

         counter+=1;
      }
      if(n.isContainer)
         update(n);
   }
}

sjeandroz
Champ in-the-making
Champ in-the-making
thanks for the response's speed,

If I understand this script, it will juste re-generate existing webpreview, right?

but if I want to have a script (executed by a content rule for example) who create a webpreview when a document is uploaded on Alfresco, is it possible?

Thanks again et sorry for my bad level in english…

loftux
Star Contributor
Star Contributor
Have a look at http://localhost:8080/alfresco/s/index/uri/api/upload
This api already lets you specify the thumbnails to create on upload. Following that url you can also drill down to the javascript to find out what's happening.

sjeandroz
Champ in-the-making
Champ in-the-making
great!

Thanks I will study that soon!

Thanks again!