AEM: replicate to a specific publisher

I've added the possibility to replicate to a single publisher under the already existing /etc/replication/treeactivation.html. The user can select an agent or keep the default (replicate to all publishers).


There is not that much code to show, I'll just summarize the most important parts.


Map<String, Agent> agents = agentMgr.getAgents();
List<String> agentIdsList = new ArrayList<>();
for(Map.Entry<String, Agent> entry: agents.entrySet()){
	Agent agent = entry.getValue();
	<td><label for="agent">Agent:</label></td>
		<select id="agent" name="agent">
			<option selected="all">All</option>
var select = document.getElementById("agent");
<% for (int i=0; i< agentIdsList.size(); i++) { %>
	var option = document.createElement("option");
	var id = "<%= xssAPI.encodeForJSString(agentIdsList.get(i)) %>";
	option.text = id;
	option.value = id;
<% } %>


ReplicationOptions opts = null;
if (!agentId.equalsIgnoreCase("all")) {
	opts = new ReplicationOptions();
	opts.setFilter(new AgentFilter() {
		public boolean isIncluded(final Agent agent) {
			return agentId.equals(agent.getId());
replicator.replicate(session, ReplicationActionType.ACTIVATE, array, opts);

You can find the full code here:

If you do have any questions, do not hesitate to contact me or leave a comment below.