code: @Override
      public EntityIdentifier[] searchForGroups(
              final String query,
              final SearchMethod method,
              @SuppressWarnings("unchecked") final Class leaftype) {
  
          // only search for groups
          if (leaftype != IPerson.class) {
              return new EntityIdentifier[] {};
          }
  
          if (LOGGER.isDebugEnabled()) {
              LOGGER.debug("Searching Grouper for groups matching query: " + query);
          }
  
          // result groups.
          List<EntityIdentifier> groups = new ArrayList<EntityIdentifier>();
  
          try {
  
              // TODO: searches need to be performed against the group display
              // name rather than the group key
  
              GcFindGroups groupSearch = new GcFindGroups();
              WsQueryFilter filter = new WsQueryFilter();
              // is this an exact search or fuzzy
              if ((method == SearchMethod.DISCRETE_CI) || (method == SearchMethod.DISCRETE)) {
                  filter.setQueryFilterType("FIND_BY_GROUP_NAME_EXACT");
              } else {
                  filter.setQueryFilterType("FIND_BY_GROUP_NAME_APPROXIMATE");
              }
              filter.setGroupName(query);
              groupSearch.assignQueryFilter(filter);
              WsFindGroupsResults results = groupSearch.execute();
  
              if (results != null && results.getGroupResults() != null) {
                  for (WsGroup g : results.getGroupResults()) {
                      if (validKey(g.getName())) {
                          if (LOGGER.isTraceEnabled()) {
                              LOGGER.trace("Retrieved group: " + g.getName());
                          }
                          groups.add(new EntityIdentifier(g.getName(), IEntityGroup.class));
                      }
                  }
              }
  
              if (LOGGER.isDebugEnabled()) {
                  LOGGER.debug("Returning " + groups.size() + " results for query " + query);
              }
  
              return groups.toArray(new EntityIdentifier[groups.size()]);
  
          } catch (Exception e) {
              LOGGER.warn(
                      "Exception while attempting to retrieve "
                              + "search results for query "
                              + query
                              + " and entity type "
                              + leaftype.getCanonicalName()
                              + " : "
                              + e.getMessage());
              return new EntityIdentifier[] {};
          }
      }
docs: /* (non-Javadoc)
  @see org.apereo.portal.groups.IEntityGroupStore#searchForGroups(java.lang.String, int, java.lang.Class)