How to publish an asset/page programmatically in AEMaaCS? | Community
Skip to main content
Mario248
Level 7
November 10, 2022
Solved

How to publish an asset/page programmatically in AEMaaCS?

  • November 10, 2022
  • 1 reply
  • 3685 views

Team - In the past, we used Replicator (com.day.cq.replication.Replicator) to activate pages programmatically. Currently, I'm trying to publish assets and pages in a custom workflow in AEMaacS. 

 

AEMaaCS does not use the replication agents used in previous versions of AEM. As I understand it, content in AEM Cloud Service is replicated using Sling Content Distribution to a pipeline service that is not part of AEM.

 

Could you please tell me what APIs should be used to call appropriate distributions to publish a specific asset?

 
 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by salamswapnil

@mario248 

In AEM Cloud as well you can use Replicator API to activate resources. In cloud you don't need to provide any replication agent via ReplicationOptions. Replicator API picks the only active agent in AEM cloud which is "publish" agent.

So below code should work as its working for me in my workflow process.

@Reference
private Replicator replicator;
replicator.replicate(session, ReplicationActionType.ACTIVATE, assetPath);

1 reply

salamswapnilCommunity AdvisorAccepted solution
Community Advisor
November 10, 2022

@mario248 

In AEM Cloud as well you can use Replicator API to activate resources. In cloud you don't need to provide any replication agent via ReplicationOptions. Replicator API picks the only active agent in AEM cloud which is "publish" agent.

So below code should work as its working for me in my workflow process.

@Reference
private Replicator replicator;
replicator.replicate(session, ReplicationActionType.ACTIVATE, assetPath);
Mario248
Mario248Author
Level 7
November 10, 2022

Thanks but I want to call specific distribution service. I have 3 distributions or agents, those are preview, publish and Publish to brand portal. In this case i want to publish only Publish to brand portal agent. Is it possible ?

Community Advisor
November 10, 2022

Yes, you can call specific distribution service like this.

@Reference
private Replicator replicator; ReplicationOptions options = new ReplicationOptions(); options.setFilter(new AgentFilter() { @Override public boolean isIncluded (Agent agent) { return agent.getId().equals(DISTRIBITION_SERVICE_NAME); //PUBLISH or PREVIEW or any other distribution service you have } }); replicator.replicate(session,ReplicationActionType.ACTIVATE, assetPath, options);