AnsweredAssumed Answered

Stop Javascript Console execution

Question asked by liviu.ioan on Jul 3, 2018
Latest reply on Jul 9, 2018 by cesarista

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

Outcomes