Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Invalidate JSON service cache on webpage activation.


Level 2
I have JSON service exposed to other system from AEM ex: https:domainname/content/portal/services/apidata.getMenuData.json
This is achieved as below. 
The data which needs to shared in JSON is configured in webpage  say "/content/portal/menuconfig.html" via dialogue.
There is service component with "getMenuData.json.jsp" to read data from "/content/portal/menuconfig.html"
getMenuData.json.jsp code looks as below :


getMenuData.json.jsp :
               String xPathQuery = "/jcr:root/content/portal/menuconfig/jcr:content/body/menuconfigurarions";
                    Session session = resourceResolver.adaptTo(Session.class); 
                    QueryManager qm = session.getWorkspace().getQueryManager();
                    Query q = qm.createQuery(xPathQuery, "xpath");
                    QueryResult result = q.execute();
                    NodeIterator nIt = result.getNodes();
                    Property prop = null;
                        while(nIt.hasNext()) {
                            Node node = nIt.nextNode(); 
							 //read the dialogue value and convert to array and assign to output object 
                            if(node.getName().equals("menuconfigurarions") && node.hasProperty("items")) {  
							 prop = node.getProperty("items");
							   MenuList = prop.getValues();
                             outputString = menuconfigurarionsArray.toString();    
							..... } else { ...} }.....


   Once page is edited and activated then flush agent invalidating https:domainname/content/portal/menuconfig.html but https:domainname/content/portal/services/apidata.getMenuData.json is not getting invalidated. How to achieve JSON path invalidation on dispatcher when activating "menuconfig.html" webpage.
2 Replies


Community Advisor

@kyasam if the page path is not matching with your content service path, you need write ACS commons Generic rules..



@kyasam Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni