valtech / aem-easy-content-upgrade

AEM Easy Content Upgrade simplifies content migrations in AEM projects
Other
61 stars 27 forks source link

API request - 'executeWithInstallHookHistory' but for multiple scripts giving single history entry #238

Open krystian-panek-vmltech opened 1 month ago

krystian-panek-vmltech commented 1 month ago

Hi :)

This request is kinda continuation of https://github.com/valtech/aem-easy-content-upgrade/issues/172

consider following code being a part of ResourceChangeListener:

    private void executeScripts(List<String> scripts) {
        try {
            var history = aecu.createHistoryEntry();
            try {
                for (var groovyScriptPath : scripts) {
                    try {
                        var result = aecu.execute(groovyScriptPath);
                        //var result = aecu.executeWithInstallHookHistory(groovyScriptPath);
                        history = aecu.storeExecutionInHistory(history, result);
                    } catch (AecuException e) {
                        LOG.error("AECU script '%s' execution error '{}'", groovyScriptPath, e);
                    }
                }
            } finally {
                aecu.finishHistoryEntry(history);
            }
        } catch (AecuException e) {
            LOG.error("AECU scripts runner error", e);
        }
    }

since execute does not check hasBeenExecutedBefore and there is only executeWithInstallHookHistory which does that check, it's impossible (?) to group multiple scripts together to have single HistoryEntry and still idempotently execute scripts (on change, once, etc)

could we update AECU API to address this issue? I am asking because AECU history does not look nice when using executeWithInstallHookHistory in loop (all entries contain 0/1 scripts which looks quite messy)