Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments

Using Replicator in AEM | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

Using Replicator in AEM by AEM Queries & Solutions

Abstract

This article covers the basic usage of replicator in AEM where we sometimes can’t replicate the bulk nodes in AEM or we want to create a replicator which can replicate a specific node in our AEM code.

I have created the object of the Replictor using Reference annotation in my Java servlet:

import com.day.cq.replication.Replicator;

import com.day.cq.replication.Replicator;

@Reference
Replicator replicator;

@Reference
private transient ResourceResolverFactory resourceResolverFactory;


Now get the resourceResolver from the service user and get the Session out of it.

Map<String, Object> serviceUserAuth= Collections.singletonMap(ResourceResolverFactory.SUBSERVICE,
"serviceUser");
ResourceResolver resourceResolver = resolverFactory.getServiceResourceResolver(serviceUserAuth);

Session session = resourceResolver.adaptTo(Session.class);


Once you get the session you can use the below code snippet to replicate the node that you have in your code:

replicator.replicate(session,ReplicationActionType.ACTIVATE,node.getPath());

Read Full Blog

Using Replicator in AEM

Q&A

Please use this thread to ask the related questions.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies