| 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 ; 15 import java.net.*; 16 17 21 public class DisplayCannedMessageManagementAction extends Action 22 { 23 24 25 public DisplayCannedMessageManagementAction() 26 { 27 } 28 29 public ActionForward execute(ActionMapping mapping, 30 ActionForm form, 31 HttpServletRequest request, 32 HttpServletResponse response) throws UnsupportedEncodingException  33 { 34 CannedMessageManagementForm cform = (CannedMessageManagementForm)form; 35 ActionErrors errors = new ActionErrors(); 36 37 Connection c = (Connection)request.getSession().getAttribute("connection"); 38 if (c == null) 39 { 40 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.not.logged.in")); 41 saveErrors(request, errors); 42 43 return mapping.findForward("logon"); 44 } 45 46 AccountElement element = (AccountElement)request.getSession().getAttribute("userInfo"); 47 if ((element.isAdminLevel() == false) && (element.isCustomerLevel() == false)) 48 { 49 errors.add(ActionErrors.GLOBAL_ERROR, 50 new ActionError("error.insufficient.privilege")); 51 saveErrors(request, errors); 52 53 return mapping.findForward("main_menu"); 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(group_list.size() + 2); 64 list.add(0, new LabelValueBean("", URLEncoder.encode("", "UTF-8"))); 65 list.add(1, new LabelValueBean("all", URLEncoder.encode("all", "UTF-8"))); 66 67 Iterator iter = group_list.iterator(); 68 69 while (iter.hasNext() == true) 70 { 71 String group = (String )iter.next(); 72 list.add(new LabelValueBean(group, URLEncoder.encode(group, "UTF-8"))); 73 } 74 75 cform.setUserGroups(list); 76 } 77 } 78 else 79 { 80 ArrayList group_list = groups.list(element.getDomain()); 81 if (group_list != null) 82 { 83 ArrayList list = new ArrayList(group_list.size() + 1); 84 list.add(0, new LabelValueBean("", URLEncoder.encode("", "UTF-8"))); 85 86 Iterator iter = group_list.iterator(); 87 88 while (iter.hasNext() == true) 89 { 90 String group = (String )iter.next(); 91 list.add(new LabelValueBean(group, URLEncoder.encode(group, "UTF-8"))); 92 } 93 94 cform.setUserGroups(list); 95 } 96 } 97 98 WebTalkRelatedTasks menu = new WebTalkRelatedTasks(); 100 menu.addLink(new LinkAttribute("Search canned messages", "display_canned_message_search")); 101 request.setAttribute("menu", menu); 102 103 return mapping.getInputForward(); 104 } 105 } 106 | Popular Tags |