April 27, 2020
Estimated Post Reading Time ~

Approach to implement content preview environment in AEM

By default Adobe Experience Manager(AEM) not provides the preview instance to preview the content before publishing to live environment but most of the cases preview is required before publishing the content to live environment.

This post explain the approach to preview and approve the content before publishing to live environment.

The below diagram explains the preview flow



Author creates the content in production author and start the workflow
Workflow sends the content to Stage author and Publishers
Workflow assign the task to approver group and send the notification email
Approver reviews the content in stage environment and approve or reject the content (workflow)t - provides the detailed information for rejection
if the content is approved
Workflow sends the approved content to production publishers.
If the content is rejected
Workflow assign the task to author and sends the notification
Author review the details and completes the workflow
Start the process again by correcting the content

Define Replication process step with ECMA script:
Create ecma file replicate.ecma under /etc/workflow/scripts/<<application>> e.g. /etc/workflow/scripts/blog - This ecma script helps to replicate the content to stage environments

var workflowData = workItem.getWorkflowData();
var path = workflowData.getPayload().toString();
var session = workflowSession.getSession();

var replicator = sling.getService(Packages.com.day.cq.replication.Replicator);
var options = new Packages.com.day.cq.replication.ReplicationOptions();

for(var i=0;i<args.length;i++) {
var agent= args[i];
var filter = new Packages.com.day.cq.replication.AgentIdFilter(agent);
options.setFilter(filter);
options.setSuppressStatusUpdate(true);
try {
replicator.replicate(session, Packages.com.day.cq.replication.ReplicationActionType.ACTIVATE, path, options);
} catch(e) {
log.error("Cannot replicate page : " + path +"on publisher. (agentId: " + agent + "): " + e);
}
}




Define approver group:
Create a user group in production author- workflow-approver and add the required users to the group





Define Replication agents:
Define replication agents for Staging author and staging publishers in production author, Check only the checkbox associated with "ignore default"



Define workflow model:
Create new workflow model in production author- Content Review



Add a process step, select the ecma script defined in the previous step - /etc/workflow/scripts/blog/remlication.ecma as process
Select Handler Advance
Provide the staging replication agents as the argument - e.g. stage-author,stage-publisher1,stage-publisher2



Add a Participation Step and select the approver group defined
Select checkbox associated with Email



Add OR split with two branches
Add Activate Page/Asset step in the first branch



Add Dynamic Participant Step in the second branch and select Workflow Initiator Participant Chooser (Script)
Select checkbox associated with Email



Save the final workflow



Create the content and initiate the workflow for the content path in production author- Content Author





The content is published to stage author and publisher.
The workflow item is assigned to the workflow-approver group and email is send to the group.



Login to workflow inbox(production) with the user id who is part of workflow-approver group
Approve or Reject the content - Select the corresponding Next Step "Activate Page/Asset" or "Reject workflow step"





If the content is approved, the approved content is activated/published to production publisher(via default publisher agents)
If the content is rejected, the workflow item is assigned to the workflow initiator(author) and email is send.


Login to workflow inbox(production) with the author user id, complete the workflow. Correct the content based on the comment provided by approver and restart the process.



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.