07-03-2018 05:42 AM
Hello,
Q1: Is there a way to say STOP/EXIT in the javascript code inserted into the JS Console?
(i.e., is there a way to stop the JS Console running in the Alfresco repository?)
Detailed context
I need to update cm:storeName for 1,5 million Alfresco nodes.
I want to split the processing by date intervals (e.g., process all nodes created in January 2018).
I know the js code is encapsulated in a transaction and search queries return at most 1000 results.
I want the js code to run continuously ("Run Like Crazy" option), so I can process more than 1000 objects after I start running the js code.
var def = { query: "=cm:storeName:\"storeX\" AND @cm:created:[\"2018-01-01\" TO \"2018-01-31\"]", store: "workspace://SpacesStore", language: "fts-alfresco", };
var nodes = search.query(def);
for each(var node in nodes) {
node.properties["cm:storeName"] = "storeY";
node.save();
}
nodes.length is at most 1000; when everything is done (all content is transferred to storeY), nodes.length is 0.
The problem is: even when all content is moved to storeY, the js code continues to run and I believe I need to restart the tomcat, which is very inconvenient. I want to say something like: "if nodes.length gets 0, please stop/exit".
Q2: If I cannot say stop/exit, is there another easy way of changing cm:storeName for all the objects (without tomcat restart)?
Thank you.
Liviu
07-08-2018 04:39 AM
There was a misunderstanding on my side.
Clarifications
There is a js-console client (in Share) and a js-console server (in the Repository).
Run Like Crazy = the client continuously sends the js snippet to the js-console server.
Misuderstanding: I thought Run Like Crazy = the server runs continously the js snippet.
As a result:
07-09-2018 07:36 AM
Definitely, for doing a massive task as you commented, JS Console may be not the best option. You can not stop the process once started.
In your case, I will use either CMIS script or to use a custom webscript.
In my experience, the second option is very much faster. With a CMIS script, I get more control over the process and it is easily batch-able and cron-able, while with a custom webscript execution I limit to a batch size of updates because of caches, and I use logger.warn in my js code to see in the logs how is going the custom process. In both cases, I got a complete list of target uuids in some file, and then I split the executions for doing 5000-10000 batches.
Regards.
--C.
Explore our Alfresco products with the links below. Use labels to filter content by product module.