Un bug lié à la modification via Microsoft Office des documents directement depuis les espaces projet cause une perte de données lors de la reconstruction du live.
Le bug a été corrigé, mais une migration est obligatoire pour sauvegarder les données qui peuvent être plus récentes dans le live que dans default :
Oups !
La copie dans le presse papier a échouée. Ouvrez le code et copier-le manuellement.
var xpathQuery = "//ametys:plugins/workspaces//element(*, ametys:resource)";
var credentials = new javax.jcr.SimpleCredentials('ametys', []);
var liveSession = repository.login(credentials, 'live');
var qmLive = liveSession.getWorkspace().getQueryManager();
var qmDefault = session.getWorkspace().getQueryManager();
var queryLive = qmLive.createQuery(xpathQuery, javax.jcr.query.Query.XPATH);
var nodes = queryLive.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var node = nodes.nextNode();
if (node.hasNode("jcr:content"))
{
var contentNodeLive = node.getNode("jcr:content");
var id = contentNodeLive.getIdentifier();
try
{
var contentNodeDefault = session.getNodeByIdentifier(id);
if (contentNodeLive.getProperty("jcr:lastModified").getDate().compareTo(contentNodeDefault.getProperty("jcr:lastModified").getDate()) > 0)
{
if (contentNodeLive.isLocked() || contentNodeDefault.isLocked())
{
print("Content locked : " + id);
}
else
{
count++;
var binary = contentNodeLive.getProperty("jcr:data");
contentNodeDefault.setProperty("jcr:data", binary.getValue());
contentNodeDefault.setProperty("jcr:lastModified", contentNodeLive.getProperty("jcr:lastModified").getValue());
session.save();
}
}
}
catch (e)
{
print("Erreur while migrating content : " + id);
}
}
}
print("Number of contents migrated : " + count)
var xpathQuery = "//ametys:plugins/workspaces//element(*, ametys:resource)";
var credentials = new javax.jcr.SimpleCredentials('ametys', []);
var liveSession = repository.login(credentials, 'live');
var qmLive = liveSession.getWorkspace().getQueryManager();
var qmDefault = session.getWorkspace().getQueryManager();
var queryLive = qmLive.createQuery(xpathQuery, javax.jcr.query.Query.XPATH);
var nodes = queryLive.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var node = nodes.nextNode();
if (node.hasNode("jcr:content"))
{
var contentNodeLive = node.getNode("jcr:content");
var id = contentNodeLive.getIdentifier();
try
{
var contentNodeDefault = session.getNodeByIdentifier(id);
if (contentNodeLive.getProperty("jcr:lastModified").getDate().compareTo(contentNodeDefault.getProperty("jcr:lastModified").getDate()) > 0)
{
if (contentNodeLive.isLocked() || contentNodeDefault.isLocked())
{
print("Content locked : " + id);
}
else
{
count++;
var binary = contentNodeLive.getProperty("jcr:data");
contentNodeDefault.setProperty("jcr:data", binary.getValue());
contentNodeDefault.setProperty("jcr:lastModified", contentNodeLive.getProperty("jcr:lastModified").getValue());
session.save();
}
}
}
catch (e)
{
print("Erreur while migrating content : " + id);
}
}
}
print("Number of contents migrated : " + count)
var xpathQuery = "//ametys:plugins/workspaces//element(*, ametys:resource)";
var credentials = new javax.jcr.SimpleCredentials('ametys', []);
var liveSession = repository.login(credentials, 'live');
var qmLive = liveSession.getWorkspace().getQueryManager();
var qmDefault = session.getWorkspace().getQueryManager();
var queryLive = qmLive.createQuery(xpathQuery, javax.jcr.query.Query.XPATH);
var nodes = queryLive.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var node = nodes.nextNode();
if (node.hasNode("jcr:content"))
{
var contentNodeLive = node.getNode("jcr:content");
var id = contentNodeLive.getIdentifier();
try
{
var contentNodeDefault = session.getNodeByIdentifier(id);
if (contentNodeLive.getProperty("jcr:lastModified").getDate().compareTo(contentNodeDefault.getProperty("jcr:lastModified").getDate()) > 0)
{
if (contentNodeLive.isLocked() || contentNodeDefault.isLocked())
{
print("Content locked : " + id);
}
else
{
count++;
var binary = contentNodeLive.getProperty("jcr:data");
contentNodeDefault.setProperty("jcr:data", binary.getValue());
contentNodeDefault.setProperty("jcr:lastModified", contentNodeLive.getProperty("jcr:lastModified").getValue());
session.save();
}
}
}
catch (e)
{
print("Erreur while migrating content : " + id);
}
}
}
print("Number of contents migrated : " + count)