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.configuration;
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
27 import org.apache.log4j.Logger;
28 import org.apache.struts.action.ActionForm;
29 import org.apache.struts.action.ActionForward;
30 import org.apache.struts.action.ActionMapping;
31 import org.apache.struts.action.ActionMessage;
32 import org.apache.struts.action.ActionMessages;
33 import org.itracker.services.util.UserUtilities;
34 import org.itracker.web.actions.base.ItrackerBaseAction;
35 import org.itracker.web.forms.ImportForm;
36
37
38
39 public class ImportDataFormAction extends ItrackerBaseAction {
40 private static final Logger log = Logger.getLogger(ImportDataFormAction.class);
41
42 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
43 ActionMessages errors = new ActionMessages();
44
45
46 if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) {
47 return mapping.findForward("unauthorized");
48 }
49
50 try {
51 ImportForm importForm = (ImportForm) form;
52 if(importForm == null) {
53 importForm = new ImportForm();
54 }
55 importForm.setOptionreuseusers(Boolean.TRUE);
56 importForm.setOptionreuseprojects(Boolean.TRUE);
57 importForm.setOptionreuseconfig(Boolean.TRUE);
58 importForm.setOptionreusefields(Boolean.TRUE);
59 importForm.setOptioncreatepasswords(Boolean.TRUE);
60
61 request.setAttribute("importForm", importForm);
62 saveToken(request);
63 return mapping.getInputForward();
64 } catch(Exception e) {
65 log.error("Exception while creating import data form.", e);
66 errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.system"));
67 }
68
69 if(! errors.isEmpty()) {
70 saveErrors(request, errors);
71 }
72
73 return mapping.findForward("error");
74 }
75
76 }
77