How to fetch /content/dam/ and further folder path in AEM | Community
Skip to main content
New Participant
Jul 27, 2023 10:28 AM UTC
Solved

How to fetch /content/dam/ and further folder path in AEM

 I am fetching userGroups associated with it.
now, i need to generate a hashmap containing :

Client Name vs ArrayList of User Groups

 

 
 
 
Session session = resourceResolver.adaptTo(Session.class);
 
 
 
 
 
 
 
 
 
 
 

Any help through this is welcome.
Thanks.
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
AsifChowdhury
AsifChowdhuryAccepted solution
New Participant
Jul 27, 2023 11:24 AM UTC

Hi @mahima16 

As you need to fetch all the folder path and as you said folder means multiple clients, assuming your client's folder will look like this:

So if we iterate the list of children for the path: "/content/dam/clients", we will get all its child folder paths within the given path.

 

5 replies

AsifChowdhury
New Participant
Jul 27, 2023 10:57 AM UTC

Hi @mahima16 

You can resolve the parent path using a resource resolver. Then with that resource, you can get its children, it will be an iterator, and by each of the children, you can get the path.

Here is the code snippet:

 

Resource resource = resourceResolver.getResource("/content/{path}"); Iterator<Resource> resourceIterator = resource.listChildren(); while (resourceIterator.hasNext()){ String path = resourceIterator.next().getPath(); }

 

NB: You need read permission for the user. and have to identify the folders conditionally.

Translate
Mahima16Author
New Participant
Jul 27, 2023 11:02 AM UTC

hi
suppose my folder path is something like:
/content/dam/folders

Translate
AsifChowdhury
AsifChowdhuryAccepted solution
New Participant
Jul 27, 2023 11:24 AM UTC

Hi @mahima16 

As you need to fetch all the folder path and as you said folder means multiple clients, assuming your client's folder will look like this:

So if we iterate the list of children for the path: "/content/dam/clients", we will get all its child folder paths within the given path.

 

Translate