Menu

How to search the content only from the specified directory using AEM query builder?

Using the AEM query builder, will search a content which is available in specified directory only. This query will not search the content in sub directories, or not even child of the child directories. 

Open AEM Query Builder Debuggerhttp://localhost:4502/libs/cq/search/content/querydebug.html. Add the following options to perform the search.
path=/content/dam/we-retail/en/features

path.flat=true
type=dam:Asset
fulltext=cart

Filters definition:

  • path=? // On which path this query will perform the search operation.
  • path.flat=true // will look the content only in the specified directory.
  • fulltext=? //name or keyword which you are searching.

find-direct-children-in-aem-using-query-builder
find direct children using query builder

Query tree + URLs

ROOT=group: [
{fulltext=fulltext: fulltext=cart}
{path=path: path=/content/dam/we-retail/en/features, flat=true}
{type=type: type=dam:Asset}
]

XPath query to find the direct child in a directory

/jcr:root/content/dam/we-retail/en/features/element(*, dam:Asset)
[
(jcr:contains(., 'cart'))

]

JSON response 

You can get the JSON response of this query using this URL: (Note: update the domain(localhost:4502) to browse the url for your AEM instance)


Response:
{
  "success": true,
  "results": 1,
  "total": 1,
  "more": false,
  "offset": 0,
  "hits": [
    {
      "path": "/content/dam/we-retail/en/features/cart.png",
      "excerpt": "/content/dam/we-retail/en/features/cart.png",
      "name": "cart.png",
      "title": "cart.png",
      "lastModified": "2016-06-06 16:26:05"
    }
  ]
}

Configure and start remote debugger in Eclipse

Set the remote debugger configuration in Eclipse, to debug the running application code and identify the code issues.

Step 1: Open the Debug perspective from tool bar. if you don't see debug perspective option in your toolbar, then open the perspective from this path in Eclipse. 
Windows >> Perspective >> Open perspective >> Others >> Debug  
  1. Click on the perspective drop-down option very next to bug symbol.
  2. Select the option Debug configuration

Debug Configuration in Eclipse
Debug Configuration in Eclipse
Step 2: Debug Configuration will open a new window(below is the screenshot).
  1. Click on Remote Java Application option from left side rail.
  2. Click on the New Launch configuration(new configuration) button. As shown in the screenshot below.

Remote Java Application setup
Remote Java Application setup

Step 3: Once you click on new configuration button, a configuration setup option will appear right side on same window. Switch to connect tab, if you are not on the connect tab by default.
  1. In Name section, please provide a valid name.
  2. In Connection Properties section specify the host and port on which your application is running. 
    e.g. 
    Host: localhost
    Port: 30303 (default AEM debug mode port)
  3. Project: Select the core folder of your project.
  4. Connection type: Keep it as Standard.

Debugger remote connection setup
Debugger remote connection setup

Step 4: Now switch to source tab, next to connect and configure your Java project. Below is the screenshot.

  1. Switch to source tab
  2. Click on Add option
  3. Select Java Project option
  4. Hit Ok button
  5. Select your project 
  6. Hit Ok button
  7. After successful selection your project get added in the source section.  

Debug project setup in Eclipse
Debug project setup in Eclipse

You have successfully setup the debugger with your remote application. Now run or tune your application in debug mode and start the debugger in Eclipse from debug perspective to listen the request from your application server to Eclipse.

How to export the list of users from AEM?

To manage the user and security purpose, we always need the list of available and active users in our system for analysis. Adobe Experience Manager(AEM) also have an in build user management section to manage the AEM user and make the things secure. In this article we will export or generate the list of available user from AEM in an excel file. To perform this activity we will use the ACS commons. ACS commons provide so many powerful tools, which is easy to use and easily plug-able on AEM, by installing ACS commons package.

Prerequisite:

ACS commons should be installed in your AEM instance. If you don't have latest ACS commons installed in your AEM instance, then you can easily and free download the ACS package from here and install the package in your AEM instance using package manager.

Now we will perform the following steps to export the user list from AEM.

Step 1: Open the URL <domain>/miscadmin#/etc/acs-commons/exporters
If you are running on your local machine then; e.g. http://localhost:4502/miscadmin#/etc/acs-commons/exporters

Go to Tools >> acs-commons >> Exporters from left side rail. Below is the screenshot of steps.

  1. Click on the Exporter folder
  2. Click on New >> New Page
  3. Create a page with any title using the default selected template(User to CSV Exporter).
  4. Click on create button.
This will create a new page under the exporter directory. Open the newly created page by double clicking on that page name.

Export users and groups list in AEM
Export User list in AEM

Step 2: Your Page will now look like this(below screenshot). From here you may add or remove the user profile properties, which you want to export and get appended in your exported CSV file.

Add Custom Property will let you add user properties (Relative path from the [rep:User] node). if you don't know the path and property name then you may refer the CRXDE-Lite to get the exact path and property name.(Below is the screenshot)
Custom user properties- user list export
Custom user properties

Screenshot to get the property name from crx/de. e.g designation, familyName
Screenshot to get the property name from crx/de. e.g designation, familyName
User profile section in CRXDE

Step 3:
Now Select the group membership the way which you want to export. Using 
Only Include Users by Group Membership option.

  1. Direct Membership : Only the direct member of groups.
  2. Indirect Membership: Only Indirect member of groups, means a group which is member of another group.
  3. Direct and Indirect Membership: Both direct and indirect membership.
Only Include Users by Group Membership option
Only Include Users by Group Membership option

Step 4: Now select all those groups whose members and user you want to export using Filter by Group option.(Select none for all groups). 
Download User CSV Report in AEM
Download User CSV Report
Step 5: After selecting the all groups click on the Download User CSV Report button to download the csv file.

You may also save the configuration for later use using the save configuration button.


References: