Reputation: 121
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?
Upvotes: 3
Views: 5276
Reputation: 1
https://aem.redquark.org/2018/10/day-19-replication-api-in-action.html
Please refer this reference looks to be good and moreover if you want to deactivate you can use
replicator.replicate(session, ReplicationActionType.DEACTIVATE, path);
log.info("Replicated:---- {}", path);
Upvotes: -1
Reputation: 3402
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;
Upvotes: 10
Reputation: 37
Have you thought about running the same background process on the publisher instead of activating/deactivating the pages? I mean in case for some reasons your process fails during activation/deactivation you need to handle it and make sure that your publishers are still in a consistent state.
Upvotes: 0