KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * DisplayGroupWizardCannedMessageAddAction.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 DisplayGroupWizardCannedMessageAddAction extends Action
24 {
25     
26     /** Creates a new instance of DisplayUserManagementAction */
27     public DisplayGroupWizardCannedMessageAddAction()
28     {
29     }
30     
31     public ActionForward execute(ActionMapping mapping,
32     ActionForm form,
33     HttpServletRequest request,
34     HttpServletResponse response) throws UnsupportedEncodingException JavaDoc
35     {
36         GroupWizardCannedMessageForm cform = (GroupWizardCannedMessageForm)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         cform.setDomain(domain);
60         cform.setCounter(cform.getCounter() + 1);
61         
62         GroupTable groups = new GroupTable();
63         groups.setConnection(c);
64         ArrayList group_list = groups.list(domain);
65         if (group_list != null)
66         {
67             ArrayList list = new ArrayList();
68             Iterator iter = group_list.iterator();
69             
70             while (iter.hasNext() == true)
71             {
72                 String JavaDoc group = (String JavaDoc)iter.next();
73                 
74                 if (group.equals(domain) == false)
75                 {
76                     list.add(new LabelValueBean(group, URLEncoder.encode(group, "UTF-8")));
77                 }
78                 else
79                 {
80                     list.add(0, new LabelValueBean("All of this customer's groups", URLEncoder.encode(group, "UTF-8")));
81                 }
82             }
83             
84             cform.setUserGroups(list);
85         }
86         
87         // clear some of the fields for the next message to be added
88
cform.setContent("");
89         cform.setDescription("");
90         
91         // add related tasks to the navigation bar
92
WebTalkRelatedTasks menu = new WebTalkRelatedTasks();
93         request.setAttribute("menu", menu);
94         
95         menu.addLink(new LinkAttribute("List all groups", "list_groups"));
96         menu.addLink(new LinkAttribute("List all features", "list_features"));
97         menu.addLink(new LinkAttribute("Search users", "display_user_search"));
98         menu.addLink(new LinkAttribute("Search canned messages", "display_canned_message_search"));
99         
100         return mapping.getInputForward();
101     }
102 }
103
Popular Tags