* @throws Exception
*/
public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
CoreUtil.clearFlow(request);
ShowAvailableAccountsForm accountsForm = (ShowAvailableAccountsForm) form;
UserDatabase userDatabase = UserDatabaseManager.getInstance().getUserDatabase(getSessionInfo(request).getUser().getRealm());
User[] users;
try {
String filterText = accountsForm.getFilterText();
String filter = Util.isNullOrTrimmedBlank(filterText) ? UserDatabase.WILDCARD_SEARCH : filterText;
int maxUserResults = userDatabase.getMaxUserResults();
users = userDatabase.listAllUsers(filter, maxUserResults + 1);
if (users.length > maxUserResults) {
int newLength = users.length - 1;
User[] copy = new User[newLength];
System.arraycopy(users, 0, copy, 0, newLength);
users = copy;
saveMessage(request, "availableAccounts.match.limited", maxUserResults);
}
} catch (Exception e) {
LOG.error("Could not list users.", e);
String exceptionMessageChain = Util.getExceptionMessageChain(e);
saveError(request, "availableAccounts.cannotListAccounts", exceptionMessageChain);
users = new User[0];
}
accountsForm.initialize(users, request.getSession());
ActionMessages messages = new ActionMessages();
if (userDatabase.supportsAccountCreation() && !userDatabase.supportsPasswordChange()) {
messages.add(Globals.MESSAGE_KEY, new ActionMessage("availableAccounts.noPasswordChange.text"));
}
if (!userDatabase.supportsAccountCreation() && userDatabase.supportsPasswordChange()) {