Manuel de migration technique vers 1.7.0

Pour corriger l'issue https://issues.ametys.org/browse/SYN-31, le passage à la version 1.6.0 du plugin nécessite la migration des services existants.

Rendez-vous sur la console du repository (http://[url_cms]/_repository) et exécutez le script suivant:

Migration des services Flux RSS v1.6.0 ou antérieurs

importPackage(javax.jcr);

var qm = session.getWorkspace().getQueryManager();
var migrated = 0;
  
var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type='SERVICE' and @ametys-internal:service='org.ametys.plugins.syndication.service.RSS']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
  
while (nodes.hasNext())
{
	var needSave = false;
	var node = nodes.next();
    var paramNode = node.getNode("ametys:service_parameters");
    var feedsNode = paramNode.getNode("ametys:feeds");
    
    if (feedsNode.hasNodes())
    {       
        var position = 1;
        var feedNodes = feedsNode.getNodes();
        while (feedNodes.hasNext())
        {
            var entryNode = feedNodes.next();
            if (!entryNode.hasProperty("ametys:id"))
            {
                entryNode.setProperty("ametys:id", position.toString());
                position++;
                needSave = true;
            }
        }
     
        if (needSave)
        {
            node.save();
            migrated++;
        }
    }
}
  
println(migrated + ' service(s) have been migrated.');

var credentials = new SimpleCredentials('ametys', []);
var liveSession = repository.login(credentials, 'live');
 
qm = liveSession.getWorkspace().getQueryManager();
migrated = 0;
   
query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type='SERVICE' and @ametys-internal:service='org.ametys.plugins.syndication.service.RSS']", javax.jcr.query.Query.XPATH);
nodes = query.execute().getNodes();
   
while (nodes.hasNext())
{
    var needSave = false;
    var node = nodes.next();
    var paramNode = node.getNode("ametys:service_parameters");
    var feedsNode = paramNode.getNode("ametys:feeds");
    
    if (feedsNode.hasNodes())
    {       
        var position = 1;
        var feedNodes = feedsNode.getNodes();
        while (feedNodes.hasNext())
        {
            var entryNode = feedNodes.next();
            if (!entryNode.hasProperty("ametys:id"))
            {
                entryNode.setProperty("ametys:id", position.toString());
                position++;
                needSave = true;
            }
        }
     
        if (needSave)
        {
            node.save();
            migrated++;
        }
    }
}
   
println(migrated + ' service(s) have been migrated in LIVE.');