<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: When I run a rule for many files, it always gives me an error in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135117#M36334</link>
    <description>&lt;P&gt;You can develop a javascript where you can limit the number of document to process. For those they process, you can apply an aspect (empty), just to mark them. So next time, you can add a check, if the script get a file with that aspect, just exit it and continue with next one.&lt;/P&gt;&lt;P&gt;Something like that.&lt;/P&gt;&lt;P&gt;I had develop long time ago a script where you give a folder_name and it was creating the preview for those files they don't have it yet. Maybe you can reuse part of it. You need to save the script in Data Dictionay/Scripts&lt;/P&gt;&lt;PRE&gt;/**
* Author: CristinaMR
* Date: 22/12/11
* url to launch it: http://[HOST]:[PORT]/alfresco/command/script/execute?scriptPath=/Company%20Home/Data%20Dictionary/Scripts/GeneraPreviewsFinal.js&amp;amp;q=10
**/

var counter=0;&lt;BR /&gt;//Log config
var logmessage="[INFO] ";
var errmessage="[ERROR] ";&lt;BR /&gt;// space to loop
var espacio = companyhome.childByNamePath("folder_name");   &lt;BR /&gt;//Get number from URL
var max=args.q;
&lt;BR /&gt;//Log config
var logfile = espacio.childByNamePath( "ThumbnailsLog.txt" );  
if ( logfile == null )  
 logfile = espacio.createFile( "ThumbnailsLog.txt" ); 

logfile.content = "############### LOG ############### \n";
logfile.content += logmessage + "Content to update: "+max.toString() +"\n \n \n";
&lt;BR /&gt;//main function
recorre(espacio);

function recorre(n)
{
	var srchQuery = "+TYPE:\"cm:content\" -ASPECT:\"{http://www.alfresco.org/model/content/1.0}taggable\"";  

	var def =
	{
      query: srchQuery,
      store: "workspace://SpacesStore",
      language: "lucene",
      page: {maxItems:max}
	};

	var n = search.query(def);
	
	logfile.content += logmessage + "Documents to process: "+ max +" &amp;amp; docs loaded: "+ n.length + "\n";
	
	if (n.length&amp;gt;0){

	   for (var i=0; i&amp;lt;max; i++)
      {
		logfile.content += logmessage + "Counter: "+counter +"\n";
		var thumbnails = n[i].getThumbnails();
		
		if ((thumbnails == null || thumbnails.length == 0)&amp;amp;&amp;amp; !n[i].hasAspect("cm:taggable")){
				creaThumbnail(n[i]); 
			}
	}
 
	}else{
		logfile.content += logmessage + "No doc to update. \n";
	}
}
&lt;BR /&gt;//function to create the thumbnail
function creaThumbnail(node){
	try{
                //logfile.content += logmessage + "First step to thumbnail function in " + node.name +"\n";
                node.addAspect("cm:taggable");
                node.createThumbnail("webpreview", true);
                counter++;
                node.addTag("Actualizado");
                node.save();
                logfile.content += logmessage + "Updated: "+ node.name +"\n";
	}catch(e){
		logfile.content += errmessage + "Failed to update node: "+node.name +"\n";
	}
}
 
//Log properties
logfile.content += logmessage + "Total files updated: "+counter.toString() +"\n \n \n";
logfile.properties.encoding = "UTF-8";
logfile.properties.mimetype = "text/plain";
logfile.properties.title = "Log Preview";
logfile.properties.description = "Update log file";
logfile.save();&lt;/PRE&gt;&lt;P&gt;Cris.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Sep 2021 14:35:22 GMT</pubDate>
    <dc:creator>cristinamr</dc:creator>
    <dc:date>2021-09-09T14:35:22Z</dc:date>
    <item>
      <title>When I run a rule for many files, it always gives me an error</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135112#M36329</link>
      <description>&lt;P&gt;In any version of Alfresco ACS, when I try to run a rule to a folder that has let's say, 2k files, it always fails... As if it timed out.&lt;/P&gt;&lt;P&gt;I can't seem to figure out, how can I apply a rule to many files, without failing just because the big number of files?&lt;/P&gt;&lt;P&gt;Thank you all.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 11:57:53 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135112#M36329</guid>
      <dc:creator>iohann95</dc:creator>
      <dc:date>2021-09-09T11:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: When I run a rule for many files, it always gives me an error</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135113#M36330</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Why don't you use &lt;A href="https://docs.alfresco.com/content-services/latest/admin/import-transfer/" target="_blank" rel="noopener nofollow noreferrer"&gt;Bulk Import tool&lt;/A&gt;? For such amount of documents is highly recommended.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Cristina.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 12:08:34 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135113#M36330</guid>
      <dc:creator>cristinamr</dc:creator>
      <dc:date>2021-09-09T12:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: When I run a rule for many files, it always gives me an error</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135114#M36331</link>
      <description>&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;But I was actually trying to run the rule for files that are already on the ECM.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 12:28:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135114#M36331</guid>
      <dc:creator>iohann95</dc:creator>
      <dc:date>2021-09-09T12:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: When I run a rule for many files, it always gives me an error</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135115#M36332</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/86189"&gt;@iohann95&lt;/A&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;In any version of Alfresco ACS, when I try to run a rule to a folder that has let's say, 2k files, it always fails... As if it timed out.&lt;/P&gt;

