how to publish a page programmatically in cq5
Solved! Go to Solution.
Hi.
It is possible form a servlet to get hold of a replicator by using the @Reference annotation.
(more info about that here http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/replication/Replicator.html)
To get hold of a replicator you can use the following code:
@Reference private Replicator replicator;
Then you can use the following code to replicate a page to a publish instance:
String path = "PATH OF THE RESOURCE HERE"; Session session = //Get the session fro eg. a the request try { replicator.replicate(session, "ACTIVATE", path); } catch(ReplicationException replicationException) { //Handle the replication exception }
The same goes for any deactivation of a resource.
Hope that will help you.
/Johan
Views
Replies
Total Likes
You can use the replicator service for this:
http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/replication/Replicator.html
Views
Replies
Total Likes
Hi.
It is possible form a servlet to get hold of a replicator by using the @Reference annotation.
(more info about that here http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/replication/Replicator.html)
To get hold of a replicator you can use the following code:
@Reference private Replicator replicator;
Then you can use the following code to replicate a page to a publish instance:
String path = "PATH OF THE RESOURCE HERE"; Session session = //Get the session fro eg. a the request try { replicator.replicate(session, "ACTIVATE", path); } catch(ReplicationException replicationException) { //Handle the replication exception }
The same goes for any deactivation of a resource.
Hope that will help you.
/Johan
Views
Replies
Total Likes
I would like to just add the below point with Johan
You can use ReplicationActionType to get the different events like ACTIVATE, DEACTIVATE, DELETE, REVERSE (for reverse replicate)
replicator.replicate(session, ReplicationActionType.ACTIVATE, path);
~Loki
Views
Likes
Replies