A partir de la 4.3 et sans reconstruction du live, exécutez ce script, sinon, voir la suite...

Mettre handle = true pour rendre le script effectif :

let handle = false;

const jsonUtils = Ametys.serviceManager.lookup('org.ametys.core.util.JSONUtils');

migrateServicesOfType('org.ametys.plugins.userdirectory.service.OrganizationChart', {'maxLevel': 'long-not-zero'});
migrateServicesOfType('org.ametys.plugins.google-calendar.service.Calendar', {'iframe-height': 'long', 'iframe-border': 'boolean', 'showTitle': 'boolean', 'showNav': 'boolean', 'showDate': 'boolean', 'showPrint': 'boolean', 'showTabs': 'boolean', 'showCalendars': 'boolean', 'showTz': 'boolean'});
migrateServicesOfType('org.ametys.blog.service.PostsService', {'year': 'long', 'month': 'long'});
migrateServicesOfType('org.ametys.blog.service.PostsByTagsService', {'excludePrivateTags': 'boolean'});
migrateServicesOfType('org.ametys.plugins.linkdirectory.DirectoryService', {'displayUserLinks': 'boolean', 'configurable': 'boolean', 'showUrl': 'boolean', 'showThemes': 'boolean'});
migrateServicesOfType('org.ametys.plugins.external.data.search.service', {'limit': 'long'});
migrateServicesOfType('org.ametys.plugins.calendar.Calendar', {'months-before': 'long', 'months-after': 'long', 'contents-on-same-page': 'boolean', 'handle-user-access': 'boolean'});
migrateServicesOfType('org.ametys.plugins.calendar.Agenda', {'months-before': 'long', 'months-after': 'long', 'mask-orphan': 'boolean', 'handle-user-access': 'boolean', 'pdf-download': 'boolean', 'ical-download': 'boolean', 'rss': 'boolean'});
migrateServicesOfType('org.ametys.web.service.FilteredPagesService', {'nb-max': 'long', 'pagination': 'long'});
migrateServicesOfType('org.ametys.newsletter.service.ListService', {'length': 'long', 'rss': 'boolean'});
migrateServicesOfType('org.ametys.web.service.SitemapService', {'depth': 'long', 'includeInvisiblePage': 'boolean'});
migrateServicesOfType('org.ametys.web.service.IframeService', {'iframe-height': 'long', 'iframe-border': 'boolean', 'transparancy': 'boolean'});
migrateServicesOfType('org.ametys.odf.service.ProgramList', {'alphaOrderOnFirstLevel': 'boolean', 'alphaOrderOnSecondLevel': 'boolean', 'displaySubProgram': 'boolean'});
migrateServicesOfType('org.ametys.plugins.server.directory', {'enableDynamicPaths': 'boolean'});
migrateServicesOfType('org.ametys.plugins.tagcloud.services.Words', {'limit': 'long'});
migrateServicesOfType('org.ametys.plugins.tagcloud.services.Tags', {'limit': 'long'});
migrateServicesOfType('org.ametys.plugin.ugc.service.UGC', {'user': 'user'});
migrateServicesOfType('org.ametys.proxied-content.service.Revamping', {'cas': 'boolean'});
migrateServicesOfType('org.ametys.plugins.blog.service.FilteredPostsService', {'pagination': 'long'});
migrateServicesOfType('org.ametys.plugins.socialnetworking.twitter.showtweets', {'max': 'long'});
migrateServicesOfType('org.ametys.web.service.FrontSearchService', {'advanced-search': 'boolean', 'strict-search-on-tags': 'boolean', 'search-multisite': 'boolean', 'facets': 'boolean', 'offset': 'long', 'withWorkspaces': 'boolean'});
migrateServicesOfType('org.ametys.web.service.ResourcesSearchService', {'offset': 'long', 'search-by-format': 'boolean', 'search-by-creator': 'boolean', 'search-by-publisher': 'boolean', 'search-by-rights': 'boolean', 'search-multisite': 'boolean', 'on-same-page': 'boolean'});
migrateServicesOfType('org.ametys.odf.service.SearchService', {'advanced-search': 'boolean', 'subprogram-search': 'boolean', 'facets': 'boolean', 'offset': 'long'});
migrateServicesOfType('org.ametys.odf.service.SearchCourseService', {'advanced-search': 'boolean', 'facets': 'boolean', 'displayProgramReferences': 'boolean', 'offset': 'long'});
migrateServicesOfType('org.ametys.plugins.syndication.service.RSS', {'length': 'long', 'nb-feed-user': 'long', 'nb-feed-max': 'long'}, {'feeds': {'length': 'long', 'limited': 'boolean', 'fo-group': 'to-multiple', 'fo-user': 'multiple-user', 'cache': 'to-empty'}});
migrateServicesOfType('org.ametys.web.service.FilteredContentsService', {'nb-max': 'long', 'pagination': 'long', 'mask-orphan': 'boolean', 'handle-user-access': 'boolean', 'rss': 'boolean'}, {'search': {'strict-search-on-tags': 'boolean'}});

Ametys.console.info("End of services migration");

function migrateServicesOfType(serviceId, serviceParams, serviceParamsRepeaters)
{
    migrateServicesOfTypeInSession(serviceId, serviceParams, serviceParamsRepeaters, Repository.session);
    migrateServicesOfTypeInSession(serviceId, serviceParams, serviceParamsRepeaters, Repository.liveSession);
}

function migrateServicesOfTypeInSession(serviceId, serviceParams, serviceParamsRepeaters, session)
{
    let zoneItems = Repository.query("//element(*, ametys:zoneItem)[@ametys-internal:type = 'SERVICE' and @ametys-internal:service = '" + serviceId + "']", false, session);
    let count = 0;
    while (zoneItems.hasNext())
    {
        let zoneItem = zoneItems.nextNode();
        if (_migrateService(zoneItem, serviceParams, serviceParamsRepeaters))
        {
            count++;
        }
    }

    if (count > 0)
    {
        if (handle)
        {
            session.save();
        }
        Ametys.console.info("[" + session.getWorkspace().getName() + "] " + count + " '" + serviceId + "' services have been migrated.");
    }
}

