1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.itracker.web.actions.project;
20
21 import org.apache.commons.beanutils.PropertyUtils;
22 import org.apache.log4j.Logger;
23 import org.apache.struts.action.*;
24 import org.itracker.model.User;
25 import org.itracker.services.IssueService;
26 import org.itracker.web.actions.base.ItrackerBaseAction;
27 import org.itracker.web.util.Constants;
28 import org.itracker.web.util.ServletContextUtils;
29
30 import javax.servlet.ServletException;
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
33 import javax.servlet.http.HttpSession;
34 import java.io.IOException;
35
36
37 public class RemoveHistoryEntryAction extends ItrackerBaseAction {
38 private static final Logger log = Logger.getLogger(RemoveHistoryEntryAction.class);
39
40
41 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
42
43 ActionMessages errors = new ActionMessages();
44
45 try {
46 IssueService issueService = ServletContextUtils.getItrackerServices().getIssueService();
47
48 Integer historyId = (Integer) PropertyUtils.getSimpleProperty(form, "historyId");
49 String caller = (String) PropertyUtils.getSimpleProperty(form, "caller");
50 if (caller == null) {
51 caller = "";
52 }
53
54 HttpSession session = request.getSession(true);
55 User currUser = (User) session.getAttribute(Constants.USER_KEY);
56 if (!currUser.isSuperUser()) {
57 return mapping.findForward("unauthorized");
58 } else {
59 Integer issueId = issueService.removeIssueHistoryEntry(historyId, currUser.getId());
60 return new ActionForward(mapping.findForward("editissue").getPath() + "?id=" + issueId + "&caller=" + caller);
61 }
62 } catch (Exception e) {
63 errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.system"));
64 log.error("System Error.", e);
65 }
66 if (!errors.isEmpty()) {
67 saveErrors(request, errors);
68 }
69 return mapping.findForward("error");
70 }
71
72 }
73