Technical migration manual from version 2.4.x to version 2.5.x


  1. Training copy (since 09/02/2016)
  2. Modification of virtual page identifiers (since 10/02/2016)
  3. Auto-completion on the training and UE search engine
  4. Re-indexing ofODF

Training copy (since 09/02/2016)

Starting with 2.5.0, a course can be duplicated.

This requires an update to the WEB-INF/params/workflow-program.xmlfile, adding the initial workflow action with identifier 111:

<initial-actions>
	<action id="111" name="plugin.odf:WORKFLOW_ACTION_CREATE_BY_COPY">
            <results>
                <unconditional-result old-status=" " status=" " step="0" />
            </results>
    </action>
</initial-action>

 

Modification of virtual page identifiers (since 10/02/2016)

The following script is necessary if you have rich texts that may contain links to ODF pages (training, courses, ELP).

Attention
The following script can only be run once! Make a backup of the repository BEFORE running script.
Then go to script for the first time, leaving the instruction session.save() commented. Check that this seems correct before replaying the script with uncommentary comments. session.save()

Script update links in rich texts

var qm = session.getWorkspace().getQueryManager();
// récupération de tous les textes riches existants
var query = qm.createQuery("//element(*, ametys:richText)[@jcr:data]", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var nodeCount = 0;
var liveCount = 0;
while (nodes.hasNext())
{
    var node = nodes.next();
   
   
   
    try
    {
   
    // contenu du texte riche
    var is = node.getProperty("jcr:data").getStream();
   
    var builder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
    var doc = builder.parse(is);
    is.close();
     
    var needUpdate = false;
   
    // parcours des liens contenus dans le texte riche
    var links = org.apache.xpath.XPathAPI.selectNodeList(doc, "//link[@type='page']", doc.getDocumentElement());
    for (var i = 0; i < links.getLength(); i++)
    {   
        var linkNeedUpdate = false;
       
        var link = links.item(i);
        var href = link.getAttributes().getNamedItem("xlink:href").getNodeValue();
       
        // traitement des liens vers une formation, parcours ou ELP
        if (href.indexOf("program://") == 0)
        {
            // les anciennes url sont de la forme program://art-lettres-langue-ALL/master-lmd-XB/master-design-program-fruai3182988bprh7agzrd6?rootId=page://xxxx&programId=subProgram://yyyy
            // ou program://art-lettres-langue-ALL/master-lmd-XB?rootId=page://xxx&programId=program://yyy
            var index = href.indexOf('?');
            var oldPath = href.substring("program://".length, index);
            // println(node.getUUID() + " - "+ href);
             
            var pathSegment = oldPath.split("/");
             
            var newPath;
            if (pathSegment.length == 2)
            {
                newPath = "_root";
                linkNeedUpdate = true;
            }
            else if (pathSegment.length > 2)
            {
                linkNeedUpdate = true;
                newPath = org.apache.commons.lang.StringUtils.join(pathSegment, '/', 2, pathSegment.length);
            }
           
            if (linkNeedUpdate)
            {
                // calcul du nouveau lien
                // les nouvelles url sont de la forme program://master-design-program-fruai3182988bprh7agzrd6?rootId=page://xxxx&programId=subProgram://yyyy
                // ou program://_root?rootId=page://xxx&programId=program://yyy
                var newHref = "program://" + newPath + href.substring(index);
                println(href + " \n=>\n " + newHref + "'");
                println("");
                link.getAttributes().getNamedItem("xlink:href").setNodeValue(newHref);   
                needUpdate = true;
            }
        }
        else if (href.indexOf("course://") == 0 && href.indexOf("&programId=") == -1)
        {
            var index = href.indexOf('?');
            var oldPath = href.substring("course://".length, index);
             
            var pathSegment = oldPath.split("/");
             
            var newPath;
            if (pathSegment.length > 2)
            {
                // les anciennes url sont de la forme course://art-lettres-langue-ALL/master-lmd-XB/master-design-program-fruai3182988bprh7agzrd6?rootId=xxx&courseId=yyy
                newPath = org.apache.commons.lang.StringUtils.join(pathSegment, '/', 2, pathSegment.length);
       
                // course://licence-professionnelle-design-program-fruai3182988bprh7agzrd6?rootId=...
                var programName = pathSegment[2].substring (pathSegment[2].indexOf('program-'));
                 
                query = qm.createQuery("//" + programName, javax.jcr.query.Query.XPATH);
                nodes = query.execute().getNodes();
                var program = nodes.hasNext() ? nodes.next() : null;
               
                // calcul du nouveau lien
                // les nouvelles url sont de la forme course://master-design-program-fruai3182988bprh7agzrd6?rootId=xxx&courseId=yyy&programId=zzz
                var newHref = "course://" + newPath + href.substring(index);
                if (program != null)
                {
                    newHref += "&programId=program://" + program.getId();
                }
                println(href + " \n=>\n " + newHref + "'");
                println("");
               
                link.getAttributes().getNamedItem("xlink:href").setNodeValue(newHref);   
                needUpdate = true;
            }
        }
        
    }
   
    if (needUpdate)
    {
        // mise à jour du contenu du texte riche avec les liens modifiés
        var os = new java.io.ByteArrayOutputStream();
        var result = new javax.xml.transform.stream.StreamResult(os);
        var source = new javax.xml.transform.dom.DOMSource(doc);
       
        var transformer = javax.xml.transform.TransformerFactory.newInstance().newTransformer();
         
        var format = new java.util.Properties();
        format.put(javax.xml.transform.OutputKeys.METHOD, "xml");
        //format.put(javax.xml.transform.OutputKeys.INDENT, "yes");
        format.put(javax.xml.transform.OutputKeys.ENCODING, "UTF-8");
        //format.put(OutputPropertiesFactory.S_KEY_INDENT_AMOUNT, "2");
        transformer.setOutputProperties(format);
 
        transformer.transform(source, result);
   
        var is = new java.io.ByteArrayInputStream(os.toByteArray());
        node.setProperty("jcr:data", is);
   
        is.close();
       
        nodeCount++;
        println("\n"+node.getUUID()+"\n");
        var content = node.getParent();
        
        // TO UNCOMMENT WHEN READY
        //content.save();
        
        if (content.hasProperty("ametys-internal:currentStepId") && content.getProperty("ametys-internal:currentStepId").getLong() == 3)
        {
        	//TO UNCOMMENT WHEN READY
        	//content.checkin();
        	//content.checkout();
			
			var versionName = content.getBaseVersion().getName();
			content.getVersionHistory().addVersionLabel(versionName, "Live", true);
			liveCount++;
		}        
    }
  
   }
catch (e) { println("ERROR: "+node.getPath());}
}
 
// TO UNCOMMENT WHEN READY
// session.save();
println (nodeCount + " rich text(s) were processed");
println (liveCount + " live rich text(s) were processed");

Auto-completion on the training and UE search engine

Adding auto-completion to the "keywords" search field requires content to be re-indexed.

Setting up auto-completion also requires a graphical migration Manual for graphical migration from version 2.4.x to version 2.5.x

 

Re-indexing ofODF

Following the correction of certain issues (in particular ODF-1163), it is necessary to restart the construction of the complete live system.

 

 

 

 

Back to top