KickJava   Java API By Example, From Geeks To Geeks.

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


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

20 public class DisplayCannedMessageSearchAction extends Action
21 {
22     
23     /** Creates a new instance of DisplayUserSearchAction */
24     public DisplayCannedMessageSearchAction()
25     {
26     }
27     
28     public ActionForward execute(ActionMapping mapping,
29     ActionForm form,
30     HttpServletRequest request,
31     HttpServletResponse response) throws UnsupportedEncodingException JavaDoc
32     {
33         CannedMessageSearchForm cform = (CannedMessageSearchForm)form;
34         ActionErrors errors = new ActionErrors();
35         
36         Connection c = (Connection)request.getSession().getAttribute("connection");
37         if (c == null)
38         {
39             errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.not.logged.in"));
40             saveErrors(request, errors);
41             
42             return mapping.findForward("logon");
43         }
44         
45         AccountElement element = (AccountElement)request.getSession().getAttribute("userInfo");
46         if ((element.isAdminLevel() == false) && (element.isCustomerLevel() == false))
47         {
48             errors.add(ActionErrors.GLOBAL_ERROR,
49             new ActionError("error.insufficient.privilege"));
50             saveErrors(request, errors);
51             
52             return mapping.findForward("main_menu");
53         }
54         
55         
56         GroupTable groups = new GroupTable();
57         groups.setConnection(c);
58         if (element.isAdminLevel() == true)
59         {
60             ArrayList group_list = groups.list();
61             if (group_list != null)
62             {
63                 ArrayList list = new ArrayList();
64                 Iterator iter = group_list.iterator();
65                 
66                 while (iter.hasNext() == true)
67                 {
68                     String JavaDoc group = (String JavaDoc)iter.next();
69                     list.add(new LabelValueBean(group, URLEncoder.encode(group, "UTF-8")));
70                 }
71                 
72                 list.add(0, new LabelValueBean("all", URLEncoder.encode("all", "UTF-8")));
73                 list.add(0, new LabelValueBean("", URLEncoder.encode("", "UTF-8")));
74                 cform.setUserGroups(list);
75             }
76         }
77         else
78         {
79             ArrayList group_list = groups.list(element.getDomain());
80             if (group_list != null)
81             {
82                 ArrayList list = new ArrayList();
83                 Iterator iter = group_list.iterator();
84                 
85                 while (iter.hasNext() == true)
86                 {
87                     String JavaDoc group = (String JavaDoc)iter.next();
88                     list.add(new LabelValueBean(group, URLEncoder.encode(group, "UTF-8")));
89                 }
90                 
91                 list.add(0, new LabelValueBean("", URLEncoder.encode("", "UTF-8")));
92                 cform.setUserGroups(list);
93             }
94         }
95         
96         // add related tasks to the navigation bar
97
WebTalkRelatedTasks menu = new WebTalkRelatedTasks();
98         menu.addLink(new LinkAttribute("Administer canned messages", "display_canned_message_management"));
99         request.setAttribute("menu", menu);
100         
101         
102         return mapping.getInputForward();
103     }
104 }
105
Popular Tags