docs: @Override
      public EntityIdentifier[] searchForGroups(
              String query, SearchMethod searchMethod, Class leafType) throws GroupsException {
          List ids = new ArrayList();
          File baseDir = getFileRoot(leafType);
  
          if (log.isDebugEnabled())
              log.debug(
                      DEBUG_CLASS_NAME
                              + "searchForGroups(): "
                              + query
                              + " method: "
                              + searchMethod
                              + " type: "
                              + leafType);
  
          if (baseDir != null) {
              String nameFilter = null;
  
              switch (searchMethod) {
                  case DISCRETE:
                  case DISCRETE_CI:
                      nameFilter = query;
                      break;
                  case STARTS_WITH:
                  case STARTS_WITH_CI:
                      nameFilter = query + ".*";
                      break;
                  case ENDS_WITH:
                  case ENDS_WITH_CI:
                      nameFilter = ".*" + query;
                      break;
                  case CONTAINS:
                  case CONTAINS_CI:
                      nameFilter = ".*" + query + ".*";
                      break;
                  default:
                      throw new GroupsException(
                              DEBUG_CLASS_NAME
                                      + ".searchForGroups(): Unknown search method: "
                                      + searchMethod);
              }
  
              final Pattern namePattern = Pattern.compile(nameFilter);
              final FilenameFilter filter =
                      new FilenameFilter() {
                          @Override
                          public boolean accept(File dir, String name) {
                              return namePattern.matcher(name).matches();
                          }
                      };
  
              Set allDirs = getAllDirectoriesBelow(baseDir);
              allDirs.add(baseDir);
  
              for (Iterator itr = allDirs.iterator(); itr.hasNext(); ) {
                  File[] files = ((File) itr.next()).listFiles(filter);
                  for (int filesIdx = 0; filesIdx < files.length; filesIdx++) {
                      String key = getKeyFromFile(files[filesIdx]);
                      EntityIdentifier ei =
                              new EntityIdentifier(key, ICompositeGroupService.GROUP_ENTITY_TYPE);
                      ids.add(ei);
                  }
              }
          }
  
          if (log.isDebugEnabled())
              log.debug(DEBUG_CLASS_NAME + ".searchForGroups(): found " + ids.size() + " files.");
  
          return (EntityIdentifier[]) ids.toArray(new EntityIdentifier[ids.size()]);
      }