Expand my Community achievements bar.

SOLVED

Extending ACS Commons Report Builder

Avatar

Level 4
Can we run a report created using ACS Commons Report Builder from a Java service? Requirement - Client wants to run a report every day to get all activities done on pages everyday (such as creation, modification, deletion, workflows, etc) automatically. So, we were thinking of configuring the report using the report builder and trigger it from the service and do the post processing based on client requirement. The advantage of this approach is that the client can modify the report easily and the changes will be reflected without dev involvement. Please let me know if there is a way to run the report or is there any better way. Thanks in advance!
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Ashwin_Raju ,

 

You can trigger the ACS AEM Commons Report Builder using the Event Service in AEM. You can achieve this by creating a custom event handler that listens for specific events and then initiates the report building process within the ACS Report Builder. 

Implementation Steps:

  1. Define the Triggering Event: Identify the event that will trigger the report generation. This could be a page activation, asset upload, or any other relevant event. 
  1. Create the Custom Event Handler:
    • Register an event listener to listen for the chosen event using the EventAdmin service. 
    • In the handleEvent method of your event handler, check if the event matches your criteria. 
    • If it matches, retrieve the report configuration (e.g., report name, parameters). 
    • Use the Report Builder API to execute the report. 
    • Optionally, you can download the generated report or trigger further actions. 

 

Hope it helps!

-Tarun

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi @Ashwin_Raju ,

 

You can trigger the ACS AEM Commons Report Builder using the Event Service in AEM. You can achieve this by creating a custom event handler that listens for specific events and then initiates the report building process within the ACS Report Builder. 

Implementation Steps:

  1. Define the Triggering Event: Identify the event that will trigger the report generation. This could be a page activation, asset upload, or any other relevant event. 
  1. Create the Custom Event Handler:
    • Register an event listener to listen for the chosen event using the EventAdmin service. 
    • In the handleEvent method of your event handler, check if the event matches your criteria. 
    • If it matches, retrieve the report configuration (e.g., report name, parameters). 
    • Use the Report Builder API to execute the report. 
    • Optionally, you can download the generated report or trigger further actions. 

 

Hope it helps!

-Tarun

Avatar

Level 9

Never tried but it should be achievable using the ReportExecutor API provided by ACS AEM Commons.

1. First, access the report configuration

Reports are stored under /var/acs-commons/reports. Retrieve the report configuration resource (e.g., /var/acs-commons/reports/my-report/config).

Resource reportConfig = resourceResolver.getResource("/var/acs-commons/reports/my-report/config")

2. Then initialise the report executor

Adapt the configuration resource to your ReportExecutor implementation. The executor type is defined in the report's reportExecutor property.

ReportExecutor executor = reportConfig.adaptTo(MyCustomReportExecutor.class);
executor.setConfiguration(reportConfig); // Apply config

3. Finally execute the report and retrieve results

Use the getAllResults() method to fetch results. Process them as needed (e.g., export to CSV, inject into services).

ResultsPage results = executor.getAllResults();
results.getResults().forEach(result -> {
    // Process each result (e.g., Resource, Node)
});


References:

 

Avatar

Administrator

@Ashwin_Raju Just checking in — were you able to resolve your issue?
We’d love to hear how things worked out. If the suggestions above helped, marking a response as correct can guide others with similar questions. And if you found another solution, feel free to share it — your insights could really benefit the community. Thanks again for being part of the conversation!



Kautuk Sahni