Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-10290

[Demo] All templates: Initilialize migration components

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.3.0
    • Fix Version/s: 4.3.0
    • Component/s: None
    • Labels:
      None
    • Sprint:
      4.3 RC1

      Description

      On all templates data :

      • Remove the custom_nodetypes.xml (maybe you don't save it by default)
      • Run this script in the CMS admin script tool:
        var logger = Ametys.getLogger("migration.manual4jcr"); 
        
        logger.info("Begin of the manual initialization for automatic JCR Data component's migration"); 
        
        logger.info("Components preparation"); 
        const JcrDataVersion = Java.type("org.ametys.plugins.repository.migration.jcr.data.JcrDataVersion"); 
        const _migrationEP = Ametys.serviceManager.lookup("org.ametys.core.migration.MigrationExtensionPoint"); 
        const _versionsRootHelper = Ametys.serviceManager.lookup("org.ametys.plugins.repository.migration.jcr.data.VersionsRootHelper"); 
        const _versionHandlerEP = Ametys.serviceManager.lookup("org.ametys.core.migration.handler.VersionHandlerExtensionPoint"); 
        const _jcrVersionHandler = _versionHandlerEP.getExtension("jcr-data"); 
        
        logger.info("Iterate on migration components"); 
        _migrationEP.getExtensionsIds().forEach( 
            extensionId => 
            { 
                logger.info("Component " + extensionId); 
                var extension = _migrationEP.getExtension(extensionId); 
                var versionConfigurations = extension.getConfiguration().getChild("versions").getChildren("version"); 
                for (var versionConfiguration of versionConfigurations) 
                { 
                    if (versionConfiguration.getAttribute("type") == "jcr-data") 
                    { 
                        logger.info("Version jcr-data found"); 
                        try 
                        { 
                            _jcrVersionHandler.getCurrentVersions(extensionId, versionConfiguration, "jcr-data"); 
                            // Migration is not failing 
                        } 
                        catch (e) 
                        { 
                            logger.info("Needed migration"); 
                            // Migration is failing 
                            var version = new JcrDataVersion("jcr-data", extensionId); 
                            version.setVersionNumber("0"); 
                            version.setComment("Manual initialization."); 
                            _jcrVersionHandler.addVersion(version); 
                        } 
                    } 
                } 
            } 
        ); 
        
        logger.info("Update of known plugins"); 
        _versionsRootHelper.updateKnownPlugins(); 
        
        logger.info("End of the manual initialization for automatic JCR Data component's migration"); 
      • Run this script in the CMS admin script tool and the site admin script tool:
        var logger = Ametys.getLogger("migration.manual4sql"); 
        
        logger.info("Begin of the manual initialization for automatic SQL component's migration"); 
        
        logger.info("Components preparation"); 
        const _migrationEP = Ametys.serviceManager.lookup("org.ametys.core.migration.MigrationExtensionPoint"); 
        const _versionHandlerEP = Ametys.serviceManager.lookup("org.ametys.core.migration.handler.VersionHandlerExtensionPoint"); 
        const _sqlVersionHandler = _versionHandlerEP.getExtension("sql"); 
        
        logger.info("Iterate on migration components"); 
        _migrationEP.getExtensionsIds().forEach( 
            extensionId => 
            { 
                logger.info("Component " + extensionId); 
                var extension = _migrationEP.getExtension(extensionId); 
                var versionConfigurations = extension.getConfiguration().getChild("versions").getChildren("version"); 
                for (var versionConfiguration of versionConfigurations) 
                { 
                    if (versionConfiguration.getAttribute("type") == "sql") 
                    { 
                        logger.info("Version sql found"); 
                        try 
                        { 
                            var versionsObj = _sqlVersionHandler.getCurrentVersions(extensionId, versionConfiguration, "sql"); 
                            for (var version of versionsObj) 
                            { 
                                if (version.getVersionNumber() == null) 
                                { 
                                    logger.info("Needed migration"); 
                                    // Migration is failing 
                                    version.setVersionNumber("0"); 
                                    version.setComment("Manual initialization."); 
                                    _sqlVersionHandler.addVersion(version); 
                                } 
                            } 
                        } 
                        catch (e) 
                        { 
                            logger.error("Error during manual migration", e); 
                        } 
                    } 
                } 
            } 
        );
        
        logger.info("End of the manual initialization for automatic SQL component's migration"); 

        Attachments

          Activity

            People

            • Assignee:
              laurence Laurence Aumeunier
              Reporter:
              bmaurel Bérénice Maurel
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: