AEM 6420 - Sync Specific Folders to Scene7 in AEM Dynamic Media Scene7 (DMS7)

Goal


By default, the Scene7 step of DAM Update Asset workflow syncs all assets uploaded to AEM, to Scene 7, in DMS7 mode (sling run mode dynamicmedia_scene7)

If the requirement is syncing specific folders, this post explains how-to, by adjusting the DAM Update Asset Workflow

For AEM 65 check this post

Another way of do this is by removing Scene7 step from default DAM Update Asset workflow, creating a DAM update workflow with Scene7 step having workflow launcher path condition set to e.g. /content/dam/my_dm_sync_folder(/.*/)renditions/original (where my_dm_sync_folder is the folder in AEM with assets synced to Scene7)

Demo | Package Install | Github


Solution


1) Edit the DAM Update Asset workflow to add an OR Split step, move the Scene7 step to branch 1 and add a No Operation step in branch 2



2) Add the following script in branch 1 tab of OR Split; add the folder paths in SYNC_PATHS variable, which should be kept in sync with Scene7 (so the images and videos uploaded to these folders ONLY are synced to Scene7)

function check() {
    var SYNC_PATHS = new Packages.java.util.ArrayList();

    //add the paths you'd like to sync to scene7
    SYNC_PATHS.add("/content/dam/sreek");

    var doSync = false;

    try {
        var path = workflowData.getPayload().toString();

        if (path === null) {
            return doSync;
        }

        path = path.replaceAll("/jcr:content/renditions/original", "");

        log.info("Checking if asset should be uploaded to Scene7 - " + path);

        var payloadNode = workflowSession.getSession().getNode(path);

        if (payloadNode === null) {
            return doSync;
        }

        doSync = SYNC_PATHS.contains(payloadNode.getParent().getPath());

        if (doSync === false) {
            log.info("Skipping upload to Scene7 - " + path);
        } else {
            log.info("Uploading to Scene7 - " + path);
        }
    } catch (e) {
        doSync = false;
        log.error(e);
    }

    return doSync;
}




3) For the branch 2 tab (no operation) add the following script

function check(){
      return true;
}


4) Sync the workflow to copy the model from /conf/global/settings/workflow/models/dam/update_asset to /var/workflow/models/dam/update_asset

5) A bug in 64 SP2 causes the workflow nodes to get reversed as below during workflow sync (fixed in later versions), so workaround it in /var/workflow/models/dam/update_asset by changing the node xml and pushing to CRX

                           Before:


                           After:



6) Upload an asset to folder with Scene7 sync allowed, you can see the jcr:content/metadata@dam:scene7ID  in asset metadata, confirming the upload to Scene7



7) Assets in folders that are skipped by OR-split do not have  jcr:content/metadata@dam:scene7ID  in asset metadata and are not uploaded to Scene7




No comments:

Post a Comment