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