I need to hit a servlet whenever the author publishes any content on AEM. I need to do it at the end of the publish workflow such that the servlet is hit only after all the approval processes are complete and AEM finally replicates the content to the publish instance.
I need to do it for all ways of publishing content in AEM. Some of the most common ways are shown below (using AEM 6.5)
We have tried adding our own replication agent under "Agents on author" as shown below:
Pointed the agent to our custom servlet and the servlet is being hit but there seems to be absolutely no way to determine the page path from where the author has initiated publish. We require the page path inside the servlet too.
Therefore the only way seems to be through Jquery where on clicking the publish button an ajax call is made to the servlet and we are able to capture the current page path this way. This approach is incorrect since the ajax call is independent of the inbuilt AEM publish workflow and the servlet will be called even if the page publish is rejected by any approvers in the workflow.
The correct way would be to call the servlet at the end of the default AEM replication/activation/publish workflow but we also need the path of the page which was published/activated which seems impossible. Is there any way to call our servlet during the default AEM activation flow?
Solved! Go to Solution.
Views
Replies
Total Likes
So what are trying to achieve? I understand it in a way, that you want to get the path of the page which is being published, is this correct? I ask because you mention at one point, that you need to extract the page the author is currently on. And while that might be the same in some cases, it's not required at all.
Then the next question: At which point do you need to your code to run? Before the replication is initiated? When the replication has completed? When the payload has reached all publishs?
Hi @AEM_Dev_Newbie!
I see two approaches to your requirement:
As you already mentioned, IMO it would not be an appropriate approach to handle this on the front end (jquery or similar).
Hope that helps!
[1] https://experienceleague.adobe.com/docs/experience-manager-65/deploying/configuring/replication.html
Views
Replies
Total Likes
So what are trying to achieve? I understand it in a way, that you want to get the path of the page which is being published, is this correct? I ask because you mention at one point, that you need to extract the page the author is currently on. And while that might be the same in some cases, it's not required at all.
Then the next question: At which point do you need to your code to run? Before the replication is initiated? When the replication has completed? When the payload has reached all publishs?
Views
Replies
Total Likes
Do you plan to fetch this data directly from author, and will the index job crawl this from publish?
I would implement it this way:
In that case the workflow payload is either the page, where it is invoked on, or a workflow package (a set of pages). In the first case you can get the payload path directly, while in the second case you need to use the ResourceCollectionManager service to list the content of a workflow package. See https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/main/java/com/ad...for an example how it can be done.
Views
Replies
Total Likes
you can write a custom replication event listener and call your index api from eventlister. e.g.
https://github.com/arunpatidar02/aem63app-repo/blob/master/java/ReplicationListener.java
Views
Likes
Replies
Views
Likes
Replies