KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > communicator > applications > webtalk > controller > DisplayGroupWizardUserAddAction


1 /*
2  * DisplayGroupWizardUserAddAction.java
3  *
4  */

5
6 package com.quikj.application.communicator.applications.webtalk.controller;
7
8 import com.quikj.application.communicator.applications.webtalk.model.*;
9 import com.quikj.application.communicator.admin.model.*;
10 import com.quikj.application.communicator.admin.controller.*;
11
12 import javax.servlet.http.*;
13 import org.apache.struts.action.*;
14 import org.apache.struts.util.*;
15 import java.sql.*;
16 import java.util.*;
17 import java.io.UnsupportedEncodingException JavaDoc;
18 import java.net.*;
19 /**
20  *
21  * @author bhm
22  */

23 public class DisplayGroupWizardUserAddAction extends Action
24 {
25     
26     /** Creates a new instance of DisplayUserManagementAction */
27     public DisplayGroupWizardUserAddAction()
28     {
29     }
30     
31     public ActionForward execute(ActionMapping mapping,
32     ActionForm form,
33     HttpServletRequest request,
34     HttpServletResponse response) throws UnsupportedEncodingException JavaDoc
35     {
36         UserManagementForm uform = (UserManagementForm)form;
37         ActionErrors errors = new ActionErrors();
38         
39         Connection c = (Connection)request.getSession().getAttribute("connection");
40         if (c == null)
41         {
42             errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.not.logged.in"));
43             saveErrors(request, errors);
44             
45             return mapping.findForward("logon");
46         }
47         
48         AccountElement element = (AccountElement)request.getSession().getAttribute("userInfo");
49         if (element.isAdminLevel() == false)
50         {
51             errors.add(ActionErrors.GLOBAL_ERROR,
52             new ActionError("error.insufficient.privilege"));
53             saveErrors(request, errors);
54             
55             return mapping.findForward("main_menu");
56         }
57         
58         String JavaDoc domain = (String JavaDoc)request.getSession().getAttribute("groupWizardDomain");
59         uform.setDomain(domain);
60         
61         GroupTable groups = new GroupTable();
62         groups.setConnection(c);
63         ArrayList group_list = groups.list(domain);
64         if (group_list != null)
65         {
66             ArrayList list = new ArrayList();
67             Iterator iter = group_list.iterator();
68             
69             while (iter.hasNext() == true)
70             {
71                 String JavaDoc group = (String JavaDoc)iter.next();
72                 
73                 if (group.equals(domain) == false)
74                 {
75                     list.add(new LabelValueBean(group, URLEncoder.encode(group, "UTF-8")));
76                 }
77             }
78             
79             uform.setUserGroups(list);
80         }
81         
82         // clear some of the fields for the next operator to be added
83
uform.setName("");
84         uform.setFullName("");
85         uform.setAddress("");
86         
87         // add related tasks to the navigation bar
88
WebTalkRelatedTasks menu = new WebTalkRelatedTasks();
89         request.setAttribute("menu", menu);
90         
91         menu.addLink(new LinkAttribute("List all groups", "list_groups"));
92         menu.addLink(new LinkAttribute("List all features", "list_features"));
93         menu.addLink(new LinkAttribute("Search users", "display_user_search"));
94         
95         
96         return mapping.getInputForward();
97     }
98 }
99
Popular Tags