function _migrateService(node, params, repeaters)
{
    let paramsNode = node.getNode("ametys:service_parameters");
    let hasChanges = false;

    for (let name in params)
    {
        hasChanges = __convertStringPropertyTo(paramsNode, "ametys:" + name, params[name]) || hasChanges;
    }

    for (let repeaterName in repeaters)
    {
        if (paramsNode.hasNode("ametys:" + repeaterName))
        {
            let repeaterEntries = paramsNode.getNode("ametys:" + repeaterName).getNodes();
            while (repeaterEntries.hasNext())
            {
                let repeaterEntry = repeaterEntries.nextNode();
                let repeaterParams = repeaters[repeaterName];
                for (let name in repeaterParams)
                {
                    hasChanges = __convertStringPropertyTo(repeaterEntry, "ametys:" + name, repeaterParams[name]) || hasChanges;
                }
            }
        }
    }

    return hasChanges;
}

function __convertStringPropertyTo(holder, propertyName, type)
{
    let hasChanges = false;

    if (holder.hasProperty(propertyName))
    {
        let property = holder.getProperty(propertyName);
        if (property.getType() == 1) // 1 is for string
        {
            if (type == 'to-multiple')
            {
                hasChanges = Repository.helper.convertSingleToMultipleProperty(holder, propertyName) || hasChanges;
            }
            else if (type == 'multiple-user')
            {
                __convertStringPropertyToMultipleUser(holder, property);
                hasChanges = true;
            }
            else
            {
                let valueAsString = property.getString();

                if (type != 'to-empty' || !valueAsString)
                {
                    property.remove();
                    hasChanges = true;

                    if (valueAsString)
                    {
                        if (type == 'long' || (type == 'long-not-zero' && Number(valueAsString) >= 1))
                        {
                            __convertStringPropertyToLong(holder, propertyName, valueAsString);
                        }
                        else if (type == 'boolean')
                        {
                            __convertStringPropertyToBoolean(holder, propertyName, valueAsString);
                        }
                        else if (type == 'user')
                        {
                            __convertStringPropertyToUser(holder, propertyName, valueAsString);
                        }
                    }
                }
            }
        }
    }

    return hasChanges;
}

function __convertStringPropertyToBoolean(node, propertyName, valueAsString)
{
    if (valueAsString == "true")
    {
        Repository.helper.setProperty(node, propertyName, true);
    }
    else if (valueAsString == "false")
    {
        Repository.helper.setProperty(node, propertyName, false);
    }
}

function __convertStringPropertyToLong(node, propertyName, valueAsString)
{
    Repository.helper.setProperty(node, propertyName, Number(valueAsString));
}

function __convertStringPropertyToUser(node, propertyName, valueAsString)
{
    let userMap = jsonUtils.convertJsonToMap(valueAsString);

    let userNode = node.addNode(propertyName, 'ametys:user');
    userNode.setProperty('ametys:login', userMap.get("login"));
    userNode.setProperty('ametys:population', userMap.get("populationId"));
}

function __convertStringPropertyToMultipleUser(node, property)
{
    let nodeName = property.getName();
    if (!property.isMultiple())
    {
        Repository.helper.convertSingleToMultipleProperty(node, nodeName) || hasChanges;
        property = node.getProperty(nodeName);
    }
    let values = property.getValues();
    property.remove();

    if (values)
    {
        let usersNode = node.addNode(nodeName, 'ametys:multipleItem');
        usersNode.setProperty('ametys-internal:typeId', 'user');

        for (let i = 0; i < values.length; i++)
        {
            __convertStringPropertyToUser(usersNode, 'ametys:' + (i + 1), values[i].getString());
        }
    }
}

Avant la 4.3, prenez un des deux scripts ci-dessous, mais ils sont buggués, les données "vides" ne sont pas bien supprimées.

Exécutez le script suivant pour migrer l'ensemble de vos services.

Réconstruisez le workspace Live ensuite.

var ConsoleHelper = Java.type('org.ametys.workspaces.repository.ConsoleHelper');         
function __getServicesNodes(serviceId)                                
{                                
    var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type = 'SERVICE' and @ametys-internal:service = '" + serviceId + "']", javax.jcr.query.Query.XPATH);                                        
    return query.execute().getNodes();                                  
}                                
                     
function __migrateService(node, params)                                
{                                
    var paramsNode = node.getNode("ametys:service_parameters");                                
    var hasChanges = false;                                
    for (var name in params)                                
    {                                        
      var hasChanges = false;                                
      var type = params[name];                                
      if (type == 'long')                                
      {                                
        hasChanges = __convertStringPropertyToLong(paramsNode, "ametys:" + name) || hasChanges;                                
      }                                
      else if (type == 'boolean')                                
      {                                
        hasChanges = __convertStringPropertyToBoolean(paramsNode, "ametys:" + name) || hasChanges;                                
      }                       
      else if (type == 'user')                       
      {                       
        hasChanges = __convertStringPropertyToUser(paramsNode, "ametys:" + name) || hasChanges;                       
      }                       
    }                                
                                 
    return hasChanges;                                      
}                                
                     
function __convertStringPropertyToBoolean(node, propertyName)                                        
{                                       
  var hasChanged = false;                                        
  if (node.hasProperty(propertyName))                                        
  {                                        
    var property = node.getProperty(propertyName);                                  
    if (property.getType() == 1) // 1 is for string                                        
    {                                        
      var valueAsString = property.getString();                                        
      property.remove();                                        
                                      
      if (valueAsString == "true")                                        
      {                                        
        ConsoleHelper.setProperty(node, propertyName, true);                                        
        hasChanged = true;                                        
      }                                        
      else if (valueAsString == "false")                                        
      {                                        
        ConsoleHelper.setProperty(node, propertyName, false);                                        
        hasChanged = true;                                        
      }                                        
    }                                        
  }                                            
  return hasChanged;                                        
}                                
                     
function __convertStringPropertyToLong(node, propertyName)                                        
{                                        
  var hasChanged = false;                                        
  if (node.hasProperty(propertyName))                                        
  {                                        
    var property = node.getProperty(propertyName);                                        
    if (property.getType() == 1) // 1 is for string                                        
    {                                        
      var valueAsString = property.getString();                                        
      property.remove();                                        
                                      
      if (valueAsString)                                        
      {                                          
        node['setProperty(java.lang.String, long)'](propertyName, Number(valueAsString));                                        
        hasChanged = true;                                        
      }                                        
    }                                        
  }                                              
  return hasChanged;                                        
}                       
                     