&lt;P&gt;I can't seem to figure out, how can I apply a rule to many files, without failing just because the big number of files?&lt;/P&gt;

&lt;P&gt;Thank you all.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not a good idea to run rule on 2k nodes, However what error you see in logs (alfresco.log, share.log, catalina.out)?&lt;/P&gt;
&lt;P&gt;I would rather suggest to use java behaviors and process the nodes in batches.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 13:40:10 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135115#M36332</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2021-09-09T13:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: When I run a rule for many files, it always gives me an error</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135116#M36333</link>
      <description>&lt;P&gt;Thank you very&amp;nbsp; much for the answer. I will try to check the logs, but probably won't help since this behavior is present from the older to newer alfresco version.&lt;/P&gt;&lt;P&gt;Am I basically out of luck then... I will have to figure out develop something, correct?&lt;/P&gt;&lt;P&gt;I was actually trying to run the &lt;EM&gt;Extract common metadata fields &lt;/EM&gt;rule to those files.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 13:55:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135116#M36333</guid>
      <dc:creator>iohann95</dc:creator>
      <dc:date>2021-09-09T13:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: When I run a rule for many files, it always gives me an error</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135117#M36334</link>
      <description>&lt;P&gt;You can develop a javascript where you can limit the number of document to process. For those they process, you can apply an aspect (empty), just to mark them. So next time, you can add a check, if the script get a file with that aspect, just exit it and continue with next one.&lt;/P&gt;&lt;P&gt;Something like that.&lt;/P&gt;&lt;P&gt;I had develop long time ago a script where you give a folder_name and it was creating the preview for those files they don't have it yet. Maybe you can reuse part of it. You need to save the script in Data Dictionay/Scripts&lt;/P&gt;&lt;PRE&gt;/**
* Author: CristinaMR
* Date: 22/12/11
* url to launch it: http://[HOST]:[PORT]/alfresco/command/script/execute?scriptPath=/Company%20Home/Data%20Dictionary/Scripts/GeneraPreviewsFinal.js&amp;amp;q=10
**/

var counter=0;&lt;BR /&gt;//Log config
var logmessage="[INFO] ";
var errmessage="[ERROR] ";&lt;BR /&gt;// space to loop
var espacio = companyhome.childByNamePath("folder_name");   &lt;BR /&gt;//Get number from URL
var max=args.q;
&lt;BR /&gt;//Log config
var logfile = espacio.childByNamePath( "ThumbnailsLog.txt" );  
if ( logfile == null )  
 logfile = espacio.createFile( "ThumbnailsLog.txt" ); 

logfile.content = "############### LOG ############### \n";
logfile.content += logmessage + "Content to update: "+max.toString() +"\n \n \n";
&lt;BR /&gt;//main function
recorre(espacio);

function recorre(n)
{
	var srchQuery = "+TYPE:\"cm:content\" -ASPECT:\"{http://www.alfresco.org/model/content/1.0}taggable\"";  

	var def =
	{
      query: srchQuery,
      store: "workspace://SpacesStore",
      language: "lucene",
      page: {maxItems:max}
	};

	var n = search.query(def);
	
	logfile.content += logmessage + "Documents to process: "+ max +" &amp;amp; docs loaded: "+ n.length + "\n";
	
	if (n.length&amp;gt;0){

	   for (var i=0; i&amp;lt;max; i++)
      {
		logfile.content += logmessage + "Counter: "+counter +"\n";
		var thumbnails = n[i].getThumbnails();
		
		if ((thumbnails == null || thumbnails.length == 0)&amp;amp;&amp;amp; !n[i].hasAspect("cm:taggable")){
				creaThumbnail(n[i]); 
			}
	}
 
	}else{
		logfile.content += logmessage + "No doc to update. \n";
	}
}
&lt;BR /&gt;//function to create the thumbnail
function creaThumbnail(node){
	try{
                //logfile.content += logmessage + "First step to thumbnail function in " + node.name +"\n";
                node.addAspect("cm:taggable");
                node.createThumbnail("webpreview", true);
                counter++;
                node.addTag("Actualizado");
                node.save();
                logfile.content += logmessage + "Updated: "+ node.name +"\n";
	}catch(e){
		logfile.content += errmessage + "Failed to update node: "+node.name +"\n";
	}
}
 
//Log properties
logfile.content += logmessage + "Total files updated: "+counter.toString() +"\n \n \n";
logfile.properties.encoding = "UTF-8";
logfile.properties.mimetype = "text/plain";
logfile.properties.title = "Log Preview";
logfile.properties.description = "Update log file";
logfile.save();&lt;/PRE&gt;&lt;P&gt;Cris.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 14:35:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135117#M36334</guid>
      <dc:creator>cristinamr</dc:creator>
      <dc:date>2021-09-09T14:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: When I run a rule for many files, it always gives me an error</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135118#M36335</link>
      <description>&lt;P&gt;Thanks, I will have a look.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 11:49:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/when-i-run-a-rule-for-many-files-it-always-gives-me-an-error/m-p/135118#M36335</guid>
      <dc:creator>iohann95</dc:creator>
      <dc:date>2021-09-13T11:49:18Z</dc:date>
    </item>
  </channel>
</rss>

