Plugin Répertoire ServeurManuel de migration v1.0.0 vers v1.1.0
Dernière publication:23/02/2018à 14:54LaurencePerier
Pour des raisons de conformité avec les autres services Ametys, la propriété portant le titre du service a été renommée "header" au lieu de "title".
Exécutez le script suivant dans la console de l'interface repository pour migrer vos services existants :
Oups !
La copie dans le presse papier a échouée. Ouvrez le code et copier-le manuellement.
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");
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");
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");