1 5 6 package com.quikj.application.communicator.applications.webtalk.controller; 7 8 import javax.servlet.http.*; 9 import org.apache.struts.action.*; 10 import java.sql.*; 11 import java.util.*; 12 13 import com.quikj.application.communicator.admin.model.*; 14 import com.quikj.application.communicator.admin.controller.*; 15 import com.quikj.application.communicator.applications.webtalk.model.*; 16 import com.quikj.server.framework.*; 17 18 22 public class ListFeaturesAction extends Action 23 { 24 25 26 public ListFeaturesAction() 27 { 28 } 29 30 public ActionForward execute(ActionMapping mapping, 31 ActionForm form, 32 HttpServletRequest request, 33 HttpServletResponse response) 34 { 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, 41 new ActionError("error.not.logged.in")); 42 saveErrors(request, errors); 43 return mapping.findForward("logon"); 44 } 45 46 AccountElement element = (AccountElement)request.getSession().getAttribute("userInfo"); 47 if (element.isAdminLevel() == 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 FeatureTable tbl = new FeatureTable(); 57 tbl.setConnection(c); 58 59 ArrayList list = tbl.list(); 60 61 if (list == null) 62 { 63 errors.add(ActionErrors.GLOBAL_ERROR, 64 new ActionError("error.db.failure")); 65 66 AceLogger.Instance().log(AceLogger.ERROR, AceLogger.SYSTEM_LOG, 67 "ListFeaturesAction.execute()/by-" 68 + element.getName() 69 + ": " 70 + tbl.getErrorMessage()); 71 } 72 else 73 { 74 int num_items = list.size(); 75 76 ArrayList name_list = new ArrayList(); 78 for (int i = 0; i < num_items; i++) 79 { 80 FeatureTableElement ele = (FeatureTableElement) list.get(i); 81 82 HashMap map = new HashMap(); 83 map.put("name", ele.getName()); 84 map.put("submit", "Find"); 85 map.put("domain", ele.getDomain()); 86 87 if (ele.isActive() == true) 88 { 89 map.put("status", "active"); 90 } 91 else 92 { 93 map.put("status", "inactive"); 94 } 95 96 if (ele.getClassName().equals(FeatureOperatorManagementAction.CLASSNAME) == true) 97 { 98 map.put("forward", "feature_operator_management"); 99 } 100 else 101 { 102 map.put("forward", "feature_management"); 103 } 104 105 name_list.add(map); 106 } 107 108 request.setAttribute("features", name_list); 109 } 110 111 if (errors.isEmpty() == false) 112 { 113 saveErrors(request, errors); 114 } 115 116 WebTalkRelatedTasks menu = new WebTalkRelatedTasks(); 118 menu.addLink(new LinkAttribute("Administer operator features", "display_feature_operator_management")); 119 menu.addLink(new LinkAttribute("Administer other features", "display_feature_management")); 120 menu.addLink(new LinkAttribute("Administer users", "display_user_management")); 121 menu.addLink(new LinkAttribute("Search users", "display_user_search")); 122 request.setAttribute("menu", menu); 123 124 return mapping.getInputForward(); 125 } 126 } | Popular Tags |