View Javadoc
1   package org.itracker.web.actions.admin.project;
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.model.PermissionType;
8   import org.itracker.model.util.UserUtilities;
9   import org.itracker.web.actions.project.ListProjectsAction;
10  import org.itracker.web.util.RequestHelper;
11  import org.itracker.web.util.ServletContextUtils;
12  
13  import javax.servlet.http.HttpServletRequest;
14  import javax.servlet.http.HttpServletResponse;
15  import java.util.Map;
16  import java.util.Set;
17  
18  
19  /**
20   * Action for preparing request for list_projects.jsp.
21   *
22   * @author ranks
23   */
24  public class ListProjectsAdminAction extends ListProjectsAction {
25  
26      private static final Logger log = Logger.getLogger(ListProjectsAdminAction.class);
27  
28      public ActionForward execute(ActionMapping mapping, ActionForm form,
29                                   HttpServletRequest request, HttpServletResponse response)
30              throws Exception {
31  
32          final Map<Integer, Set<PermissionType>> permissions =
33                  RequestHelper.getUserPermissions(request.getSession());
34          Boolean isSuperUser = UserUtilities.isSuperUser(permissions);
35          Boolean showAll = Boolean.valueOf(request.getParameter("showAll"));
36  
37          // filter projects, so only administrated projects remain
38          if (showAll) {
39              request.setAttribute("projects", getAllPTOs(ServletContextUtils.getItrackerServices().getProjectService(), new PermissionType[]{PermissionType.PRODUCT_ADMIN}, permissions));
40          } else {
41              request.setAttribute("projects", getPTOs(ServletContextUtils.getItrackerServices().getProjectService(), new PermissionType[]{PermissionType.PRODUCT_ADMIN}, permissions));
42          }
43          if (log.isDebugEnabled()) {
44              log.debug("execute: project-ptos set to request-attribute: " + request.getAttribute("projects"));
45          }
46          request.setAttribute("isSuperUser", isSuperUser);
47          request.setAttribute("showAll", showAll);
48  
49          String pageTitleKey = "itracker.web.admin.listprojects.title";
50          String pageTitleArg = "";
51          request.setAttribute("pageTitleKey", pageTitleKey);
52          request.setAttribute("pageTitleArg", pageTitleArg);
53  
54          return mapping.findForward("listprojectsadmin");
55      }
56  
57  
58  }