Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Custom Rollout Config for Rollout and Publish not working

Avatar

Level 1

Hi,

I have a requirement to create a custom rollout config that performs rollout (adjust some properties) and publish.

I am using AEM 6.5.

 

I was able to successfully roll out the pages but unable to replicate them. Reference Replicator is always throwing null pointer exception

 

Please find the sample code below.

public class CustomLiveAction implements LiveAction {

private static final Logger LOG = LoggerFactory.getLogger(CustomLiveAction.class);
protected final String name;

publicCustomLiveAction(final String name) {
this.name = name;
}

@Override
public String getName() {
return name;
}

@Reference
private Replicator replicator;

@Override
public void execute(final Resource source, final Resource target, final LiveRelationship relation,
final boolean autoSave, final boolean isResetRollout) throws WCMException {
if (source != null && target != null) {
//code to replicate
replicator.replicate(..);

}
}

 

 

  1. How to get the reference of the replicator in live-action?
  2. What are the other options to replicate the pages after rolling out? 
  3. is it a best practice to publish language-masters and use Activate on blueprint activation trigger?
  4. is it a best practice to roll out and publish under the same operation?

 

 

 
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-msm...

the above documentation has full details.

 

or , please see below

 

Did you declare your class as @component?

The following should work with the component

 

/** The replicator. */
private Replicator replicator;
    
 
/**
* Replicate resource to Publish instance.
*
* @Param session the session
*            
* @Param resourcePath the resource path
*            
*/
public void replicate(Session session, String resourcePath) {
try {
            // Set Replication Options
ReplicationOptions options = setReplicateOptions();
replicator.replicate(session, ReplicationActionType.ACTIVATE, resourcePath, options);
LOGGER.debug("Replicated resource at path : {} ", resourcePath);
} catch (ReplicationException repositoryException) {
LOGGER.error("repositoryException occurred while replicating the path::{}, exception{}", resourcePath,
repositoryException);
}
}
 
/**
* Sets the replicate options.
*
* @Return the replication options
*/
private ReplicationOptions setReplicateOptions() {
ReplicationOptions options = new ReplicationOptions();
options.setSuppressVersions(true);
options.setSynchronous(true);
options.setSuppressStatusUpdate(false);
return options;
}

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-msm...

the above documentation has full details.

 

or , please see below

 

Did you declare your class as @component?

The following should work with the component

 

/** The replicator. */
private Replicator replicator;
    
 
/**
* Replicate resource to Publish instance.
*
* @Param session the session
*            
* @Param resourcePath the resource path
*            
*/
public void replicate(Session session, String resourcePath) {
try {
            // Set Replication Options
ReplicationOptions options = setReplicateOptions();
replicator.replicate(session, ReplicationActionType.ACTIVATE, resourcePath, options);
LOGGER.debug("Replicated resource at path : {} ", resourcePath);
} catch (ReplicationException repositoryException) {
LOGGER.error("repositoryException occurred while replicating the path::{}, exception{}", resourcePath,
repositoryException);
}
}
 
/**
* Sets the replicate options.
*
* @Return the replication options
*/
private ReplicationOptions setReplicateOptions() {
ReplicationOptions options = new ReplicationOptions();
options.setSuppressVersions(true);
options.setSynchronous(true);
options.setSuppressStatusUpdate(false);
return options;
}