pretty new to Java dev as well as adobe CQ dev and I'm a bit stumped at the moment. I am attempting to return a formatted table of all users and the groups they are associated to using the UserManager.
Everything appears to be setup and working correctly, however, I receive an error when it reaches my while loop to iterate through the Iterator returned by the Authorizable.memberOf() method. When it reaches the Next() method it returns an error stating "The method Next() is undefined for the type Iterator". Not sure what to do at this point. Any help would be appreciated. The specific code section in question is below.
while(paths.hasNext()) {
Node node = paths.nextNode();
String UID = node.getProperty("jcr:uuid").getString();
String usrName = node.getProperty("rep:principalName").getString();
Authorizable usr = usrMgr.getAuthorizable(UID);
Iterator<Group> itrGrp = usr.memberOf();
String grpList = "";
while(itrGrp.hasNext()) {
Group grp = itrGrp.Next();
Value[] grpVal = grp.getProperty("rep:principalName");
String[] grpArr = Arrays.copyOf(grpVal, grpVal.length, String[].class);
int arrLen = grpArr.Length;
If (arrLen > 1) {
for(int i=0; i<arrLen; i++){
grpList = grpList + grpArr[i] + "<br/>";
}
}else{
grpList = grpList + grpArr[0];
}
}
out.println("<tr><td>" + usrName + "</td><td>" +grpList + "</td></tr>");
}
Also, here are all my imported interfaces in case it's applicable:
java.util.Iterator,
javax.jcr.query.Query,
javax.jcr.NodeIterator,
javax.jcr.Node,
javax.jcr.PropertyIterator,
javax.jcr.Property,
javax.jcr.Value,
javax.jcr.SimpleCredentials,
javax.jcr.RepositoryFactory,
javax.jcr.Repository,
javax.jcr.Session,
org.apache.jackrabbit.api.JackrabbitSession,
org.apache.jackrabbit.api.security.user.UserManager,
org.apache.jackrabbit.api.security.user.Authorizable,
org.apache.jackrabbit.api.security.user.Group
Please let me know if anything doesn't make sense or if I didn't include enough info. Any help would be greatly appreciated.
Thanks.
You should use the method next()
instead of Next()
(note the lower case 'n')