function __convertStringPropertyToUser(node, propertyName)                       
{                       
  var hasChanged = false;                       
  if (node.hasProperty(propertyName))                       
  {                       
    var property = node.getProperty(propertyName);                       
    if (property.getType() == 1) // 1 is for string                       
    {                       
      var valueAsString = property.getString();                       
      property.remove();                       
                       
     if (valueAsString)                       
     {                       
       var jsonUtils = serviceManager.lookup('org.ametys.core.util.JSONUtils');                       
       var userMap = jsonUtils.convertJsonToMap(valueAsString);                       
                             
       var userNode = node.addNode(propertyName, 'ametys:user');                       
       userNode.setProperty('ametys:login', userMap.get("login"));                       
       userNode.setProperty('ametys:population', userMap.get("populationId"));                       
                             
       hasChanged = true;                       
     }                       
    }                       
   }                       
   return hasChanged;                       
}            
            
function __convertStringPropertyToMultipleUser(node, propertyName)            
{            
  var hasChanged = false;            
  if (node.hasProperty(propertyName))            
  {            
    var property = node.getProperty(propertyName);            
    if (property.getType() == 1) // 1 is for string            
    {            
      var values = property.getValues();            
      property.remove();            
            
      if (values)            
      {            
        var jsonUtils = serviceManager.lookup('org.ametys.core.util.JSONUtils');            
        var usersNode = node.addNode(propertyName, 'ametys:multipleItem');            
        usersNode.setProperty('ametys-internal:typeId', 'user');            
            
        for (var i = 0; i < values.length; i++)            
        {            
          var user = jsonUtils.convertJsonToMap(values[i].getString());            
          var nodeIndex = i + 1;            
          var userNode = usersNode.addNode('ametys:' + nodeIndex, 'ametys:user');            
          userNode.setProperty('ametys:login', user.get("login"));            
          userNode.setProperty('ametys:population', user.get("populationId"));            
        }            
            
        hasChanged = true;            
      }            
    }            
  }            
  return hasChanged;            
}            
            
function __removeStringPropertyIfEmpty(node, propertyName)            
{            
  var hasChanged = false;            
  if (node.hasProperty(propertyName))            
  {            
    var property = node.getProperty(propertyName);            
    if (property.getType() == 1) // 1 is for string            
    {            
      var valueAsString = property.getString();            
            
      if (!valueAsString)            
      {            
        property.remove();            
        hasChanged = true;            
      }            
    }            
  }            
  return hasChanged;            
}            
            
function migrateGoogleCalendarService()                                
{                                
    var params = {'iframe-height': 'long', 'iframe-border': 'boolean', 'showTitle': 'boolean', 'showNav': 'boolean', 'showDate': 'boolean', 'showPrint': 'boolean', 'showTabs': 'boolean', 'showCalendars': 'boolean', 'showTz': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.plugins.google-calendar.service.Calendar');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
        session.save();                                
        print(count + " google calendar services have been migrated.");                                
    }                                  
}                                   
                     
function migrateFilteredContentsService()                                
{                                
    var params = {'nb-max': 'long', 'pagination': 'long', 'mask-orphan': 'boolean', 'handle-user-access': 'boolean', 'rss': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.web.service.FilteredContentsService');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        var node = nodes.nextNode();                                
        var hasChanges = __migrateService(node, params);                                
                                        
        var paramsNode = node.getNode("ametys:service_parameters");                                
        var repeaterEntries = paramsNode.getNode("ametys:search").getNodes();                                        
        while (repeaterEntries.hasNext())                                        
        {                                        
          var repeaterEntry = repeaterEntries.nextNode();                                        
          hasChanges = __convertStringPropertyToBoolean(repeaterEntry, "ametys:strict-search-on-tags") || hasChanges;                                        
        }                                   
                                    
        if (hasChanges)                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
        session.save();                                
        print(count + " filtered contents services have been migrated.");                                
    }                                   
}                                    
                     
function migratePostsService()                                
{                                
    var params = {'year': 'long', 'month': 'long'};                                
    var nodes = __getServicesNodes('org.ametys.blog.service.PostsService');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
        session.save();                                
        print(count + " posts services have been migrated.");                                
    }                                  
}                                  
                     
function migratePostsByTagsService()                                
{                                
    var params = {'excludePrivateTags': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.blog.service.PostsByTagsService');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
        session.save();                                
        print(count + " posts services have been migrated.");                                
    }                                  
}                                
                                 
function migrateLinkDirectoryService()                                
{                                
    var params = {'displayUserLinks': 'boolean', 'configurable': 'boolean', 'showUrl': 'boolean', 'showThemes': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.plugins.linkdirectory.DirectoryService');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
        session.save();                                
        print(count + " link directory services have been migrated.");                                
    }                                  
}                                  
                     
function migrateExternalSearchService()                                
{                                
    var params = {'limit': 'long'};                                
    var nodes = __getServicesNodes('org.ametys.plugins.external.data.search.service');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
      session.save();                                
      print(count + " external search services have been migrated.");                                
    }                                  
}                                
                     
function migrateCalendarService()                                
{                                
    var params = {'months-before': 'long', 'months-after': 'long', 'contents-on-same-page': 'boolean', 'handle-user-access': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.plugins.calendar.Calendar');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
      session.save();                                
      print(count + " calendar services have been migrated.");                                
    }                                  
}                                
                     
function migrateAgendaService()                                
{                                
    var params = {'months-before': 'long', 'months-after': 'long', 'mask-orphan': 'boolean', 'handle-user-access': 'boolean', 'pdf-download': 'boolean', 'ical-download': 'boolean', 'rss': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.plugins.calendar.Agenda');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
      session.save();                                
      print(count + " agenda services have been migrated.");                                
    }                                  
}                               
                     
function migrateFilteredPagesService()                               
{                               
    var params = {'nb-max': 'long', 'pagination': 'long'};                               
    var nodes = __getServicesNodes('org.ametys.web.service.FilteredPagesService');                               
    var count = 0;                                  
    while (nodes.hasNext())                                  
    {                               
        if (__migrateService(nodes.nextNode(), params))                               
        {                               
          count++;                               
        }                               
    }                               
                                
    if (count > 0)                               
    {                               
      session.save();                               
      print(count + " filtered pages services have been migrated.");                               
    }                                 
}                            
                     
function migrateNewsletterListService()                            
{                            
    var params = {'length': 'long', 'rss': 'boolean'};                            
    var nodes = __getServicesNodes('org.ametys.newsletter.service.ListService');                            
    var count = 0;                            
    while (nodes.hasNext())                            
    {                            
        if (__migrateService(nodes.nextNode(), params))                            
        {                            
            count++;                            
        }                            
    }                            
                            
    if (count > 0)                            
    {                            
        session.save();                            
        print(count + " newsletter list services have been migrated.");                            
    }                            
}                            
                     
