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.language;
20
21 import org.apache.log4j.Logger;
22 import org.apache.struts.action.*;
23 import org.itracker.model.util.UserUtilities;
24 import org.itracker.services.ConfigurationService;
25 import org.itracker.web.actions.admin.AdminHomeAction;
26 import org.itracker.web.actions.base.ItrackerBaseAction;
27 import org.itracker.web.util.LoginUtilities;
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 java.io.IOException;
34
35
36 public class InitializeLanguagesAction extends ItrackerBaseAction {
37 private static final Logger log = Logger.getLogger(InitializeLanguagesAction.class);
38
39 public InitializeLanguagesAction() {
40 }
41
42 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
43 ActionMessages errors = new ActionMessages();
44
45 if (!LoginUtilities.hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) {
46 return mapping.findForward("unauthorized");
47 }
48
49 try {
50 ConfigurationService configurationService = ServletContextUtils.getItrackerServices().getConfigurationService();
51
52 configurationService.initializeAllLanguages(true);
53
54 AdminHomeAction.execSetupJspEnv(request);
55 return mapping.getInputForward();
56 } catch (Exception e) {
57 log.error("Exception while reinitializing languages.", e);
58 errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.system"));
59 }
60
61 if (!errors.isEmpty()) {
62 saveErrors(request, errors);
63 }
64
65 return mapping.findForward("error");
66 }
67 }
68