Upgrade manual to v1.11.0


Dans vos fichiers modèles associés à chaque gabarit de newsletter qui se trouvent dans skins/<nom de la skin>/newsletter/<nom du gabarit NL>/models/model.xml , procéder aux modifications suivantes :

  • Replace ametys_src with data-ametys -src
  • Replace ametys_type with data-ametys -type

 

Go to script to migrate your newsletter content:

importClass(java.io.ByteArrayInputStream);
importClass(org.apache.commons.io.IOUtils);

session.refresh(true);

var qm = session.getWorkspace().getQueryManager();

var query = qm.createQuery("//element(*, ametys:content)[@ametys-internal:contentType='org.ametys.plugins.newsletter.Content.newsletter']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var i = 0;

while (nodes.hasNext())
{
	var node = nodes.nextNode();
	
	if (node.hasNode("ametys:content"))
	{
		var bis = null;
		var stream = null;
		try
		{
			var contentNode = node.getNode("ametys:content");
			stream = contentNode.getProperty("jcr:data").getBinary().getStream();
			var contentString = IOUtils.toString(stream, "UTF-8");
			contentString = contentString.replaceAll("ametys_", "data-ametys-");
			
			bis = new ByteArrayInputStream(contentString.getBytes("UTF-8"));
			var binary = contentNode.getSession().getValueFactory().createBinary(bis);
			contentNode.setProperty("jcr:data", binary);
			contentNode.save();
			if (contentNode.hasProperty("ametys-internal:currentStepId") && contentNode.getProperty("ametys-internal:currentStepId").getLong() == 3)
			{
				contentNode.checkin();
				contentNode.checkout();
				
				var versionName = contentNode.getBaseVersion().getName();
				contentNode.getVersionHistory().addVersionLabel(versionName, "Live", true);
			}
	        
            println(node.getIdentifier());
			i++;
		}
		finally
		{
			if (bis != null)
			{
				bis.close();
			}
			if (stream != null)
			{
				stream.close();
			}
		}
	}
}

session.save();

println(i + " contenus corrigés.");
Back to top

Newsletter