function migrateSitemapService()                            
{                            
    var params = {'depth': 'long', 'includeInvisiblePage': 'boolean'};                            
    var nodes = __getServicesNodes('org.ametys.web.service.SitemapService');                            
    var count = 0;                            
    while (nodes.hasNext())                            
    {                            
        if (__migrateService(nodes.nextNode(), params))                            
        {                            
            count++;                            
        }                            
    }                            
                            
    if (count > 0)                            
    {                            
        session.save();                            
        print(count + " sitemap services have been migrated.");                            
    }                            
}                            
                     
function migrateIframeService()                            
{                            
    var params = {'iframe-height': 'long', 'iframe-border': 'boolean', 'transparancy': 'boolean'};                            
    var nodes = __getServicesNodes('org.ametys.web.service.IframeService');                            
    var count = 0;                            
    while (nodes.hasNext())                            
    {                            
        if (__migrateService(nodes.nextNode(), params))                            
        {                            
            count++;                            
        }                            
    }                            
                            
    if (count > 0)                            
    {                            
        session.save();                            
        print(count + " iframe services have been migrated.");                            
    }                            
}                            
                     
function migrateProgramListService()                           
{                           
    var params = {'alphaOrderOnFirstLevel': 'boolean', 'alphaOrderOnSecondLevel': 'boolean', 'displaySubProgram': 'boolean'};                           
    var nodes = __getServicesNodes('org.ametys.odf.service.ProgramList');                           
    var count = 0;                           
    while (nodes.hasNext())                           
    {                           
        if (__migrateService(nodes.nextNode(), params))                           
        {                           
            count++;                           
        }                           
    }                           
                           
    if (count > 0)                           
    {                           
        session.save();                           
        print(count + " program list services have been migrated.");                           
    }                           
}                           
                     
function migrateServerDirectoryService()                           
{                           
    var params = {'enableDynamicPaths': 'boolean'};                           
    var nodes = __getServicesNodes('org.ametys.plugins.server.directory');                           
    var count = 0;                           
    while (nodes.hasNext())                           
    {                           
        if (__migrateService(nodes.nextNode(), params))                           
        {                           
            count++;                           
        }                           
    }                           
                           
    if (count > 0)                           
    {                           
        session.save();                           
        print(count + " server directory services have been migrated.");                           
    }                           
}                           
                     
function migrateWordsService()                           
{                           
    var params = {'limit': 'long'};                           
    var nodes = __getServicesNodes('org.ametys.plugins.tagcloud.services.Words');                           
    var count = 0;                           
    while (nodes.hasNext())                           
    {                           
        if (__migrateService(nodes.nextNode(), params))                           
        {                           
            count++;                           
        }                           
    }                           
                           
    if (count > 0)                           
    {                           
        session.save();                           
        print(count + " words services have been migrated.");                           
    }                           
}                           
                     
function migrateTagsService()                           
{                           
    var params = {'limit': 'long'};                           
    var nodes = __getServicesNodes('org.ametys.plugins.tagcloud.services.Tags');                           
    var count = 0;                           
    while (nodes.hasNext())                           
    {                           
        if (__migrateService(nodes.nextNode(), params))                           
        {                           
            count++;                           
        }                           
    }                           
                           
    if (count > 0)                           
    {                           
        session.save();                           
        print(count + " tags services have been migrated.");                           
    }                           
}                       
                     
function migrateUGCService()                       
{                       
  var params = {'user': 'user'};                       
  var nodes = __getServicesNodes('org.ametys.plugin.ugc.service.UGC');                       
  var count = 0;                       
  while (nodes.hasNext())                       
  {                       
    if (__migrateService(nodes.nextNode(), params))                       
    {                       
      count++;                       
    }                       
  }                       
                       
  if (count > 0)                       
  {                       
    session.save();                       
    print(count + " UGC services have been migrated.");                       
  }                       
}                      
                     
function migrateRevampingService()                      
{                      
  var params = {'cas': 'boolean'};                      
  var nodes = __getServicesNodes('org.ametys.proxied-content.service.Revamping');                      
  var count = 0;                      
  while (nodes.hasNext())                      
  {                      
    if (__migrateService(nodes.nextNode(), params))                      
    {                      
      count++;                      
    }                      
  }                      
                     
  if (count > 0)                      
  {                      
    session.save();                      
    print(count + " revamping services have been migrated.");                      
  }                      
}                 
            
function migrateFilteredPostsService()                      
{                      
  var params = {'pagination': 'long'};                      
  var nodes = __getServicesNodes('org.ametys.plugins.blog.service.FilteredPostsService');                      
  var count = 0;                      
  while (nodes.hasNext())                      
  {                      
    if (__migrateService(nodes.nextNode(), params))                      
    {                      
      count++;                      
    }                      
  }                      
                     
  if (count > 0)                      
  {                      
    session.save();                      
    print(count + " filtered posts services have been migrated.");                      
  }                      
}                
            
function migrateShowTweetsService()                
{                
  var params = {'max': 'long'};                
  var nodes = __getServicesNodes('org.ametys.plugins.socialnetworking.twitter.showtweets');                
  var count = 0;                
  while (nodes.hasNext())                
  {                
    if (__migrateService(nodes.nextNode(), params))                
    {                
      count++;                
    }                
  }                
            
  if (count > 0)                
  {                
    session.save();                
    print(count + " swhow tweets services have been migrated.");                
  }                
}               
            
function migrateSearchService()              
{              
  var params = {'advanced-search': 'boolean', 'strict-search-on-tags': 'boolean', 'search-multisite': 'boolean', 'facets': 'boolean', 'offset': 'long', 'withWorkspaces': 'boolean'};              
  var nodes = __getServicesNodes('org.ametys.web.service.FrontSearchService');              
  var count = 0;              
  while (nodes.hasNext())              
  {              
    if (__migrateService(nodes.nextNode(), params))              
    {              
      count++;              
    }              
  }              
              
  if (count > 0)              
  {              
    session.save();              
    print(count + " search services have been migrated.");              
  }              
}              
            
function migrateResourcesSearchService()              
{              
  var params = {'offset': 'long', 'search-by-format': 'boolean', 'search-by-creator': 'boolean', 'search-by-publisher': 'boolean', 'search-by-rights': 'boolean', 'search-multisite': 'boolean', 'on-same-page': 'boolean'};              
  var nodes = __getServicesNodes('org.ametys.web.service.ResourcesSearchService');              
  var count = 0;              
  while (nodes.hasNext())              
  {              
    if (__migrateService(nodes.nextNode(), params))              
    {              
      count++;              
    }              
  }              
              
  if (count > 0)              
  {              
    session.save();              
    print(count + " resources search services have been migrated.");              
  }              
}              
            
