* org.ajaxtags.helpers.AjaxXmlBuilder)
*/
@SuppressWarnings("unchecked")
protected void onAjaxRequest(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response,
AjaxXmlBuilder builder) throws Exception {
UserDatabase userDatabase;
if (ContextHolder.getContext().isSetupMode()) {
AbstractWizardSequence sequence = (AbstractWizardSequence) request.getSession().getAttribute(Constants.WIZARD_SEQUENCE);
if (sequence == null) {
log.error("No wizard sequence, cannot list users.");
return;
}
userDatabase = (UserDatabase) sequence.getAttribute(SelectUserDatabaseForm.ATTR_USER_DATABASE_INSTANCE, null);
if (userDatabase == null) {
log.error("No user database, cannot list users.");
return;
}
} else {
SessionInfo sessionInfo = LogonControllerFactory.getInstance().getSessionInfo(request);
if (sessionInfo == null) {
throw new Exception("No authenticated.");
}
Realm realm = LogonControllerFactory.getInstance().getUser(request).getRealm();
userDatabase = UserDatabaseManager.getInstance().getUserDatabase(realm);
}
String account = request.getParameter("account");
String maxRows = request.getParameter("maxRows");
int rows = Integer.parseInt(maxRows == null ? "10" : maxRows);
String filter = (account == null ? "" : Util.urlDecode(account)) + "*";
User[] users = userDatabase.listAllUsers(filter, rows);
List<User> sortedUsers = new ArrayList<User>(Arrays.asList(users));
Collections.sort(sortedUsers);
for (User user : sortedUsers) {
if (isPermitted(user)) {
String encodedHtml = Util.encodeHTML(user.getPrincipalName());