Technical migration manual to 1.7.0


To correct the issue https://issues.ametys.org/browse/SYN-31, upgrading to plugin version 1.6.0 requires the migration of existing services.

Go to the repository console(http://[url _cms]/_repository) and run the following script :

Migration of Flux services RSS v1.6.0 or earlier

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.');


 

 

Back to top

Syndication