1 6 7 package com.quikj.application.web.talk.jspbeans; 8 9 import java.io.*; 10 import javax.servlet.*; 11 import javax.servlet.http.*; 12 import com.quikj.client.raccess.*; 13 import com.quikj.server.framework.*; 14 15 20 public class ContactCenterServlet extends HttpServlet 21 { 22 23 public static final String CUSTOMER_BEAN = "customerBean"; 24 25 29 public void init(ServletConfig config) throws ServletException 30 { 31 super.init(config); 32 33 if (AceLicenseManager.getInstance().licenseFeature("ace-contact-center") == false) 34 { 35 throw new ServletException(AceLicenseManager.getInstance().getErrorMessage()); 36 } 37 38 String app_root = getServletContext().getRealPath(""); 39 40 ContactCenterCustomerList bean = new ContactCenterCustomerList(); 41 bean.setPath(app_root); 42 43 getServletContext().setAttribute(CUSTOMER_BEAN, bean); 44 45 } 46 47 51 public void destroy() 52 { 53 } 54 55 59 protected void processRequest(HttpServletRequest request, HttpServletResponse response) 60 throws ServletException, IOException 61 { 62 response.setContentType("text/html"); 63 64 String customer = request.getParameter("customer"); 65 if (customer == null) 66 { 67 request.setAttribute("errorMessage", 68 "talk.servlet.no.customer"); 69 goToPage("/aceapp/jsp/contactcenter/talk_internal_error.jsp", request, response); 70 return; 71 } 72 73 ContactCenterCustomerList customer_bean = (ContactCenterCustomerList)getServletContext().getAttribute(CUSTOMER_BEAN); 74 if (customer_bean == null) 75 { 76 request.setAttribute("errorMessage", 77 "talk.servlet.uninitialized"); 78 goToPage( "/aceapp/jsp/contactcenter/talk_internal_error.jsp", request, response); 79 return; 80 } 81 82 try 83 { 84 ContactCenterCustomerProperty customer_property = 86 customer_bean.getCustomerProperty(customer); 87 88 if (customer_property == null) 89 { 90 request.setAttribute("errorMessage", 92 "talk.servlet.customer.undefined"); 93 goToPage( "/aceapp/jsp/contactcenter/talk_internal_error.jsp", request, response); 94 return; 95 } 96 97 request.setAttribute("customerProperty", customer_property); 99 100 if (customer_property.isActive() == false) 103 { 104 String page = (String )customer_property.getPagesParams().get("oosPage"); 105 if (page == null) 106 { 107 page = "/aceapp/jsp/contactcenter/talk_oos.jsp"; 108 } 109 110 ContactCenterEmailForm form = new ContactCenterEmailForm(); 111 request.setAttribute("formBean", form); 112 113 goToPage(page, request, response); 114 return; 115 } 116 117 if (customer_property.isCheckOperatorAvailability() == true) 118 { 119 if (loggedIn(customer_property.getOperator()) == false) 120 { 121 String page = (String )customer_property.getPagesParams().get("oosPage"); 122 if (page == null) 123 { 124 page = "/aceapp/jsp/contactcenter/talk_oos.jsp"; 125 } 126 127 ContactCenterEmailForm form = new ContactCenterEmailForm(); 128 request.setAttribute("formBean", form); 129 goToPage(page, request, response); 130 return; 131 } 132 else if (allOperatorsBusy(customer_property.getOperator()) == true) 133 { 134 String page = (String )customer_property.getPagesParams().get("aobPage"); 135 if (page == null) 136 { 137 page = (String )customer_property.getPagesParams().get("oosPage"); 138 if (page == null) 139 { 140 page = "/aceapp/jsp/contactcenter/talk_oos.jsp"; 141 } 142 } 143 144 ContactCenterEmailForm form = new ContactCenterEmailForm(); 145 request.setAttribute("formBean", form); 146 goToPage(page, request, response); 147 return; 148 } 149 } 150 151 if( customer_property.getAccessType().equals("unrestricted") == true) 153 { 154 String page = (String )customer_property.getPagesParams().get("userInfoPage"); 155 if (page == null) 156 { 157 page = "/aceapp/jsp/contactcenter/talk_unrestricted_userinfo.jsp"; 158 } 159 160 ContactCenterUnrestrictedAccessForm form = new ContactCenterUnrestrictedAccessForm(); 162 request.setAttribute("formBean", form); 163 164 goToPage(page, 165 request, response); 166 return; 167 168 } 169 else if( customer_property.getAccessType().equals("restricted") == true) 170 { 171 String page = (String )customer_property.getPagesParams().get("userLoginPage"); 172 if (page == null) 173 { 174 page = "/aceapp/jsp/contactcenter/talk_restricted_login.jsp"; 175 } 176 177 ContactCenterRestrictedAccessForm form = new ContactCenterRestrictedAccessForm(); 179 request.setAttribute("formBean", form); 180 181 goToPage(page, request, response ); 182 return; 183 } 184 185 } 186 catch (Exception ex) 187 { 188 request.setAttribute("exceptionMessage", 189 ex.getClass().getName() + ": " 190 + ex.getMessage()); 191 goToPage( "/aceapp/jsp/contactcenter/talk_internal_error.jsp", request, response); 192 return; 193 194 } 195 196 } 197 198 202 protected void doGet(HttpServletRequest request, HttpServletResponse response) 203 throws ServletException, IOException 204 { 205 206 processRequest(request, response); 207 208 } 209 210 214 protected void doPost(HttpServletRequest request, HttpServletResponse response) 215 throws ServletException, IOException 216 { 217 processRequest(request, response); 218 } 219 220 222 public String getServletInfo() 223 { 224 return "This servlet determines if restricted or unrestricted access is required" 225 + " and forwards to the appropriate jsp."; 226 } 227 228 233 private void goToPage( String address, 234 HttpServletRequest request, 235 HttpServletResponse response ) 236 throws ServletException, IOException 237 { 238 RequestDispatcher dispatcher = 239 getServletContext().getRequestDispatcher(address); 240 dispatcher.forward(request, response); 241 } 242 243 private boolean loggedIn(String user) 244 { 245 RemoteAccessClient cl = (RemoteAccessClient)getServletContext().getAttribute("remoteAccess"); 246 if (cl == null) 247 { 248 return false; 249 } 250 251 try 252 { 253 String val = cl.getRemoteAccess().getParam("com.quikj.application.web.talk.feature.operator.Operator:" 254 + user, 255 "operator-queue-size"); 256 if (val == null) 257 { 258 return false; 259 } 260 else 261 { 262 try 263 { 264 int count = Integer.parseInt(val); 265 if (count > 0) 266 { 267 return true; 268 } 269 270 return false; 271 } 272 catch (NumberFormatException ex) 273 { 274 return false; 275 } 276 } 277 } 278 catch (Exception ex) 279 { 280 return false; 281 } 282 } 283 284 private boolean allOperatorsBusy(String user) 285 { 286 RemoteAccessClient cl = (RemoteAccessClient)getServletContext().getAttribute("remoteAccess"); 287 if (cl == null) 288 { 289 return true; 290 } 291 292 try 293 { 294 String val = cl.getRemoteAccess().getParam("com.quikj.application.web.talk.feature.operator.Operator:" 295 + user, 296 "all-operators-busy"); 297 if (val == null) 298 { 299 return true; 300 } 301 else 302 { 303 if (val.equals("false") == true) 304 { 305 return false; 306 } 307 else 308 { 309 return true; 310 } 311 } 312 } 313 catch (Exception ex) 314 { 315 return true; 316 } 317 } 318 319 } 320 | Popular Tags |