/* (non-Javadoc)
@see org.apereo.portal.groups.IEntityGroupStore#findParentGroups(org.apereo.portal.groups.IGroupMember)
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();
    }
47758
private Collection<Membership> findMembershipsByGroup(Session session, Group group) throws Exception
   {
      Node groupNode;
      NodeIterator refUsers;
      try
      {
         groupNode = utils.getGroupNode(session, group);
         refUsers = groupNode.getNode(JCROrganizationServiceImpl.JOS_MEMBERSHIP).getNodes();
      }
      catch (PathNotFoundException e)
      {
         return new ArrayList<Membership>();
      }

      List<Membership> memberships = new ArrayList<Membership>();
      while (refUsers.hasNext())
      {
         Node refUserNode = refUsers.nextNode();
         memberships.addAll(findMembershipsByUserAndGroup(session, refUserNode, groupNode));
      }

      return memberships;
   }
1135379
public TypeElement findParent(TypeElement typeElement, Set<TypeElement> parents) {
    TypeMirror type;
    while (true) {
      type = typeElement.getSuperclass();
      if (type.getKind() == TypeKind.NONE) {
        return null;
      }
      typeElement = (TypeElement) ((DeclaredType) type).asElement();
      if (containsTypeMirror(parents, type)) {
        return typeElement;
      }
    }
  }
655341
public com.google.api.ads.adwords.axis.v201809.cm.Location[] getParentLocations() {
        return parentLocations;
    }
856865
public Collection<Logger> getParentLoggers() {
		LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
		List<Logger> loggers = new ArrayList<>(ctx.getLoggers());
		Map<String, Logger> parentMap = new HashMap<>();
		try {
			for (Logger logger : loggers) {
				if (null != logger.getParent() && parentMap.get(logger.getParent().getName()) == null) {
					parentMap.put(logger.getParent().getName(), logger.getParent());
				}
			}
			List<Logger> parents = new ArrayList<>(parentMap.values());
			Collections.sort(parents, LOGGER_COMP);
			return parents;
		} finally {
			loggers.clear();
			parentMap.clear();
		}
	}
185600
@Override
    public List<Object> findParentEntityFromJoinTable(EntityMetadata parentMetadata, String joinTableName,
            String joinColumnName, String inverseJoinColumnName, Object childId)
    {
        throw new PersistenceException("Not applicable for HBase");
    }
610340
@Override
    public Set<IGroupMember> getChildren() throws GroupsException {

        final EntityIdentifier cacheKey = getUnderlyingEntityIdentifier();
        Element element = childrenCache.get(cacheKey);

        if (element == null) {
            final Set<IGroupMember> children = buildChildrenSet();
            element = new Element(cacheKey, children);
            childrenCache.put(element);
        }

        @SuppressWarnings("unchecked")
        final Set<IGroupMember> rslt = (Set<IGroupMember>) element.getObjectValue();
        return rslt;
    }
1078638
private function FindParentGroup()
    {
        $parentGroup = null;
        if ($this->parent)
        {
            $parentGroup = GroupFinder::FindPageGroup($this->parent);
        }
        if (!$parentGroup)
        {
            $parentGroup = $this->site->GetUserGroup();
        }
        return $parentGroup;
    }
234813
protected JRDesignGroup getParent(JRDesignGroup group) {
        int index = realGroups.indexOf(group);
        return (index > 0) ? (JRDesignGroup) realGroups.get(index - 1) : group;
    }
100498
private Collection<Group> findGroups(Session session, Group parent, boolean recursive) throws Exception
   {
      List<Group> groups = new ArrayList<Group>();
      String parentId = parent == null ? "" : parent.getId();

      NodeIterator childNodes = utils.getGroupNode(session, parentId).getNodes();

      while (childNodes.hasNext())
      {
         Node groupNode = childNodes.nextNode();
         if (!groupNode.getName().startsWith(JCROrganizationServiceImpl.JOS_MEMBERSHIP))
         {
            Group group = readGroup(groupNode);
            groups.add(group);

            if (recursive)
            {
               groups.addAll(findGroups(session, group, recursive));
            }
         }
      }

      return groups;
   }
1134518
private void getGroups(Entity entity, LdapEntry ldapEntry, GroupMembershipControl grpMbrshipCtrl) throws WIMException {
        if (grpMbrshipCtrl == null) {
            return;
        }

        int level = grpMbrshipCtrl.getLevel();
        List<String> propNames = grpMbrshipCtrl.getProperties();
        String[] bases = null;
        List<String> searchBases = grpMbrshipCtrl.getSearchBases();
        int size = searchBases.size();
        String[] grpBases = iLdapConfigMgr.getGroupSearchBases();
        if (size == 0) {
            // New:: Default search bases to top level nodes if no group level search bases are defined
            if (grpBases.length != 0)
                bases = grpBases;
            else
                bases = iLdapConfigMgr.getTopLdapNodes();
        } else {
            List<String> baseList = new ArrayList<String>(size);
            for (int i = 0; i < size; i++) {
                String uName = searchBases.get(i);
                String dn = getDN(uName, null, null, true, false);
                baseList.add(dn);
            }
            bases = baseList.toArray(new String[0]);
        }
        bases = NodeHelper.getTopNodes(bases);
        if (iLdapConfigMgr.getMembershipAttribute() != null) {
            if (iLdapConfigMgr.isRacf())
                getGroupsByMembershipRacf(entity, ldapEntry, bases, level, propNames, null);
            else {
                getGroupsByMembership(entity, ldapEntry, bases, level, propNames, null);
            }
        } else {
            // If operational attribute "ibm-allGroups" is specified in groupMemberIdMap, then get groups using operational attr "ibm-allGroups"
            if (LdapConstants.IDS_LDAP_SERVER.equalsIgnoreCase(iLdapConfigMgr.getLdapType()) && iLdapConfigMgr.isLdapOperationalAttributeSet())
                getGroupsByOperationalAttribute(entity, ldapEntry, bases, level, propNames);
            else {
                getGroupsByMember(entity, ldapEntry, bases, level, propNames, null);
            }
        }
    }
451121
public Set<Group> findGroups(final RestletUtilUser user, final boolean inheritOnly)
    {
        final Set<Group> result = new HashSet<Group>();
        Set<Group> stack;
        
        // Recursively find user groups
        for(final Group group : this.getRootGroups())
        {
            stack = new LinkedHashSet<Group>();
            this.addGroupsForUser(user, result, group, stack, inheritOnly);
        }
        
        return result;
    }
1252989
@Override
    public Set<IEntityGroup> getParentGroups() throws GroupsException {

        final EntityIdentifier cacheKey = getUnderlyingEntityIdentifier();
        Element element = parentGroupsCache.get(cacheKey);

        if (element == null) {
            final Set<IEntityGroup> groups = buildParentGroupsSet();
            element = new Element(cacheKey, groups);
            parentGroupsCache.put(element);
        }

        @SuppressWarnings("unchecked")
        final Set<IEntityGroup> rslt = (Set<IEntityGroup>) element.getObjectValue();
        return rslt;
    }
714927
@Override
    public Iterator findMemberGroups(IEntityGroup group) throws GroupsException {
        Connection conn = null;
        Collection groups = new ArrayList();
        IEntityGroup eg = null;
        String serviceName = group.getServiceName().toString();
        String localKey = group.getLocalKey();

        try {
            conn = RDBMServices.getConnection();
            String sql = getFindMemberGroupsSql();
            PreparedStatement ps = conn.prepareStatement(sql);
            try {
                ps.setString(1, localKey);
                ps.setString(2, serviceName);
                if (LOG.isDebugEnabled())
                    LOG.debug(
                            "RDBMEntityGroupStore.findMemberGroups(): "
                                    + ps
                                    + " ("
                                    + localKey
                                    + ", "
                                    + serviceName
                                    + ")");
                ResultSet rs = ps.executeQuery();
                try {
                    while (rs.next()) {
                        eg = instanceFromResultSet(rs);
                        groups.add(eg);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                ps.close();
            }
        } catch (Exception sqle) {
            LOG.error("RDBMEntityGroupStore.findMemberGroups(): " + sqle);
            throw new GroupsException("Problem retrieving member groups: " + sqle);
        } finally {
            RDBMServices.releaseConnection(conn);
        }

        return groups.iterator();
    }
868357
@Override
    public IEntityGroup find(String key) throws GroupsException {

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

        log.debug("Invoking find() for key:  {}", key);

        // All of our groups (incl. ROOT_GROUP)
        // are indexed in the 'groups' map by key...
        return groupsTree.getGroups().get(key);
    }
231817
protected function _findInChildren(array $element, $id, $withParents, array &$parents)
    {
        if ($element['id'] == $id) {
            return $element;
        }
        foreach ($element['children'] as $child) {
            if ($child['id'] == $id) {
                if ($withParents) {
                    $parents[] = $element;
                }
                return $child;
            }
            if (null !== ($found = $this->_findInChildren($child, $id, $withParents, $parents))) {
                if ($withParents) {
                    $parents[] = $element;
                }
                return $found;
            }
        }
    }
189658
public function getParents()
    {
        if (!$this->parents) {
            $groups = wei()->group->getGroupsFromCache();

            $parents = wei()->groupModel()->beColl();
            $parents[] = $this;

            $group = $this;
            while ($group->parentId) {
                $group = $groups[$group->parentId];
                $parents[] = $group;
            }

            $this->parents = $parents;
        }

        return $this->parents;
    }