View Javadoc
1   package org.itracker.web.actions;
2   
3   import org.apache.log4j.Logger;
4   import org.apache.struts.action.ActionForm;
5   import org.apache.struts.action.ActionForward;
6   import org.apache.struts.action.ActionMapping;
7   import org.itracker.core.resources.ITrackerResources;
8   import org.itracker.services.ConfigurationService;
9   import org.itracker.web.actions.base.ItrackerBaseAction;
10  import org.itracker.web.util.Constants;
11  import org.itracker.web.util.ServletContextUtils;
12  
13  import javax.servlet.http.HttpServletRequest;
14  import javax.servlet.http.HttpServletResponse;
15  import javax.servlet.http.HttpSession;
16  import java.text.SimpleDateFormat;
17  import java.util.Date;
18  import java.util.Locale;
19  
20  
21  public class ShowHelpAction extends ItrackerBaseAction {
22      private static final Logger log = Logger.getLogger(ShowHelpAction.class);
23  
24      public ActionForward execute(ActionMapping mapping, ActionForm form,
25                                   HttpServletRequest request, HttpServletResponse response)
26              throws Exception {
27  
28          String helpPage = "";
29          String helpParam = request.getParameter("page");
30          HttpSession session = request.getSession(true);
31          Locale locale = (Locale) session.getAttribute(Constants.LOCALE_KEY);
32          log.debug("Requesting Help Page: " + helpParam);
33          if ("ct".equals(helpParam)) {
34              helpPage = "commontasks";
35          } else if ("ab".equals(helpParam)) {
36              setupHelpAboutPageAttributes(request);
37              helpPage = "about";
38          } else {
39              helpPage = "index";
40  
41          }
42          log.debug("Redirecting to Help Page: " + helpPage);
43          request.setAttribute("helpPage", ITrackerResources.getString("itracker.web.helppage." + helpPage, locale));
44  
45          String pageTitleKey = "itracker.web.showhelp.title";
46          String pageTitleArg = ITrackerResources.getString("itracker.web.help" + helpPage+".title", locale);
47          request.setAttribute("pageTitleKey", pageTitleKey);
48          request.setAttribute("pageTitleArg", pageTitleArg);
49  
50          return mapping.findForward("show_help");
51      }
52  
53      public ShowHelpAction() {
54          super();
55  
56      }
57  
58  
59      /**
60       * This method will prepare the request attribute for the help about jsp .
61       */
62      private void setupHelpAboutPageAttributes(HttpServletRequest request) {
63          ConfigurationService configurationService = ServletContextUtils.getItrackerServices().getConfigurationService();
64          long startTimeMillis = Long.parseLong(configurationService.getProperty("start_time_millis", ""));
65          SimpleDateFormat dateFormat = new SimpleDateFormat(ITrackerResources.getString("itracker.dateformat.full"));
66          String startTime = dateFormat.format(new Date(startTimeMillis));
67          request.setAttribute("starttime", startTime);
68          request.setAttribute("javaVersion", System.getProperty("java.version"));
69          request.setAttribute("javaVendor", System.getProperty("java.vendor"));
70      }
71  
72  }