Package utility facilitates the building of a user interface (UI) to execute XPath queries for information-related pages, assets, etc. The user gets an option: either view the result of the query on the same UI or build a CQ package of the result obtained from the query.
This approach has two key benefits:
- It can be used while syncing the environments
- Example: Suppose we have 100 pages in QA environment, 100 pages in production till date, and after a week, around 50 pages get created in QA. Now the environments are not in sync. We can fire a query in QA environment to fetch information about the pages created since last week, make a package of that result, and install in production. That will sync both environments.
- The UI allows authors to execute queries without having xpath knowledge.
1) Create an html form to input the parameters regarding query.
2) To handle the request, create a servlet, in which the input fields will be retrieved from a form and query description will be created as a map.
3) Use the Query Builder API to create the query and get results from it.
4) Use Package Manager API to create the package of the CQ query and download it from AEM package manager console.
User interface
Using the Query Builder tool
Select the Xtype from dropdown to search for like assets or pages.
- Select the name of the property from the dropdown. You can also provide a property which is not present in the dropdown by selecting ‘Other’. A text box will appear to enter the property.
- You can provide the value of the property and the date-range value for properties specific to date range.
- You can click on the ‘Show Results’ button to view the results of the query and for building a package click on Build Package button for package creation of the results generated.