Returns an <code>Iterator</code> over the <code>Collection</code> of <code>IEntities</code>
that are members of this <code>IEntityGroup</code>.

@return java.util.Iterator
@param group org.apereo.portal.groups.IEntityGroup
969867
@Override
    public java.util.Iterator findEntitiesForGroup(IEntityGroup group) throws GroupsException {
        if (log.isDebugEnabled())
            log.debug(
                    DEBUG_CLASS_NAME
                            + ".findEntitiesForGroup(): retrieving entities for group "
                            + group);

        Collection entities = null;
        File f = getFile(group);
        if (f.isDirectory()) {
            entities = Collections.EMPTY_LIST;
        } else {
            entities = getEntitiesFromFile(f);
        }

        return entities.iterator();
    }
38958
private String getGroupKey() {
        EntityIdentifier[] groups = null;
        try {
            groups =
                    GroupService.searchForGroups(
                            groupName, IGroupConstants.SearchMethod.DISCRETE, IPerson.class);
        } catch (GroupsException e1) {
            throw new RuntimeException(
                    "An exception occurred searching for " + "the group " + groupName + ".", e1);
        }
        if (groups == null || groups.length == 0)
            throw new RuntimeException(
                    "Group with name '"
                            + groupName
                            + "' not found for "
                            + this.getClass().getName()
                            + ". All evaluations will return false.");

        return groups[0].getKey();
    }
1176364
public OvhGroup identity_group_group_GET(String group) throws IOException {
		String qPath = "/me/identity/group/{group}";
		StringBuilder sb = path(qPath, group);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhGroup.class);
	}
744246
@Override
    public boolean contains(IEntityGroup group, IGroupMember member) throws GroupsException {
        return (member.isGroup())
                ? containsGroup(group, (IEntityGroup) member)
                : containsEntity(group, member);
    }
54986
public static Iterator iterator(final Matcher matcher) {
        matcher.reset();
        return new Iterator() {
            private boolean found /* = false */;
            private boolean done /* = false */;

            public boolean hasNext() {
                if (done) {
                    return false;
                }
                if (!found) {
                    found = matcher.find();
                    if (!found) {
                        done = true;
                    }
                }
                return found;
            }

            public Object next() {
                if (!found) {
                    if (!hasNext()) {
                        throw new NoSuchElementException();
                    }
                }
                found = false;

                if (hasGroup(matcher)) {
                    // are we using groups?
                    // yes, so return the specified group as list
                    List<String> list = new ArrayList<String>(matcher.groupCount());
                    for (int i = 0; i <= matcher.groupCount(); i++) {
                       list.add(matcher.group(i));
                    }
                    return list;
                } else {
                    // not using groups, so return the nth
                    // occurrence of the pattern
                    return matcher.group();
                 }
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
661838
public static synchronized IEntityGroupStore getGroupStore() {
        if (groupStore == null) {
            groupStore = new GrouperEntityGroupStore();
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("returning IEntityGroupStore: " + groupStore);
        }
        return groupStore;
    }
458406
private IEntityGroup igetDistinguishedGroup(String name) throws GroupsException {
        try {
            String key = getDistinguishedGroupKey(name);
            return compositeGroupService.findGroup(key);
        } catch (Exception ex) {
            throw new GroupsException(
                    "GroupService.getDistinguishedGroup(): " + "could not find key for: " + name,
                    ex);
        }
    }
500366
@Override
    public boolean contains(IEntityGroup group, IGroupMember member) throws GroupsException {
        boolean found = false;
        Iterator itr = (member.isGroup()) ? findMemberGroups(group) : findEntitiesForGroup(group);
        while (itr.hasNext() && !found) {
            found = member.equals(itr.next());
        }
        return found;
    }
123400
@Override
    public IEntityStore newEntityStore() throws GroupsException {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Creating new Grouper GrouperEntityGroupStoreFactory");
        }
        return (IEntityStore) new GrouperEntityGroupStoreFactory().newGroupStore();
    }
974945
public static Iterable<BoxGroup.Info> getAllGroups(final BoxAPIConnection api, String ... fields) {
        final QueryStringBuilder builder = new QueryStringBuilder();
        if (fields.length > 0) {
            builder.appendParam("fields", fields);
        }
        return new Iterable<BoxGroup.Info>() {
            public Iterator<BoxGroup.Info> iterator() {
                URL url = GROUPS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString());
                return new BoxGroupIterator(api, url);
            }
        };
    }
217482
@Override
    public IGroupMember getGroupMember(String key, Class type) throws GroupsException {
        IGroupMember gm = null;
        if (type == ICompositeGroupService.GROUP_ENTITY_TYPE) gm = findGroup(key);
        else gm = getEntity(key, type);
        return gm;
    }
677556
@Override
    public ILockableEntityGroup findGroupWithLock(String key, String lockOwner)
            throws GroupsException {
        CompositeEntityIdentifier ent = newCompositeEntityIdentifier(key);
        IIndividualGroupService service = getComponentService(ent);
        return (service == null) ? null : service.findGroupWithLock(ent.getLocalKey(), lockOwner);
    }
1189642
public GroupChain getGroupChainFor(final Collection<Class<?>> groups) {
    if (groups == null || groups.isEmpty()) {
      throw new IllegalArgumentException("At least one group has to be specified.");
    }

    groups.forEach(clazz -> {
      if (!validationGroupsMetadata.containsGroup(clazz)
          && !validationGroupsMetadata.isSeqeuence(clazz)) {
        throw new ValidationException("The class " + clazz + " is not a valid group or sequence.");
      }
    });

    final GroupChain chain = new GroupChain();
    groups.forEach(clazz -> {
      if (isGroupSequence(clazz)) {
        insertSequence(clazz, chain);
      } else {
        final Group group = new Group(clazz);
        chain.insertGroup(group);
        insertInheritedGroups(clazz, chain);
      }
    });

    return chain;
  }
491596
@Override
    @SuppressWarnings("unchecked")
    public Iterator findParentGroups(IGroupMember gm) throws GroupsException {

        final List<IEntityGroup> parents = new LinkedList<IEntityGroup>();

        GcGetGroups getGroups = new GcGetGroups();

        String uportalStem = getStemPrefix();

        // if only searching in a specific stem
        if (!StringUtils.isBlank(uportalStem)) {
            getGroups.assignStemScope(StemScope.ALL_IN_SUBTREE);
            getGroups.assignWsStemLookup(new WsStemLookup(uportalStem, null));
        }

        String key = null;
        String subjectSourceId = null;
        if (gm.isGroup()) {

            key = ((IEntityGroup) gm).getLocalKey();

            if (!validKey(key)) {
                return parents.iterator();
            }
            subjectSourceId = "g:gsa";
        } else {

            // Determine the key to use for this entity. If the entity is a
            // group, we should use the group's local key (excluding the
            // "grouper." portion of the full key. If the entity is not a
            // group type, just use the key.
            key = gm.getKey();
        }
        getGroups.addSubjectLookup(new WsSubjectLookup(null, subjectSourceId, key));

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Searching Grouper for parent groups of the entity with key: " + key);
        }

        try {

            WsGetGroupsResults results = getGroups.execute();

            if (results == null
                    || results.getResults() == null
                    || results.getResults().length != 1) {
                LOGGER.debug("Grouper service returned no matches for key " + key);
                return parents.iterator();
            }
            WsGetGroupsResult wsg = results.getResults()[0];
            if (wsg.getWsGroups() != null) {
                for (WsGroup g : wsg.getWsGroups()) {
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.trace("Retrieved group: " + g.getName());
                    }
                    IEntityGroup parent = createUportalGroupFromGrouperGroup(g);
                    parents.add(parent);
                }
            }

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(
                        "Retrieved " + parents.size() + " parent groups of entity with key " + key);
            }

        } catch (Exception e) {
            LOGGER.warn(
                    "Exception while attempting to retrieve "
                            + "parents for entity with key "
                            + key
                            + " from Grouper web services: "
                            + e.getMessage());
            return Collections.<IEntityGroup>emptyList().iterator();
        }

        return parents.iterator();
    }
