1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.itracker.web.actions.admin.user;
20
21 import org.apache.struts.action.*;
22 import org.itracker.model.User;
23 import org.itracker.model.util.UserUtilities;
24 import org.itracker.services.UserService;
25 import org.itracker.web.actions.base.ItrackerBaseAction;
26 import org.itracker.web.util.LoginUtilities;
27 import org.itracker.web.util.ServletContextUtils;
28 import org.itracker.web.util.SessionManager;
29
30 import javax.servlet.ServletException;
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
33 import java.io.IOException;
34
35
36 public class LockUserAction extends ItrackerBaseAction {
37
38
39 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
40 ActionMessages errors = new ActionMessages();
41
42 try {
43 UserService userService = ServletContextUtils.getItrackerServices().getUserService();
44
45 Integer userId = Integer.valueOf((request.getParameter("id") == null ? "-1" : (request.getParameter("id"))));
46 User user = userService.getUser(userId);
47 user.setStatus(UserUtilities.STATUS_LOCKED);
48
49 if (user.getStatus() == UserUtilities.STATUS_LOCKED) {
50 userService.clearOwnedProjects(user);
51 if (SessionManager.getSessionStart(user.getLogin()) != null) {
52 SessionManager.setSessionNeedsReset(user.getLogin());
53 }
54 }
55 } catch (Exception e) {
56 errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.system"));
57 }
58
59 if (!errors.isEmpty()) {
60 saveErrors(request, errors);
61 }
62 return mapping.findForward("listusers");
63 }
64
65 }
66