本文整理汇总了Java中org.apache.jackrabbit.api.security.user.Group.getMembers方法的典型用法代码示例。如果您正苦于以下问题:Java Group.getMembers方法的具体用法?Java Group.getMembers怎么用?Java Group.getMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jackrabbit.api.security.user.Group
的用法示例。
在下文中一共展示了Group.getMembers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkCyclicRelations
import org.apache.jackrabbit.api.security.user.Group; //导入方法依赖的package包/类
/**
* Adding group to another group may result in cyclic relation. Let current group be the group where we
* want to add current authorizable to. If current authorizable contains group such that current group
* belongs to, then we prevent such operation.
*
* @param currentGroup The group where we want to add current authorizable
* @param groupToBeAdded Authorizable we want to add
* @throws ActionExecutionException Throw exception, if adding operation results in cyclic relation
*/
public static void checkCyclicRelations(Group currentGroup, Group groupToBeAdded)
throws ActionExecutionException {
try {
if (groupToBeAdded.getID().equals(currentGroup.getID())) {
throw new ActionExecutionException(MessagingUtils.addingGroupToItself(currentGroup.getID()));
}
Iterator<Group> parents = currentGroup.memberOf();
while (parents.hasNext()) {
Group currentParent = parents.next();
// Is added group among my parents?
if (currentParent.getID().equals(groupToBeAdded.getID())) {
throw new ActionExecutionException(MessagingUtils.cyclicRelationsForbidden(
currentGroup.getID(), groupToBeAdded.getID()));
}
// ... and are its children among my parents?
for (Iterator<Authorizable> children = groupToBeAdded.getMembers(); children.hasNext(); ) {
Authorizable currentChild = children.next();
if (currentParent.getID().equals(currentChild.getID())) {
throw new ActionExecutionException(MessagingUtils.cyclicRelationsForbidden(
currentChild.getID(), groupToBeAdded.getID()));
}
}
}
} catch (RepositoryException e) {
throw new ActionExecutionException(MessagingUtils.createMessage(e));
}
}
示例2: checkMembers
import org.apache.jackrabbit.api.security.user.Group; //导入方法依赖的package包/类
private void checkMembers(Group grp, Set<String> ms) throws RepositoryException {
Set<String> members = new HashSet<String>(ms);
Iterator<Authorizable> iter = grp.getMembers();
while (iter.hasNext()) {
Authorizable member = iter.next();
Assert.assertTrue("Group must have member", members.remove(member.getID()));
}
assertEquals("Group must have all members", 0, members.size());
}
示例3: groupJson
import org.apache.jackrabbit.api.security.user.Group; //导入方法依赖的package包/类
protected JsonNode groupJson(Session session, final Group g)
throws RepositoryException {
final JsonBuilder jb = new JsonBuilder();
final UserDAO dao = new UserDAO(session, jcrom);
List<User> members = newArrayList();
Iterator<Authorizable> iter = g.getMembers();
while (iter.hasNext()) {
final String jackrabbitUserId = iter.next().getID();
final User user = dao.findByJackrabbitID(jackrabbitUserId);
if (user != null) {
members.add(user);
}
}
return jb.toJson(g, members);
}
示例4: getEmailAddrsFromUserPath
import org.apache.jackrabbit.api.security.user.Group; //导入方法依赖的package包/类
/**
* Gets email(s) based on the path to a principal If the path is a user it
* returns an array with a single email if the path is a group returns an
* array emails for each individual in the group
*
* @param resourceResolver
* @param principlePath
* path to a CQ user or group
* @return String[] of email(s) associated with account
*/
@SuppressWarnings({"squid:S3776"})
protected static final String[] getEmailAddrsFromUserPath(ResourceResolver resourceResolver, String principlePath) {
List<String> emailList = new LinkedList<String>();
try {
Resource authRes = resourceResolver.getResource(principlePath);
if (authRes != null) {
Authorizable authorizable = authRes.adaptTo(Authorizable.class);
if (authorizable != null) {
// check if it is a group
if (authorizable.isGroup()) {
Group authGroup = authRes.adaptTo(Group.class);
// iterate over members of the group and add emails
Iterator<Authorizable> memberIt = authGroup.getMembers();
while (memberIt.hasNext()) {
String currEmail = getAuthorizableEmail(memberIt.next());
if (currEmail != null) {
emailList.add(currEmail);
}
}
} else {
// otherwise is an individual user
String authEmail = getAuthorizableEmail(authorizable);
if (authEmail != null) {
emailList.add(authEmail);
}
}
}
}
} catch (RepositoryException e) {
log.warn("Could not get list of email(s) for users. {}", e);
}
String[] emailReturn = new String[emailList.size()];
return emailList.toArray(emailReturn);
}