Expand my Community achievements bar.

Publish/replication to Preview events/agents

Avatar

Level 4

Hi again, 
Would like to ask if there would be a function in replication preprocessor that could check/return a value if the current page/resource is being published to Preview or Publish environment?  

2 Replies

Avatar

Community Advisor

Hi @LyonMartin,

I think you can try to get the information which agent is used, base on agent Id that can be retrieved from ReplicationAction object. So in preprocessor implementation it should be possible like this:

public void preprocess(ReplicationAction replicationAction, ReplicationOptions replicationOptions) throws ReplicationException {
    String agentId = replicationAction.getConfig().getAgentId();
}

In general in cloud setup you have agent with publish id that represents publish tier, and preview id for preview publish. Both are mentioned in the official documentation:

Avatar

Level 4

so, when I tried to test the snippet, config seems null even on the replicationAction itself. 
LyonMartin_0-1729504026723.png

therefore I got a null pointer when calling the "agentId()"


And on the side note: can we also setup a Publish to preview on local AEM?
Thanks!