Posts

Selective Replication: Bulk Content Replication Made Easier

, ,

Selective Replication tool, which is one of the tools in the ADX Tools package, simplifies bulk activation, deactivation and delete operations for AEM users.

Selective Replication Tool augments AEM Activation Tree with some useful additional features. AEM Activation Tree is a replication console to activate the entire tree in one action. Selective Replication tool adds to the utilities of bulk activation, deactivation and delete operations. The task gets even simpler when there is an option to selectively choose the root paths to replicate, with an added advantage of selecting the replication agents. To further apply the feature of selectivity, users have the option to include or exclude child node or DAM assets.

Purpose:

To perform bulk activation, deactivation or delete operations on a path-task list uploaded via Excel with the ability to select relevant replication agents.

Implementation:

  1. The simplest part of the tool is its input, which is uploading an Excel file containing the path-task list. A sample excel file can be downloaded using the ‘Sample’ button present in the description.
selectivecreplication

ADX Tools in AEM: Selective Replication

Excel file contains the following fields:

  • Path – root path for operation
  • Include Children – option to include child nodes of content or not
  • Include DAM Assets – option to include DAM assets of content or not
  • Action Type – defining the type of action (Activate, Deactivate, Delete)2. The tool gives an option to select multiple replication agents from the available list.

 

  1. We can get detailed replication logs with the option to export it as an Excel file or pdf.

  1. Users also get the option to see the history of the operations performed by clicking on the history icon present on the top right corner of the tool along with the tool guide.

 

Each of the individual logs can be viewed by clicking on the respective Logs icon. This action will retrieve the history of that particular operation.

 

Key Highlights of the tool:

  • Option to selectively choose the root paths for replication
  • The advantage of choosing relevant replication agents
  • Simple path-task list input via Excel
  • Include or exclude child nodes/DAM assets
  • Detailed replication logs of each root path
  • History of replication actions performed via this tool

 

The video demonstration of the tool can be viewed at:

Related Blogs:

We at Argil DX are dedicated to improving your AEM experience and usability. Get in touch with us to know more about our services and AEM expertise.

To download the ADX Tools package submit a request and we will deliver the package on your email within 15 work days.

 

Triggering a Workflow using Event Listeners in AEM

,

AEM Version: 6.2
Target Audience: AEM Developers

Introduction

In AEM 6.2 Workflows, we can trigger a workflow when a DAM Asset is created, modified, or deleted within a given path. In this article, we will explore triggering workflows from our code based on events in the JCR.

Suppose you have a workflow that creates custom renditions of assets in addition to the default AEM renditions, when the asset is under “/content/dam/ProjectName/images/”. You would have set up two launchers for triggering this workflow: one with event type as “Node Create” and one with “Node Modified”. We can also achieve the same functionality through our code, without touching the GUI.

Requirement

When assets are moved into a certain folder structure in DAM, trigger a workflow that creates a 100px X 100px thumbnail of our image.

No-rendition-outside-imgs

Fig 1: Before Moving the asset, no custom thumbnail. Fig 2: Desired result after moving the asset, the new thumbnail.

Analysis

The intuitive thought is that when an asset is moved, a new node is created in the new location and the old one is deleted. However, experience shows that AEM does not create a new node in the destination folder on Node Move. We know this because the ‘jcr:Created’ property does not change. AEM does not even change the last modified date.

Creation Timestamp Before Moving the Asset Creation Timestamp is the same after moving

Fig 3: Creation Timestamp Before Moving the Asset. Fig 4: Creation Timestamp is the same after moving

Modification Timestamp Before Moving the Asset. Modification Timestamp is the same after moving

Fig 5: Modification Timestamp Before Moving the Asset. Fig 6: Modification Timestamp is the same after moving.

What if we copy the asset?

On copying the asset, a new version of the same is created. This triggers the Node Creation launcher.

No versions before copying the asset Version created after copy-pasting the asset

Fig. 7: No versions before copying the asset. Fig. 8: Version created after copy-pasting the asset.

Approach

Event Listeners

AEM supports observation, which enables us to receive notifications of persistent changes to the workspace. A persisted change to the workspace is represented by a set of one or more events. Each event reports a single simple change to the structure of the persistent workspace in terms of an item added, changed, moved or removed. There are thus 7 possible events at the JCR level, viz:

  1. Node Added
  2. Node Moved
  3. Node Modified
  4. Node Removed
  5. Property Added
  6. Property Removed
  7. Property Changed

We connect with the observation mechanism by registering an event listener with the workspace. An event listener is a class implementing the EventListener interface, that responds to the stream of events to which it has been subscribed. An event listener is added to a workspace with:

(A detailed explanation of each parameter is given with the code example in the package as well as the at the end of this article) As defined by the EventListener interface, listener must provide an implementation of the onEvent method:

When an event occurs that falls within the scope of the listener, the repository calls the onEvent method invoking our logic which processes/responds to the event. In our case, we will register an event listener to listen for “Node Moved” events under “/content/dam/images” so that when an asset is moved to that folder, our workflow can be triggered.

Implementation

When the component is activated, the activate(…) method is called. It contains a call to ObservationManager.addEventListener(…) for registering the event listener. The deactivate(…) method contains logic for deregistering the event listener, and is triggered when the bundle is being stopped.

When the relevant event occurs, the onEvent(…) method is called, which contains logic for processing the event. In our case, we trigger a workflow.

The following is the relevant code from ThumbnailNodeMovedListener.java:

Download this code (including the workflow):

Build it using

N.B: Creating a workflow is not part of this tutorial, and therefore a ready workflow has been provided in the code package. However, if you want to learn to create workflows, here is an excellent resource: ->

/workflow-in-aem/

References

Adobe Consulting Services. (2018, March 20). acs-aem-samples/SampleJcrEventListener.java at master · Adobe-Consulting-Services/acs-aem-samples. Retrieved from Github: https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/adobe/acs/samples/events/impl/SampleJcrEventListener.java

Day Software AG. (2018, March 20). JCR 2.0: 12 Observation (Content Repository for Java Technology API v2.0). Retrieved from Adobe Docs: https://docs.adobe.com/docs/en/spec/jcr/2.0/12_Observation.html