function migrateODFSearchService()              
{              
  var params = {'advanced-search': 'boolean', 'subprogram-search': 'boolean', 'facets': 'boolean', 'offset': 'long'};              
  var nodes = __getServicesNodes('org.ametys.odf.service.SearchService');              
  var count = 0;              
  while (nodes.hasNext())              
  {              
    if (__migrateService(nodes.nextNode(), params))              
    {              
      count++;              
    }              
  }              
              
  if (count > 0)              
  {              
    session.save();              
    print(count + " (ODF) search services have been migrated.");              
  }              
}              
            
function migrateSearchCourseService()              
{              
  var params = {'advanced-search': 'boolean', 'facets': 'boolean', 'displayProgramReferences': 'boolean', 'offset': 'long'};              
  var nodes = __getServicesNodes('org.ametys.odf.service.SearchCourseService');              
  var count = 0;              
  while (nodes.hasNext())              
  {              
    if (__migrateService(nodes.nextNode(), params))              
    {              
       count++;              
    }              
  }              
              
  if (count > 0)              
  {              
    session.save();              
    print(count + " search courses services have been migrated.");              
  }              
}            
            
function migrateSyndicationService()            
{            
  var params = {'length': 'long', 'nb-feed-user': 'long', 'nb-feed-max': 'long'};            
  var nodes = __getServicesNodes('org.ametys.plugins.syndication.service.RSS');            
  var count = 0;            
  while (nodes.hasNext())            
  {            
    var node = nodes.nextNode();            
    var hasChanges = __migrateService(node, params);            
            
    var paramsNode = node.getNode("ametys:service_parameters");            
    var repeaterEntries = paramsNode.getNode("ametys:feeds").getNodes();            
    while (repeaterEntries.hasNext())            
    {            
      var repeaterEntry = repeaterEntries.nextNode();            
      hasChanges = __convertStringPropertyToLong(repeaterEntry, "ametys:length") || hasChanges;            
      hasChanges = __convertStringPropertyToBoolean(repeaterEntry, "ametys:limited") || hasChanges;            
   hasChanges = ConsoleHelper.convertSingleToMultipleProperty(repeaterEntry, "ametys:fo-user") || hasChanges;          
 hasChanges = ConsoleHelper.convertSingleToMultipleProperty(repeaterEntry, "ametys:fo-group") || hasChanges;          
 hasChanges = __convertStringPropertyToMultipleUser(repeaterEntry, "ametys:fo-user") || hasChanges;            
      hasChanges = __removeStringPropertyIfEmpty(repeaterEntry, "ametys:cache") || hasChanges;            
    }            
            
    if (hasChanges)            
    {            
      count++;            
    }            
  }            
            
  if (count > 0)            
  {            
    session.save();            
    print(count + " syndication RSS services have been migrated.");            
  }            
}          

function migrateOrganizationChartService()       
{       
 var nodes = __getServicesNodes('org.ametys.plugins.userdirectory.service.OrganizationChart');       
 var count = 0;     
       
 while (nodes.hasNext())       
 {       
 var node = nodes.nextNode();       
 var paramsNode = node.getNode("ametys:service_parameters");       
       
 if (node.hasProperty("ametys:maxLevel"))       
 {       
 var property = node.getProperty("ametys:maxLevel");       
       
 var property = node.getProperty(propertyName);       
 if (property.getType() == 1) // 1 is for string       
 {       
 count++;       
 var value = Number(property.getString());       
 property.remove();       
       
 if (value >= 1) // If the property is not filled, then value == 0       
 {       
      ConsoleHelper.setProperty(node, "ametys:maxLevel", value);       
 }       
 }       
 }       
 }       
       
 if (count > 0)       
 {       
 session.save();       
 print(count + " organization chart services have been migrated.");       
 }       
}       
                     
var qm = session.getWorkspace().getQueryManager();                                  
                                             
migrateOrganizationChartService();       
migrateGoogleCalendarService();                                  
migrateLinkDirectoryService();                                                    
migrateServerDirectoryService();                            
migrateWordsService();                            
migrateTagsService();                                        
migrateRevampingService();                                
migrateSitemapService();                            
migrateIframeService();                    
migrateExternalSearchService();                    
migrateUGCService();                                            
migratePostsService();                   
migratePostsByTagsService();                   
migrateCalendarService();                   
migrateAgendaService();                   
migrateProgramListService();                            
migrateNewsletterListService();                     
migrateShowTweetsService();                       
migrateSearchService();              
migrateResourcesSearchService();              
migrateODFSearchService();              
migrateSearchCourseService();              
migrateFilteredContentsService();                               
migrateFilteredPagesService();                 
migrateFilteredPostsService();                
migrateSyndicationService();            
                     
print("End of migration, you can rebuild the Live workspace");                                

Dans le cas d'une migration 4.1 vers 4.3, utilisez le script suivant :

var ConsoleHelper = Java.type('org.ametys.workspaces.repository.ConsoleHelper');         
function __getServicesNodes(serviceId)                                
{                                
    var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type = 'SERVICE' and @ametys-internal:service = '" + serviceId + "']", javax.jcr.query.Query.XPATH);                                        
    return query.execute().getNodes();                                  
}                                
                     
function __migrateService(node, params)                                
{                                
    var paramsNode = node.getNode("ametys:service_parameters");                                
    var hasChanges = false;                                
    for (var name in params)                                
    {                                        
      var hasChanges = false;                                
      var type = params[name];                                
      if (type == 'long')                                
      {                                
        hasChanges = __convertStringPropertyToLong(paramsNode, "ametys:" + name) || hasChanges;                                
      }                                
      else if (type == 'boolean')                                
      {                                
        hasChanges = __convertStringPropertyToBoolean(paramsNode, "ametys:" + name) || hasChanges;                                
      }                       
      else if (type == 'user')                       
      {                       
        hasChanges = __convertStringPropertyToUser(paramsNode, "ametys:" + name) || hasChanges;                       
      }                       
    }                                
                                 
    return hasChanges;                                      
}                                
                     
function __convertStringPropertyToBoolean(node, propertyName)                                        
{                                       
  var hasChanged = false;                                        
  if (node.hasProperty(propertyName))                                        
  {                                        
    var property = node.getProperty(propertyName);                                  
    if (property.getType() == 1) // 1 is for string                                        
    {                                        
      var valueAsString = property.getString();                                        
      property.remove();                                        
                                      
      if (valueAsString == "true")                                        
      {                                        
        ConsoleHelper.setProperty(node, propertyName, true);                                        
        hasChanged = true;                                        
      }                                        
      else if (valueAsString == "false")                                        
      {                                        
        ConsoleHelper.setProperty(node, propertyName, false);                                        
        hasChanged = true;                                        
      }                                        
    }                                        
  }                                            
  return hasChanged;                                        
}                                
                     
