Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

AEM as CS | Handle event on page publish

Avatar

Level 4

Hello Team,

How do we handle page activation custom event on AEM as CS ?. Like we were handling in version <= 6.5 sling event.

We are trying to do something on publishing/activating the page with event handler using EventConstants.EVENT_TOPIC + "=" + ReplicationAction.EVENT_TOPIC which works fine in local but not on Cloud.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

The replication mechanism itself is implemented differently in CS and SDK, but the event after having received an incoming replication should be identical.

View solution in original post

3 Replies

Avatar

Community Advisor

@pradeepmoolemane Below code worked for us

 

@Component(immediate = true, property = { "event.topics=org/apache/sling/distribution/importer/package/imported",
"event.filter=(|(distribution.type=ADD)(distribution.type=DELETE))" })
public class SlingDistributionEventHandler implements EventHandler {
public static final String DISTRIBUTION_PATHS = "distribution.paths";

@Override
public void handleEvent(Event event) {
if (event.getProperty(DISTRIBUTION_PATHS) != null) {
String[] pagePath = (String[]) event.getProperty(DISTRIBUTION_PATHS);

}
}

Avatar

Correct answer by
Employee Advisor

The replication mechanism itself is implemented differently in CS and SDK, but the event after having received an incoming replication should be identical.