user3736872
user3736872

Reputation: 121

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?

Upvotes: 3

Views: 5276

Answers (3)

user20090062
user20090062

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

Sharath Madappa
Sharath Madappa

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

Nono Junang
Nono Junang

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

Related Questions