function __convertStringPropertyToLong(node, propertyName)                                        
{                                        
  var hasChanged = false;                                        
  if (node.hasProperty(propertyName))                                        
  {                                        
    var property = node.getProperty(propertyName);                                        
    if (property.getType() == 1) // 1 is for string                                        
    {                                        
      var valueAsString = property.getString();                                        
      property.remove();                                        
                                      
      if (valueAsString)                                        
      {                                          
        ConsoleHelper.setProperty(node, propertyName, Number(valueAsString));                                        
        hasChanged = true;                                        
      }                                        
    }                                        
  }                                              
  return hasChanged;                                        
}                       
                     
function __convertStringPropertyToUser(node, propertyName)                       
{                       
  var hasChanged = false;                       
  if (node.hasProperty(propertyName))                       
  {                       
    var property = node.getProperty(propertyName);                       
    if (property.getType() == 1) // 1 is for string                       
    {                       
      var valueAsString = property.getString();                       
      property.remove();                       
                       
     if (valueAsString)                       
     {                       
       var jsonUtils = serviceManager.lookup('org.ametys.core.util.JSONUtils');                       
       var userMap = jsonUtils.convertJsonToMap(valueAsString);                       
                             
       var userNode = node.addNode(propertyName, 'ametys:user');                       
       userNode.setProperty('ametys:login', userMap.get("login"));                       
       userNode.setProperty('ametys:population', userMap.get("populationId"));                       
                             
       hasChanged = true;                       
     }                       
    }                       
   }                       
   return hasChanged;                       
}            
            
function __convertStringPropertyToMultipleUser(node, propertyName)            
{            
  var hasChanged = false;            
  if (node.hasProperty(propertyName))            
  {            
    var property = node.getProperty(propertyName);            
    if (property.getType() == 1) // 1 is for string            
    {            
      var values = property.getValues();            
      property.remove();            
            
      if (values)            
      {            
        var jsonUtils = serviceManager.lookup('org.ametys.core.util.JSONUtils');            
        var usersNode = node.addNode(propertyName, 'ametys:multipleItem');            
        usersNode.setProperty('ametys-internal:typeId', 'user');            
            
        for (var i = 0; i < values.length; i++)            
        {            
          var user = jsonUtils.convertJsonToMap(values[i].getString());            
          var nodeIndex = i + 1;            
          var userNode = usersNode.addNode('ametys:' + nodeIndex, 'ametys:user');            
          userNode.setProperty('ametys:login', user.get("login"));            
          userNode.setProperty('ametys:population', user.get("populationId"));            
        }            
            
        hasChanged = true;            
      }            
    }            
  }            
  return hasChanged;            
}            
            
function __removeStringPropertyIfEmpty(node, propertyName)            
{            
  var hasChanged = false;            
  if (node.hasProperty(propertyName))            
  {            
    var property = node.getProperty(propertyName);            
    if (property.getType() == 1) // 1 is for string            
    {            
      var valueAsString = property.getString();            
            
      if (!valueAsString)            
      {            
        property.remove();            
        hasChanged = true;            
      }            
    }            
  }            
  return hasChanged;            
}            
            
function migrateGoogleCalendarService()                                
{                                
    var params = {'iframe-height': 'long', 'iframe-border': 'boolean', 'showTitle': 'boolean', 'showNav': 'boolean', 'showDate': 'boolean', 'showPrint': 'boolean', 'showTabs': 'boolean', 'showCalendars': 'boolean', 'showTz': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.plugins.google-calendar.service.Calendar');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
        session.save();                                
        print(count + " google calendar services have been migrated.");                                
    }                                  
}                                   
                     
function migrateFilteredContentsService()                                
{                                
    var params = {'nb-max': 'long', 'pagination': 'long', 'mask-orphan': 'boolean', 'handle-user-access': 'boolean', 'rss': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.web.service.FilteredContentsService');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        var node = nodes.nextNode();                                
        var hasChanges = __migrateService(node, params);                                
                                        
        var paramsNode = node.getNode("ametys:service_parameters");                                
        var repeaterEntries = paramsNode.getNode("ametys:search").getNodes();                                        
        while (repeaterEntries.hasNext())                                        
        {                                        
          var repeaterEntry = repeaterEntries.nextNode();                                        
          hasChanges = __convertStringPropertyToBoolean(repeaterEntry, "ametys:strict-search-on-tags") || hasChanges;                                        
        }                                   
                                    
        if (hasChanges)                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
        session.save();                                
        print(count + " filtered contents services have been migrated.");                                
    }                                   
}                                    
                     
function migratePostsService()                                
{                                
    var params = {'year': 'long', 'month': 'long'};                                
    var nodes = __getServicesNodes('org.ametys.blog.service.PostsService');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
        session.save();                                
        print(count + " posts services have been migrated.");                                
    }                                  
}                                  
                     
function migratePostsByTagsService()                                
{                                
    var params = {'excludePrivateTags': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.blog.service.PostsByTagsService');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
        session.save();                                
        print(count + " posts services have been migrated.");                                
    }                                  
}                                
                                 
function migrateLinkDirectoryService()                                
{                                
    var params = {'displayUserLinks': 'boolean', 'configurable': 'boolean', 'showUrl': 'boolean', 'showThemes': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.plugins.linkdirectory.DirectoryService');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
        session.save();                                
        print(count + " link directory services have been migrated.");                                
    }                                  
}                                  
                     
function migrateExternalSearchService()                                
{                                
    var params = {'limit': 'long'};                                
    var nodes = __getServicesNodes('org.ametys.plugins.external.data.search.service');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
      session.save();                                
      print(count + " external search services have been migrated.");                                
    }                                  
}                                
                     
function migrateCalendarService()                                
{                                
    var params = {'months-before': 'long', 'months-after': 'long', 'contents-on-same-page': 'boolean', 'handle-user-access': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.plugins.calendar.Calendar');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
      session.save();                                
      print(count + " calendar services have been migrated.");                                
    }                                  
}                                
                     