795937
@Override
    public Iterator findEntitiesForGroup(IEntityGroup group) throws GroupsException {

        if (isTreeRefreshRequired()) {
            refreshTree();
        }

        log.debug("Invoking findEntitiesForGroup() for group:  {}", group.getLocalKey());

        // We only deal w/ group-group relationships here...
        // return findMemberGroups(group);

        List<IEntity> rslt = new ArrayList<IEntity>();
        if (displayPersonMembers) {
            List<String> list = groupsTree.getPersonChildren().get(group.getLocalKey());
            if (list != null) {
                // should only reach this code if its a SmartLdap managed group...
                for (String s : list) {
                    rslt.add(persons.get(s));
                }
            }
        }
        return rslt.iterator();
    }
475522
@Override
    public Iterator findParentGroups(IGroupMember gm) throws GroupsException {
        Collection allGroups = new ArrayList();

        for (IIndividualGroupService service :
                (Collection<IIndividualGroupService>) getComponentServices().values()) {
            if (!gm.isGroup()
                    || service.isEditable()
                    || getComponentService(((IEntityGroup) gm).getServiceName()) == service) {
                {
                    for (Iterator groups = service.findParentGroups(gm); groups.hasNext(); ) {
                        allGroups.add((IEntityGroup) groups.next());
                    }
                }
            }
        }
        return allGroups.iterator();
    }
329362
protected Iterator findParentGroups(IEntity ent) throws GroupsException {
        if (log.isDebugEnabled()) log.debug(DEBUG_CLASS_NAME + ".findParentGroups(): for " + ent);

        List groups = new ArrayList();
        File root = getFileRoot(ent.getType());
        if (root != null) {
            File[] files = getAllFilesBelow(root);

            try {
                for (int i = 0; i < files.length; i++) {
                    Collection ids = getEntityIdsFromFile(files[i]);
                    if (ids.contains(ent.getKey())) {
                        groups.add(find(files[i]));
                    }
                }
            } catch (IOException ex) {
                throw new GroupsException("Problem reading group files", ex);
            }
        }

        return groups.iterator();
    }