How to fetch /content/dam/ and further folder path in AEM | Community
Skip to main content
July 27, 2023
Solved

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

  • July 27, 2023
  • 1 reply
  • 1860 views

 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.
Best answer by AsifChowdhury

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.

 

1 reply

AsifChowdhury
Community Advisor
Community Advisor
July 27, 2023

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.

Mahima16Author
July 27, 2023

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

AsifChowdhury
Community Advisor
AsifChowdhuryCommunity AdvisorAccepted solution
Community Advisor
July 27, 2023

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.