function migrateAgendaService()                                
{                                
    var params = {'months-before': 'long', 'months-after': 'long', 'mask-orphan': 'boolean', 'handle-user-access': 'boolean', 'pdf-download': 'boolean', 'ical-download': 'boolean', 'rss': 'boolean'};                                
    var nodes = __getServicesNodes('org.ametys.plugins.calendar.Agenda');                                
    var count = 0;                                   
    while (nodes.hasNext())                                   
    {                                
        if (__migrateService(nodes.nextNode(), params))                                
        {                                
          count++;                                
        }                                
    }                                
                                 
    if (count > 0)                                
    {                                
      session.save();                                
      print(count + " agenda services have been migrated.");                                
    }                                  
}                               
                     
function migrateFilteredPagesService()                               
{                               
    var params = {'nb-max': 'long', 'pagination': 'long'};                               
    var nodes = __getServicesNodes('org.ametys.web.service.FilteredPagesService');                               
    var count = 0;                                  
    while (nodes.hasNext())                                  
    {                               
        if (__migrateService(nodes.nextNode(), params))                               
        {                               
          count++;                               
        }                               
    }                               
                                
    if (count > 0)                               
    {                               
      session.save();                               
      print(count + " filtered pages services have been migrated.");                               
    }                                 
}                            
                     
function migrateNewsletterListService()                            
{                            
    var params = {'length': 'long', 'rss': 'boolean'};                            
    var nodes = __getServicesNodes('org.ametys.newsletter.service.ListService');                            
    var count = 0;                            
    while (nodes.hasNext())                            
    {                            
        if (__migrateService(nodes.nextNode(), params))                            
        {                            
            count++;                            
        }                            
    }                            
                            
    if (count > 0)                            
    {                            
        session.save();                            
        print(count + " newsletter list services have been migrated.");                            
    }                            
}                            
                     
function migrateSitemapService()                            
{                            
    var params = {'depth': 'long', 'includeInvisiblePage': 'boolean'};                            
    var nodes = __getServicesNodes('org.ametys.web.service.SitemapService');                            
    var count = 0;                            
    while (nodes.hasNext())                            
    {                            
        if (__migrateService(nodes.nextNode(), params))                            
        {                            
            count++;                            
        }                            
    }                            
                            
    if (count > 0)                            
    {                            
        session.save();                            
        print(count + " sitemap services have been migrated.");                            
    }                            
}                            
                     
function migrateIframeService()                            
{                            
    var params = {'iframe-height': 'long', 'iframe-border': 'boolean', 'transparancy': 'boolean'};                            
    var nodes = __getServicesNodes('org.ametys.web.service.IframeService');                            
    var count = 0;                            
    while (nodes.hasNext())                            
    {                            
        if (__migrateService(nodes.nextNode(), params))                            
        {                            
            count++;                            
        }                            
    }                            
                            
    if (count > 0)                            
    {                            
        session.save();                            
        print(count + " iframe services have been migrated.");                            
    }                            
}                            
                     
function migrateProgramListService()                           
{                           
    var params = {'alphaOrderOnFirstLevel': 'boolean', 'alphaOrderOnSecondLevel': 'boolean', 'displaySubProgram': 'boolean'};                           
    var nodes = __getServicesNodes('org.ametys.odf.service.ProgramList');                           
    var count = 0;                           
    while (nodes.hasNext())                           
    {                           
        if (__migrateService(nodes.nextNode(), params))                           
        {                           
            count++;                           
        }                           
    }                           
                           
    if (count > 0)                           
    {                           
        session.save();                           
        print(count + " program list services have been migrated.");                           
    }                           
}                           
                     
function migrateServerDirectoryService()                           
{                           
    var params = {'enableDynamicPaths': 'boolean'};                           
    var nodes = __getServicesNodes('org.ametys.plugins.server.directory');                           
    var count = 0;                           
    while (nodes.hasNext())                           
    {                           
        if (__migrateService(nodes.nextNode(), params))                           
        {                           
            count++;                           
        }                           
    }                           
                           
    if (count > 0)                           
    {                           
        session.save();                           
        print(count + " server directory services have been migrated.");                           
    }                           
}                           
                     
function migrateWordsService()                           
{                           
    var params = {'limit': 'long'};                           
    var nodes = __getServicesNodes('org.ametys.plugins.tagcloud.services.Words');                           
    var count = 0;                           
    while (nodes.hasNext())                           
    {                           
        if (__migrateService(nodes.nextNode(), params))                           
        {                           
            count++;                           
        }                           
    }                           
                           
    if (count > 0)                           
    {                           
        session.save();                           
        print(count + " words services have been migrated.");                           
    }                           
}                           
                     
function migrateTagsService()                           
{                           
    var params = {'limit': 'long'};                           
    var nodes = __getServicesNodes('org.ametys.plugins.tagcloud.services.Tags');                           
    var count = 0;                           
    while (nodes.hasNext())                           
    {                           
        if (__migrateService(nodes.nextNode(), params))                           
        {                           
            count++;                           
        }                           
    }                           
                           
    if (count > 0)                           
    {                           
        session.save();                           
        print(count + " tags services have been migrated.");                           
    }                           
}                       
                     
function migrateUGCService()                       
{                       
  var params = {'user': 'user'};                       
  var nodes = __getServicesNodes('org.ametys.plugin.ugc.service.UGC');                       
  var count = 0;                       
  while (nodes.hasNext())                       
  {                       
    if (__migrateService(nodes.nextNode(), params))                       
    {                       
      count++;                       
    }                       
  }                       
                       
  if (count > 0)                       
  {                       
    session.save();                       
    print(count + " UGC services have been migrated.");                       
  }                       
}                      
                     
function migrateRevampingService()                      
{                      
  var params = {'cas': 'boolean'};                      
  var nodes = __getServicesNodes('org.ametys.proxied-content.service.Revamping');                      
  var count = 0;                      
  while (nodes.hasNext())                      
  {                      
    if (__migrateService(nodes.nextNode(), params))                      
    {                      
      count++;                      
    }                      
  }                      
                     
  if (count > 0)                      
  {                      
    session.save();                      
    print(count + " revamping services have been migrated.");                      
  }                      
}                 
            
function migrateFilteredPostsService()                      
{                      
  var params = {'pagination': 'long'};                      
  var nodes = __getServicesNodes('org.ametys.plugins.blog.service.FilteredPostsService');                      
  var count = 0;                      
  while (nodes.hasNext())                      
  {                      
    if (__migrateService(nodes.nextNode(), params))                      
    {                      
      count++;                      
    }                      
  }                      
                     
  if (count > 0)                      
  {                      
    session.save();                      
    print(count + " filtered posts services have been migrated.");                      
  }                      
}                
            
