Plugin Server directoryMigration manual v1.0.0 to v1.1.0


For reasons of conformity with other Ametys services, the property bearing the service title has been renamed "header" instead of "title".

Run the following script in the repository interface console to migrate your existing services:

importPackage(javax.jcr);
 
var qm = session.getWorkspace().getQueryManager();
var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:service = 'org.ametys.plugins.server.directory']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
 
var count = 0;
while (nodes.hasNext())
{
    var zoneItem = nodes.next();
    var paramsNode = zoneItem.getNode('ametys:service_parameters');
  
    if (paramsNode.hasProperty('ametys:title'))
    {
        var v = paramsNode.getProperty('ametys:title').getString();
        paramsNode.setProperty("ametys:header", v);
        paramsNode.getProperty('ametys:title').remove();
        zoneItem.save();
        count++;
    }
}
println (count + " services 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:service = 'org.ametys.plugins.server.directory']", javax.jcr.query.Query.XPATH);
nodes = query.execute().getNodes();

count = 0;
while (nodes.hasNext())
{
    var zoneItem = nodes.next();
    var paramsNode = zoneItem.getNode('ametys:service_parameters');
  
    if (paramsNode.hasProperty('ametys:title'))
    {
        var v = paramsNode.getProperty('ametys:title').getString();
        paramsNode.setProperty("ametys:header", v);
        paramsNode.getProperty('ametys:title').remove();
        zoneItem.save();
        count++;
    }
}
println (count + " services have been migrated in LIVE");

Attention
If you have overloaded the service rendering, the service title can now be retrieved with : <xsl:param name="header" select="ametys:serviceParameter('header')"/>

Back to top

Server Directory