View Javadoc
1   package org.itracker.web.util;
2   
3   import org.itracker.model.NameValuePair;
4   import org.itracker.model.PermissionType;
5   import org.itracker.model.User;
6   
7   import javax.servlet.http.HttpSession;
8   import java.util.List;
9   import java.util.Map;
10  import java.util.Set;
11  
12  /**
13   * Helper class with utility methods to help with request handling in Action
14   * or JSP pages.
15   *
16   * @author johnny
17   */
18  public final class RequestHelper {
19  
20      /**
21       * Creates a new instance of RequestUtils
22       */
23      private RequestHelper() {
24      }
25  
26      /**
27       * Returns the map of a permissions by project id.
28       */
29      @SuppressWarnings("unchecked")
30      public static Map<Integer, Set<PermissionType>>
31      getUserPermissions(HttpSession session) {
32  
33          return (Map<Integer, Set<PermissionType>>)
34                  session.getAttribute(Constants.PERMISSIONS_KEY);
35      }
36  
37      public static User getCurrentUser(HttpSession session) {
38  
39          return (User) session.getAttribute(Constants.USER_KEY);
40      }
41  
42      @SuppressWarnings("unchecked")
43      public static Map<Integer, List<NameValuePair>>
44      getListOptions(HttpSession session) {
45          return (Map<Integer, List<NameValuePair>>)
46                  session.getAttribute(Constants.LIST_OPTIONS_KEY);
47      }
48  
49  }