Since version 1.6.0, the Flux RSS or Atom service has made it possible to add several RSS feeds to the same service, unlike previous versions of plugin which only allowed a single RSS feed to be inserted.
The move to version 1.5.0 of plugin therefore 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.5.0 or earlier
Oops! Copy to clipboard failed. Open the code and copy it manually.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 node = nodes.next();
var paramsNode = node.getNode('ametys:service_parameters');
if (!paramsNode.hasNode('ametys:feeds'))
{
var feedsNode = paramsNode.addNode('ametys:feeds', 'ametys:compositeMetadata');
var entryNode = feedsNode.addNode('ametys:1', 'ametys:compositeMetadata');
if (paramsNode.hasProperty('ametys:url'))
{
var url = paramsNode.getProperty('ametys:url').getString();
entryNode.setProperty('ametys:url', url);
paramsNode.getProperty('ametys:url').remove();
}
if (paramsNode.hasProperty('ametys:length'))
{
var length = paramsNode.getProperty('ametys:length').getString();
entryNode.setProperty('ametys:length', length);
}
paramsNode.setProperty('ametys:link', '');
paramsNode.setProperty('ametys:link-title', '');
paramsNode.setProperty('ametys:nb-feed-max', '');
paramsNode.setProperty('ametys:nb-feed-user', '');
paramsNode.setProperty('ametys:cache', '3');
entryNode.setProperty('ametys:title', '');
entryNode.setProperty('ametys:limited', 'false');
entryNode.setProperty('ametys:fo-user', '');
entryNode.setProperty('ametys:fo-group', '');
entryNode.setProperty('ametys:cache', '3');
migrated++;
}
}
session.save();
println(migrated + ' service(s) have been migrated.');
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 node = nodes.next();
var paramsNode = node.getNode('ametys:service_parameters');
if (!paramsNode.hasNode('ametys:feeds'))
{
var feedsNode = paramsNode.addNode('ametys:feeds', 'ametys:compositeMetadata');
var entryNode = feedsNode.addNode('ametys:1', 'ametys:compositeMetadata');
if (paramsNode.hasProperty('ametys:url'))
{
var url = paramsNode.getProperty('ametys:url').getString();
entryNode.setProperty('ametys:url', url);
paramsNode.getProperty('ametys:url').remove();
}
if (paramsNode.hasProperty('ametys:length'))
{
var length = paramsNode.getProperty('ametys:length').getString();
entryNode.setProperty('ametys:length', length);
}
paramsNode.setProperty('ametys:link', '');
paramsNode.setProperty('ametys:link-title', '');
paramsNode.setProperty('ametys:nb-feed-max', '');
paramsNode.setProperty('ametys:nb-feed-user', '');
paramsNode.setProperty('ametys:cache', '3');
entryNode.setProperty('ametys:title', '');
entryNode.setProperty('ametys:limited', 'false');
entryNode.setProperty('ametys:fo-user', '');
entryNode.setProperty('ametys:fo-group', '');
entryNode.setProperty('ametys:cache', '3');
migrated++;
}
}
session.save();
println(migrated + ' service(s) have been migrated.');
Voir le code
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 node = nodes.next();
var paramsNode = node.getNode('ametys:service_parameters');
if (!paramsNode.hasNode('ametys:feeds'))
{
var feedsNode = paramsNode.addNode('ametys:feeds', 'ametys:compositeMetadata');
var entryNode = feedsNode.addNode('ametys:1', 'ametys:compositeMetadata');
if (paramsNode.hasProperty('ametys:url'))
{
var url = paramsNode.getProperty('ametys:url').getString();
entryNode.setProperty('ametys:url', url);
paramsNode.getProperty('ametys:url').remove();
}
if (paramsNode.hasProperty('ametys:length'))
{
var length = paramsNode.getProperty('ametys:length').getString();
entryNode.setProperty('ametys:length', length);
}
paramsNode.setProperty('ametys:link', '');
paramsNode.setProperty('ametys:link-title', '');
paramsNode.setProperty('ametys:nb-feed-max', '');
paramsNode.setProperty('ametys:nb-feed-user', '');
paramsNode.setProperty('ametys:cache', '3');
entryNode.setProperty('ametys:title', '');
entryNode.setProperty('ametys:limited', 'false');
entryNode.setProperty('ametys:fo-user', '');
entryNode.setProperty('ametys:fo-group', '');
entryNode.setProperty('ametys:cache', '3');
migrated++;
}
}
session.save();
println(migrated + ' service(s) have been migrated.');