function migrateShowTweetsService()                
{                
  var params = {'max': 'long'};                
  var nodes = __getServicesNodes('org.ametys.plugins.socialnetworking.twitter.showtweets');                
  var count = 0;                
  while (nodes.hasNext())                
  {                
    if (__migrateService(nodes.nextNode(), params))                
    {                
      count++;                
    }                
  }                
            
  if (count > 0)                
  {                
    session.save();                
    print(count + " swhow tweets services have been migrated.");                
  }                
}               
            
function migrateSearchService()              
{              
  var params = {'advanced-search': 'boolean', 'strict-search-on-tags': 'boolean', 'search-multisite': 'boolean', 'facets': 'boolean', 'offset': 'long', 'withWorkspaces': 'boolean'};              
  var nodes = __getServicesNodes('org.ametys.web.service.FrontSearchService');              
  var count = 0;              
  while (nodes.hasNext())              
  {              
    if (__migrateService(nodes.nextNode(), params))              
    {              
      count++;              
    }              
  }              
              
  if (count > 0)              
  {              
    session.save();              
    print(count + " search services have been migrated.");              
  }              
}              
            
function migrateResourcesSearchService()              
{              
  var params = {'offset': 'long', 'search-by-format': 'boolean', 'search-by-creator': 'boolean', 'search-by-publisher': 'boolean', 'search-by-rights': 'boolean', 'search-multisite': 'boolean', 'on-same-page': 'boolean'};              
  var nodes = __getServicesNodes('org.ametys.web.service.ResourcesSearchService');              
  var count = 0;              
  while (nodes.hasNext())              
  {              
    if (__migrateService(nodes.nextNode(), params))              
    {              
      count++;              
    }              
  }              
              
  if (count > 0)              
  {              
    session.save();              
    print(count + " resources search services have been migrated.");              
  }              
}              
            
function migrateODFSearchService()              
{              
  var params = {'advanced-search': 'boolean', 'subprogram-search': 'boolean', 'facets': 'boolean', 'offset': 'long'};              
  var nodes = __getServicesNodes('org.ametys.odf.service.SearchService');              
  var count = 0;              
  while (nodes.hasNext())              
  {              
    if (__migrateService(nodes.nextNode(), params))              
    {              
      count++;              
    }              
  }              
              
  if (count > 0)              
  {              
    session.save();              
    print(count + " (ODF) search services have been migrated.");              
  }              
}              
            
function migrateSearchCourseService()              
{              
  var params = {'advanced-search': 'boolean', 'facets': 'boolean', 'displayProgramReferences': 'boolean', 'offset': 'long'};              
  var nodes = __getServicesNodes('org.ametys.odf.service.SearchCourseService');              
  var count = 0;              
  while (nodes.hasNext())              
  {              
    if (__migrateService(nodes.nextNode(), params))              
    {              
       count++;              
    }              
  }              
              
  if (count > 0)              
  {              
    session.save();              
    print(count + " search courses services have been migrated.");              
  }              
}            
            
function migrateSyndicationService()            
{            
  var params = {'length': 'long', 'nb-feed-user': 'long', 'nb-feed-max': 'long'};            
  var nodes = __getServicesNodes('org.ametys.plugins.syndication.service.RSS');            
  var count = 0;            
  while (nodes.hasNext())            
  {            
    var node = nodes.nextNode();            
    var hasChanges = __migrateService(node, params);            
            
    var paramsNode = node.getNode("ametys:service_parameters");            
    var repeaterEntries = paramsNode.getNode("ametys:feeds").getNodes();            
    while (repeaterEntries.hasNext())            
    {            
      var repeaterEntry = repeaterEntries.nextNode();            
      hasChanges = __convertStringPropertyToLong(repeaterEntry, "ametys:length") || hasChanges;            
      hasChanges = __convertStringPropertyToBoolean(repeaterEntry, "ametys:limited") || hasChanges;            
   hasChanges = ConsoleHelper.convertSingleToMultipleProperty(repeaterEntry, "ametys:fo-user") || hasChanges;          
 hasChanges = ConsoleHelper.convertSingleToMultipleProperty(repeaterEntry, "ametys:fo-group") || hasChanges;          
 hasChanges = __convertStringPropertyToMultipleUser(repeaterEntry, "ametys:fo-user") || hasChanges;            
      hasChanges = __removeStringPropertyIfEmpty(repeaterEntry, "ametys:cache") || hasChanges;            
    }            
            
    if (hasChanges)            
    {            
      count++;            
    }            
  }            
            
  if (count > 0)            
  {            
    session.save();            
    print(count + " syndication RSS services have been migrated.");            
  }            
}          

function migrateOrganizationChartService()       
{       
 var nodes = __getServicesNodes('org.ametys.plugins.userdirectory.service.OrganizationChart');       
 var count = 0;     
       
 while (nodes.hasNext())       
 {       
 var node = nodes.nextNode();       
 var paramsNode = node.getNode("ametys:service_parameters");       
       
 if (node.hasProperty("ametys:maxLevel"))       
 {       
 var property = node.getProperty("ametys:maxLevel");       
       
 var property = node.getProperty(propertyName);       
 if (property.getType() == 1) // 1 is for string       
 {       
 count++;       
 var value = Number(property.getString());       
 property.remove();       
       
 if (value >= 1) // If the property is not filled, then value == 0       
 {       
      ConsoleHelper.setProperty(node, "ametys:maxLevel", value);       
 }       
 }       
 }       
 }       
       
 if (count > 0)       
 {       
 session.save();       
 print(count + " organization chart services have been migrated.");       
 }       
}       
                     
var qm = session.getWorkspace().getQueryManager();                                  
                                             
migrateOrganizationChartService();       
migrateGoogleCalendarService();                                  
migrateLinkDirectoryService();                                                    
migrateServerDirectoryService();                            
migrateWordsService();                            
migrateTagsService();                                        
migrateRevampingService();                                
migrateSitemapService();                            
migrateIframeService();                    
migrateExternalSearchService();                    
migrateUGCService();                                            
migratePostsService();                   
migratePostsByTagsService();                   
migrateCalendarService();                   
migrateAgendaService();                   
migrateProgramListService();                            
migrateNewsletterListService();                     
migrateShowTweetsService();                       
migrateSearchService();              
migrateResourcesSearchService();              
migrateODFSearchService();              
migrateSearchCourseService();              
migrateFilteredContentsService();                               
migrateFilteredPagesService();                 
migrateFilteredPostsService();                
migrateSyndicationService();            
                     
print("End of migration, you can rebuild the Live workspace");