1 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 import com.quikj.server.framework.*; 12 13 import javax.servlet.http.*; 14 import org.apache.struts.action.*; 15 import java.sql.*; 16 import java.util.*; 17 18 22 public class GroupWizardGroupAddAction extends Action 23 { 24 25 26 public GroupWizardGroupAddAction() 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 ArrayList log = (ArrayList) request.getSession().getAttribute("groupWizardLog"); 57 if (log == null) 58 { 59 61 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.hosting.wizard.sequence")); 62 saveErrors(request, errors); 63 64 return mapping.findForward("display_group_wizard_intro"); 65 } 66 67 String submit = (String )((DynaActionForm)form).get("submit"); 68 69 if (submit.equals("Add Group") == true) 70 { 71 String domain = (String )request.getSession().getAttribute("groupWizardDomain"); 72 String group_name = domain + '-' + ((String )((DynaActionForm)form).get("groupName")).trim(); 73 74 GroupTable groups = new GroupTable(); 75 groups.setConnection(c); 76 77 GroupElement e = new GroupElement(); 78 79 e.setMemberBusyNotificationControl(GroupElement.NOTIFY_ALL); 80 e.setMemberLoginNotificationControl(GroupElement.NOTIFY_ALL); 81 e.setOwnerBusyNotificationControl(GroupElement.NOTIFY_NONE); 82 e.setOwnerLoginNotificationControl(GroupElement.NOTIFY_NONE); 83 e.setName(group_name); 84 e.setDomain(domain); 85 86 boolean status_ok = groups.create(e); 87 88 if (status_ok == false) 89 { 90 errors.add(ActionErrors.GLOBAL_ERROR, 91 new ActionError("error.group.create.failure")); 92 93 AceLogger.Instance().log(AceLogger.ERROR, AceLogger.SYSTEM_LOG, 94 "GroupWizardGroupAddAction.execute()/Create Group/by-" 95 + element.getName() 96 + ": " 97 + groups.getErrorMessage()); 98 } 99 else 100 { 101 AceLogger.Instance().log(AceLogger.INFORMATIONAL, AceLogger.USER_LOG, 102 "User " + element.getName() + " created new group " + 103 group_name); 104 105 ActionMessages messages = new ActionMessages(); 106 messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.group.x.created", new String (group_name))); 107 saveMessages(request, messages); 108 109 StringBuffer buf = new StringBuffer ("\nCreated group '"); 111 buf.append(group_name); 112 buf.append("'\n"); 113 log.add(buf.toString()); 114 115 116 118 String groupowner_name = group_name; 119 120 UserTable user_tbl = new UserTable(); 121 user_tbl.setConnection(c); 122 123 UserElement u = new UserElement(); 124 125 u.setAdditionalInfo("Owner of group " + group_name + ", company: " 126 + (String )request.getSession().getAttribute("groupWizardCompanyName") + ", url: " 127 + (String )request.getSession().getAttribute("groupWizardCompanyUrl")); 128 u.setAddress(((String )((DynaActionForm)form).get("messageboxEmail")).trim()); 129 u.setFullName(group_name + " Group"); 130 u.setName(groupowner_name); 131 u.setUnavailXferTo("messagebox"); 132 u.setPassword("a1b2c3d4"); 133 u.addOwnsGroup(group_name); 134 u.setDomain(domain); 135 u.addBelongsToGroup(domain); 136 137 status_ok = user_tbl.create(u); 138 139 if (status_ok == false) 140 { 141 errors.add(ActionErrors.GLOBAL_ERROR, 142 new ActionError("error.groupowner.create.failure", new String (groupowner_name), new String (group_name))); 143 144 AceLogger.Instance().log(AceLogger.ERROR, AceLogger.SYSTEM_LOG, 145 "GroupWizardGroupAddAction.execute()/Create Group Owner/by-" 146 + element.getName() 147 + ": " 148 + user_tbl.getErrorMessage()); 149 150 buf = new StringBuffer ("\n*** ERROR *** creating group owner : The group owner named '"); 152 buf.append(groupowner_name); 153 buf.append("' for the new group '"); 154 buf.append(group_name); 155 buf.append("' could not be created because a user with that name already exists or there was a database error. If that user name already exists in the system, proceed with the wizard as you normally would. After finishing with the wizard, add the group owner and the feature for this new group yourself, using a unique name other than '"); 156 buf.append(groupowner_name); 157 buf.append("'. Remember to activate the feature after adding it."); 158 buf.append("\n"); 159 log.add(buf.toString()); 160 } 161 else 162 { 163 AceLogger.Instance().log(AceLogger.INFORMATIONAL, AceLogger.USER_LOG, 164 "User " + element.getName() + " created new webtalk user " + 165 groupowner_name); 166 167 buf = new StringBuffer ("\nCreated group owner '"); 169 buf.append(groupowner_name); 170 buf.append("'\n"); 171 log.add(buf.toString()); 172 173 175 Integer max_operators = (Integer )((DynaActionForm)form).get("maxOperators"); 176 177 FeatureTable tbl = new FeatureTable(); 178 tbl.setConnection(c); 179 180 FeatureTableElement f = new FeatureTableElement(); 181 182 f.setActive(true); 183 f.setClassName(FeatureOperatorManagementAction.CLASSNAME); 184 f.setName(groupowner_name); 185 f.setDomain(domain); 186 187 HashMap map = new HashMap(4); 188 189 map.put("max-sessions", ((Integer )((DynaActionForm)form).get("maxSessions")).toString()); 190 map.put("max-queue-size", new Integer (max_operators.intValue() * 4).toString()); 191 map.put("max-operators", max_operators.toString()); 192 map.put("proactive-monitoring", ((DynaActionForm)form).get("proactiveMonitoringEnabled")); 193 194 f.setParams(map); 195 196 if (tbl.create(f) == false) 197 { 198 errors.add(ActionErrors.GLOBAL_ERROR, 199 new ActionError("error.groupfeature.create.failure", new String (groupowner_name), new String (group_name))); 200 201 AceLogger.Instance().log(AceLogger.ERROR, AceLogger.SYSTEM_LOG, 202 "GroupWizardGroupAddAction.execute()/Create Feature/by-" 203 + element.getName() 204 + ": " 205 + tbl.getErrorMessage()); 206 207 buf = new StringBuffer ("\n*** ERROR *** creating feature : The feature named '"); 209 buf.append(groupowner_name); 210 buf.append("' for the new group '"); 211 buf.append(group_name); 212 buf.append("' could not be created because a feature with that name already exists or there was a database error. If that feature name does already exist in the system, proceed with the wizard as you normally would. After finishing with the wizard, remove the old (presumably unused) feature named '"); 213 buf.append(groupowner_name); 214 buf.append("' and add a new feature with the same name and with the parameter settings you want for this new group (remember to activate the new feature after adding it). Note, a group owner named '"); 215 buf.append(groupowner_name); 216 buf.append("' has just been successfully added to the system for the new group '"); 217 buf.append(group_name); 218 buf.append("', and the parameter settings for feature '"); 219 buf.append(groupowner_name); 220 buf.append("' will be applied to the new group."); 221 buf.append("\n"); 222 log.add(buf.toString()); 223 } 224 else 225 { 226 AceLogger.Instance().log(AceLogger.INFORMATIONAL, AceLogger.USER_LOG, 227 "User " + element.getName() + " created active feature " + 228 groupowner_name); 229 230 buf = new StringBuffer ("\nCreated feature '"); 232 buf.append(groupowner_name); 233 buf.append("'\n"); 234 log.add(buf.toString()); 235 236 238 if (FeatureManagementAction.notifyAppServer(request, groupowner_name, "activate", null, "Create Feature/by-" + element.getName()) == false) 240 { 241 errors.add(ActionErrors.GLOBAL_ERROR, 242 new ActionError("error.groupfeature.activate.failure", new String (groupowner_name), new String (group_name))); 243 244 buf = new StringBuffer ("\n*** WARNING *** The data for the new group got added successfully, but the feature ('"); 246 buf.append(groupowner_name); 247 buf.append("') for the new operator group could not be activated at the Ace Application Server. You can proceed with the wizard, but afterward you'll need to (re)start the Application Server before the new group '"); 248 buf.append(group_name); 249 buf.append("' can be used."); 250 buf.append("\n"); 251 log.add(buf.toString()); 252 } 253 } 254 } 255 } 256 } 257 258 WebTalkRelatedTasks menu = new WebTalkRelatedTasks(); 259 request.setAttribute("menu", menu); 260 261 if (submit.startsWith("Cancel") == false) 262 { 263 265 menu.addLink(new LinkAttribute("List all groups", "list_groups")); 266 menu.addLink(new LinkAttribute("List all features", "list_features")); 267 menu.addLink(new LinkAttribute("Search users", "display_user_search")); 268 } 269 270 if (errors.isEmpty() == false) 271 { 272 saveErrors(request, errors); 273 return mapping.getInputForward(); 274 } 275 276 return mapping.findForward(submit); 277 } 278 279 280 } 281 | Popular Tags |