1 package org.itracker.web.actions.admin.user; 2 3 import org.apache.struts.action.ActionForm; 4 import org.apache.struts.action.ActionForward; 5 import org.apache.struts.action.ActionMapping; 6 import org.itracker.model.User; 7 import org.itracker.model.util.UserUtilities; 8 import org.itracker.services.UserService; 9 import org.itracker.web.actions.base.ItrackerBaseAction; 10 import org.itracker.web.ptos.UserPTO; 11 import org.itracker.web.util.ServletContextUtils; 12 import org.itracker.web.util.SessionManager; 13 14 import javax.servlet.http.HttpServletRequest; 15 import javax.servlet.http.HttpServletResponse; 16 import java.util.Collections; 17 import java.util.LinkedList; 18 import java.util.List; 19 20 21 public class ListUsersAction extends ItrackerBaseAction { 22 23 24 public ActionForward execute(ActionMapping mapping, ActionForm form, 25 HttpServletRequest request, HttpServletResponse response) 26 throws Exception { 27 28 UserService userService = ServletContextUtils.getItrackerServices().getUserService(); 29 boolean allowProfileCreation = 30 userService.allowProfileCreation(null, null, UserUtilities.AUTH_TYPE_UNKNOWN, UserUtilities.REQ_SOURCE_WEB); 31 request.setAttribute("allowProfileCreation", allowProfileCreation); 32 33 int activeSessions = SessionManager.getNumActiveSessions(); 34 request.setAttribute("activeSessions", activeSessions); 35 36 List<User> users = userService.getAllUsers(); 37 Collections.sort(users, User.NAME_COMPARATOR); 38 39 List<UserPTO> userDTOList = new LinkedList<UserPTO>(); 40 for (User user : users) { 41 UserPTOrPTO.html#UserPTO">UserPTO aUserDTO = new UserPTO(user, SessionManager.getSessionLastAccess(user.getLogin())); 42 userDTOList.add(aUserDTO); 43 } 44 45 request.setAttribute("users", userDTOList); 46 47 String pageTitleKey = "itracker.web.admin.listusers.title"; 48 String pageTitleArg = ""; 49 request.setAttribute("pageTitleKey", pageTitleKey); 50 request.setAttribute("pageTitleArg", pageTitleArg); 51 52 return mapping.findForward("listusers"); 53 } 54 55 56 }