Posts

Jenkins Job to clear dispatcher cache of single/multiple page(s)

Sometimes we receive requests to clear the dispatcher cache for a specific page. However, in most cases, we don't have the option to clear the cache for individual pages, so we end up clearing the entire dispatcher cache. This approach leads to heavy traffic on the production publisher instances and increased CPU utilization. To tackle this problem, I developed a dedicated Jenkins job that focuses on clearing the dispatcher cache for single or multiple pages. With this new job, we no longer have to clear the entire dispatcher cache whenever a request for page-specific cache clearing arises. This improvement brings about a significant reduction in traffic on the publishing instances and alleviates CPU utilization, especially when it's unnecessary to clear the entire dispatcher cache. Notes: 1) Enter the path as AEM full publisher/author path ending with .html as the location where the page will be stored in dispatcher 2) Multiple page paths can be entered in new lines 3) All mod...

AEM - Rollout a page programmatically and update references

 Out of the box RolloutManager provides below 3 methods by using that we can rollout the page programmatically. 1) void rollout(RolloutParams params) throws WCMException; 2) void rollout(ResourceResolver resolver, LiveRelationship relation, boolean reset) throws WCMException; 3) void rollout(ResourceResolver resolver, LiveRelationship relation, boolean reset, boolean autoSave) throws WCMException; But when using 2nd and 3rd method we are able to rollout the page but the link references are not getting updated to the corresponding locale. This is because we are not providing the rollout trigger in 2nd and 3rd methods, so referenceUpdate is not getting triggered.  In order to update the link references in the rollout page we need to use 1st method and pass/set the required details in RolloutParams class. Below is example code for setting the RolloutParams                               ...

AEM Results count using query builder

Image
 Using below query builder we can get the list of pages/assets count returned in json format Page Count: http://localhost:4502/bin/querybuilder.json?path=/content/we-retail&property=jcr:primaryType&property.1_value=cq:Page&p.limit=-1 Assets Count: http://localhost:4502/bin/querybuilder.json?path=/content/dam&property=jcr:mimeType&property.1_value=image/gif&property.1_value=image/png&property.2_value=image/jpeg&property.3_value=image/svg+xml&p.limit=-1

AEM trigger workflow from Java - Create translation project

Triggering workflow from Java and automate the process to create translation project using workflow. Code snippet  import com.day.cq.workflow.model.WorkflowModel;   import com.day.cq.workflow.WorkflowService;   @Reference private WorkflowService workflowService ; WorkflowSession wfSession = workflowService .getWorkflowSession( session ); // We can have any workflow model here - For creating language copy I am using create_language_copy workflow. String workflowName = "/var/workflow/models/wcm-translation/create_language_copy" ; / / Get the workflow model WorkflowModel wfModel = wfSession .getModel( workflowName );   String  languageEnMasterPath = "master page path"; // Get the workflow data // Workflow Data - Provide the master language page path from where the language copy to be created  WorkflowData wfData = wfSession .newWorkflowData( "JCR_PATH" , languageEnMasterPath ); // Add meta data values final Ma...

AEM integration with Akamai Fast Purge API for Single/multiple urls

Image
In AEM we can clear dispatcher cache on page activation by adding dispatcher flush agent but if we have Akamai on top of dispatcher as CDN then we need to manually clear Akamai Cache by going to akamai console. Akamai provides fast purge API and using that we can clear page cache using single URL, CPCode, multiple urls etc We can integrate Akamai Fast Purge API with replication agent so that for every page activation akamai cache gets cleared. To integrate with Akamai Fast Purge we need below details (Contact Akamai for details related to your account) 1) Access Token 2) Client Secret 3) Client Token 4) Akamai Host API End Points ( https://developer.akamai.com/api/core_features/fast_purge/v3.html ) Once above details are gathered you can refer below code for multiple urls cache clear Create a map with array list of urls  Map<String, List<String>> akamaiRequestMap = Maps.newHashMap(); ArrayList<String> arrayList = new ArrayList<>(); arrayList.add("Ad...

AEM Query Builder getting property values as json

Image
I got a requirement to list the pages which is having a property and also get the property value. Using query builder we can easily get the nodes having a specific property and there are lot of documentation, blogs which provides that but for retrieving the property value, I was in assumption that we need to write java logic where we can iterate through the nodes and then read property value. I searched a lot to find whether it can be do-abled using query builder, so that I can avoid writing java logic and finally with lot of research and trial and error I was able to read the property value using query builder. There might be documentation related to this and I was not able to find it and thought of documenting it. Ex: Run the below query using https://<host>:<port>/libs/cq/search/content/querydebug.html path:/content/we-retail/language-masters 1_property=jcr:title 1_property.operation : exists p.hits=selective p.nodedepth p.properties=jcr:path jcr:title p...
Image
Roll out option in AEM 6.4 Touch UI Tools AEM does not provide option to rollout pages from Touch UI version of siteadmin and recommending to use classic UI for rollout option which is present under tools dropdown By making below changes we can use roll-out option in Touch UI siteadmin 1) Overlay below path from /libs to /apps     /apps/wcm/core/content/sites/jcr:content/actions/selection 2) Add rollout node (nt:unstructured) under selection with values as shown below (Mostly I used open properties /libs/wcm/core/content/sites/jcr:content/actions/selection/open) 3) Add data node (nt:unstructured) under rollout node with values as shown below 4) Once above changes are done, we can see the rollout option in Touch UI siteadmin 5) I am opening the rollout page in new window so that authors can come back to previous window and make the changes