1
2
3
4
5
6 package net.sf.navigator.example;
7
8 import javax.servlet.http.HttpServletRequest;
9 import javax.servlet.http.HttpServletResponse;
10
11 import net.sf.navigator.menu.PermissionsAdapter;
12
13 import org.apache.commons.logging.Log;
14 import org.apache.commons.logging.LogFactory;
15 import org.apache.struts.action.Action;
16 import org.apache.struts.action.ActionForm;
17 import org.apache.struts.action.ActionForward;
18 import org.apache.struts.action.ActionMapping;
19
20
21 /**
22 *
23 * @author ssayles
24 */
25 public final class SetPermissionsAction extends Action {
26
27
28 /**
29 * The <code>Log</code> instance for this application.
30 */
31 private Log log = LogFactory.getLog(SetPermissionsAction.class);
32
33
34
35 /**
36 * Process the specified HTTP request, and create the corresponding HTTP
37 * response (or forward to another web component that will create it).
38 * Return an <code>ActionForward</code> instance describing where and how
39 * control should be forwarded, or <code>null</code> if the response has
40 * already been completed.
41 *
42 * @param mapping The ActionMapping used to select this instance
43 * @param actionForm The optional ActionForm bean for this request (if any)
44 * @param request The HTTP request we are processing
45 * @param response The HTTP response we are creating
46 *
47 * @exception Exception if business logic throws an exception
48 */
49 public ActionForward execute(ActionMapping mapping, ActionForm form,
50 HttpServletRequest request, HttpServletResponse response)
51 throws Exception {
52
53 String[] menus = request.getParameterValues("menus");
54
55 PermissionsAdapter permissions = new SimplePermissionsAdapter(menus);
56 request.getSession().setAttribute("exampleAdapter", permissions);
57
58
59 request.getSession().setAttribute("displayer",
60 request.getParameter("displayer"));
61
62 return (mapping.findForward("success"));
63 }
64 }