/**
  * Gets the users which have their access level equals to the specified one.
  *
  * @param accessLevel the access level the users must have.
  * @return a list of user identifiers.
  * @throws AdminException
  */
 private List<String> getUserIdsByAccessLevel(String accessLevel) throws AdminException {
   List<String> userIds;
   DomainDriverManager domainDriverManager =
       DomainDriverManagerProvider.getCurrentDomainDriverManager();
   if ("*".equalsIgnoreCase(accessLevel)) {
     // In case of "Shared domain" then retrieving all users of all domains
     // Otherwise getting only users of group's domain
     if (isSharedDomain) {
       userIds = asList(getUserManager().getAllUsersIds(domainDriverManager));
     } else {
       userIds =
           asList(getUserManager().getUserIdsOfDomain(domainDriverManager, group.getDomainId()));
     }
   } else {
     // All users by access level
     if (isSharedDomain) {
       userIds =
           asList(
               domainDriverManager
                   .getOrganization()
                   .user
                   .getUserIdsByAccessLevel(UserAccessLevel.fromCode(accessLevel)));
     } else {
       userIds =
           asList(
               getUserManager()
                   .getUserIdsOfDomainAndAccessLevel(
                       domainDriverManager,
                       group.getDomainId(),
                       UserAccessLevel.fromCode(accessLevel)));
     }
   }
   return userIds;
 }
 /**
  * Gets the users of the domain represented by the given identifier.<br>
  * This method returns user identifiers only into the context of shared domain search.
  *
  * @param domainId the identifier of the aimed domain.
  * @return a list of user identifiers.
  * @throws AdminPersistenceException
  */
 private List<String> getUserIdsByDomain(String domainId) throws AdminPersistenceException {
   DomainDriverManager domainDriverManager =
       DomainDriverManagerProvider.getCurrentDomainDriverManager();
   List<String> userIds = Collections.emptyList();
   if (isSharedDomain) {
     userIds =
         asList(
             domainDriverManager
                 .getOrganization()
                 .user
                 .getUserIdsOfDomain(Integer.parseInt(domainId)));
   }
   return userIds;
 }
 /**
  * Gets all user identifiers of the Silverpeas platform.<br>
  * The ids are cached.
  *
  * @return a list of user identifiers.
  * @throws AdminException
  */
 private List<String> getCacheOfAllUserIds() throws AdminException {
   if (cacheOfAllUserIds == null) {
     // In case of "Shared domain", retrieving all users of all domains
     // Otherwise retrieving only users of group's domain
     DomainDriverManager domainDriverManager =
         DomainDriverManagerProvider.getCurrentDomainDriverManager();
     if (isSharedDomain) {
       cacheOfAllUserIds = asList(getUserManager().getAllUsersIds(domainDriverManager));
     } else {
       cacheOfAllUserIds =
           asList(getUserManager().getUserIdsOfDomain(domainDriverManager, group.getDomainId()));
     }
   }
   return new ArrayList<>(cacheOfAllUserIds);
 }
  /**
   * Gets the users which the value of the extra property name matches the given ones.
   *
   * @param domainId the identifier of the aimed domain.
   * @param propertyName the name of the aimed extra property.
   * @param propertyValue the value the property must verify.
   * @return a list of user identifiers.
   * @throws AdminException
   */
  private List<String> getUserIdsBySpecificProperty(
      String domainId, String propertyName, String propertyValue) throws AdminException {
    final int domainIdAsInteger = Integer.parseInt(domainId);
    UserDetail[] users = new UserDetail[0];
    DomainDriverManager domainDriverManager =
        DomainDriverManagerProvider.getCurrentDomainDriverManager();
    DomainDriver domainDriver = null;
    try {
      domainDriver = domainDriverManager.getDomainDriver(domainIdAsInteger);
    } catch (Exception e) {
      reportInfo(
          "admin.getUserIdsBySpecificProperty", "Erreur ! Domaine " + domainId + " inaccessible !");
    }

    if (domainDriver != null) {
      try {
        users = domainDriver.getUsersBySpecificProperty(propertyName, propertyValue);
        if (users == null) {
          reportInfo(
              "admin.getUserIdsBySpecificProperty",
              "La propriété '" + propertyName + "' n'est pas définie dans le domaine " + domainId);
        }
      } catch (Exception e) {
        if (e instanceof AdminException) {
          Throwable cause = e.getCause();
          if (cause instanceof LDAPLocalException
              || cause instanceof org.ietf.ldap.LDAPLocalException) {
            reportInfo(
                "admin.getUserIdsBySpecificProperty",
                "Domain " + domainId + ": " + cause.toString());
          } else {
            throw (AdminException) e;
          }
        } else {
          throw new AdminException(failureOnGetting("users by property", propertyName), e);
        }
      }
    }

    List<String> specificIds = new ArrayList<>();
    if (users != null) {
      for (UserDetail user : users) {
        specificIds.add(user.getSpecificId());
      }
    }

    // We have to find users according to theirs specificIds
    UserRow[] usersInDomain =
        domainDriverManager
            .getOrganization()
            .user
            .getUsersBySpecificIds(domainIdAsInteger, specificIds);
    List<String> userIds = new ArrayList<>();
    if (usersInDomain != null) {
      for (UserRow userInDomain : usersInDomain) {
        userIds.add(Integer.toString(userInDomain.id));
      }
    }

    return userIds;
  }