Skip to content
Advertisement

Publish/Unpublish Adobe AEM page from Java

We have background process that automatically creates AEM pages as well as deletes old AEM pages. For pages to appear/disappear on the published site, they need to be activated (Published) / deactivated (Unpublished).

However, after searching from Google, I am not able to find AEM Java API that can publish/unpublish pages automatically.

Where can I find information on how to do this?

Advertisement

Answer

what you are looking for is the Replicator api. ReplicationActionType decides if you want to activate or deactivate.

replicator.replicate(session, ReplicationActionType.ACTIVATE,path);
replicator.replicate(session,ReplicationActionType.DEACTIVATE,path);

You can obtain Replicator instance using the @Reference annotation inside your OSGI service.

@Reference
Replicator replicator;
Advertisement