Get the users from AEM group
Hi All,
Appreciate your comments here.
Use case: get the users from aem group then send the mails..
This code is written in aem custom workflow.
Working fine : when click on asset and initiate custom workflow . I am getting group and able to get users.
Not working case : when adding asset to folder and using luncher/event handler initiate the custom workflow. In this case below group is coming null
JackrabbitSession jrSession=(JackrabbitSession) session;
UserManager userManager=jrSession.getUserManager();
Group group = (Group) userManager.getAuthorizable("GroupId");
log.info("group >>> "+group);
final Iterator<Authorizable> memberslist = group.getMembers();
while (memberslist.hasNext()) {
final Authorizable user = memberslist.next();
if (user != null && !user.isGroup() && user.getProperty("./profile/email") != null) {
//EMAIL ADDRESS FOR MEMBERS
Value[] usrEmail = user.getProperty("./profile/email");
for(Value emailGroup : usrEmail) {
log.info("emailGroup line 152>>> "+emailGroup);
}
}
}