List of usage examples for javax.mail.internet AddressException getMessage
public String getMessage()
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSMWar.CFAsteriskSMWarCreateNewAccountHtml.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) *///from w w w . j a va 2s.c om protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String S_ProcName = "doPost"; ICFAsteriskSchemaObj schemaObj; HttpSession sess = request.getSession(false); if (sess == null) { sess = request.getSession(true); schemaObj = new CFAsteriskSchemaPooledObj(); sess.setAttribute("SchemaObj", schemaObj); } else { schemaObj = (ICFAsteriskSchemaObj) sess.getAttribute("SchemaObj"); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "schemaObj"); } } ICFAsteriskSchema dbSchema = null; try { CFSecurityAuthorization auth = schemaObj.getAuthorization(); if (auth != null) { response.sendRedirect("CFAsteriskSMWarSecurityMainHtml"); return; } dbSchema = (ICFAsteriskSchema) CFAsteriskSchemaPool.getSchemaPool().getInstance(); schemaObj.setBackingStore(dbSchema); schemaObj.beginTransaction(); ICFSecuritySecUserObj systemUser = schemaObj.getSecUserTableObj().readSecUserByULoginIdx("system"); String passwordHash = systemUser.getRequiredPasswordHash(); if ((passwordHash == null) || (passwordHash.length() <= 0) || passwordHash.equals("bootstrap")) { response.sendRedirect("CFAsteriskSMWarSetSystemPasswordHtml"); return; } ICFSecurityClusterObj resolvedCluster; ICFSecuritySysClusterObj sysCluster = schemaObj.getSysClusterTableObj().readSysClusterByIdIdx(1, false); if (sysCluster == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "sysCluster"); } resolvedCluster = sysCluster.getRequiredContainerCluster(); if (resolvedCluster == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, "resolvedCluster"); } String clusterDomainName = resolvedCluster.getRequiredFullDomainName(); String clusterDescription = resolvedCluster.getRequiredDescription(); String loginId = (String) request.getParameter("LoginId"); if ((loginId == null) || (loginId.length() <= 0)) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAsteriskSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); out.println("Login Id must be specified."); out.println("<H2 style=\"text-align:center\">Create New Account</H2>"); out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAsteriskSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } String emailAddress = (String) request.getParameter("EMailAddress"); if ((emailAddress == null) || (emailAddress.length() <= 0)) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAsteriskSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); out.println("EMail Address must be specified."); out.println("<H2 style=\"text-align:center\">Create New Account</H2>"); out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAsteriskSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } ICFSecuritySecUserObj existingUser = schemaObj.getSecUserTableObj().readSecUserByULoginIdx(loginId, true); if (existingUser != null) { if (null != existingUser.getOptionalEMailConfirmationUuid()) { sendConfirmationEMail(request, existingUser, resolvedCluster); } response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAsteriskSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); if (null != existingUser.getOptionalEMailConfirmationUuid()) { out.println("User id \"" + loginId + "\" has already been registered. The confirmation email has been resent."); } else { out.println("User id \"" + loginId + "\" is already in use."); } out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); if (null == existingUser.getOptionalEMailConfirmationUuid()) { out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); } out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAsteriskSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } String password = (String) request.getParameter("Password"); if ((password == null) || (password.length() <= 0)) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAsteriskSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); out.println("Password must be specified."); out.println("<H2 style=\"text-align:center\">Create New Account</H2>"); out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAsteriskSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } String confirmPassword = (String) request.getParameter("ConfirmPassword"); if ((confirmPassword == null) || (confirmPassword.length() <= 0)) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAsteriskSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); out.println("Confirmation Password must be specified."); out.println("<H2 style=\"text-align:center\">Create New Account</H2>"); out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAsteriskSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } if (!confirmPassword.equals(password)) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAsteriskSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); out.println("Password and Confirmation Password do not match."); out.println("<H2 style=\"text-align:center\">Create New Account</H2>"); out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAsteriskSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } MessageDigest msgDigest = MessageDigest.getInstance("SHA-512"); msgDigest.update(password.getBytes("UTF-8")); byte[] hash = msgDigest.digest(); byte[] encodedHash = Base64.encodeBase64(hash); msgDigest.update(encodedHash); hash = msgDigest.digest(); encodedHash = Base64.encodeBase64(hash); String hashedAndEncodedPassword = new String(encodedHash); ICFSecurityClusterObj systemCluster = schemaObj.getClusterTableObj() .readClusterByUDomainNameIdx("system"); ICFSecurityTenantObj systemTenant = schemaObj.getTenantTableObj() .readTenantByUNameIdx(systemCluster.getRequiredId(), "system"); ICFSecuritySecSessionObj systemSession = schemaObj.getSecSessionTableObj().newInstance(); ICFSecuritySecSessionEditObj editSystemSession = (ICFSecuritySecSessionEditObj) systemSession .beginEdit(); editSystemSession.setRequiredContainerSecUser(systemUser); editSystemSession.setRequiredStart(Calendar.getInstance()); systemSession = editSystemSession.create(); editSystemSession.endEdit(); auth = new CFSecurityAuthorization(); auth.setSecCluster(systemCluster); auth.setSecTenant(systemTenant); auth.setSecSession(systemSession); schemaObj.setAuthorization(auth); ICFSecuritySecUserObj newUser = schemaObj.getSecUserTableObj().newInstance(); ICFSecuritySecUserEditObj editUser = (ICFSecuritySecUserEditObj) newUser.beginEdit(); editUser.setRequiredLoginId(loginId); editUser.setRequiredEMailAddress(emailAddress); editUser.setRequiredPasswordHash(hashedAndEncodedPassword); editUser.setOptionalEMailConfirmationUuid(UUID.randomUUID()); newUser = editUser.create(); editUser.endEdit(); editSystemSession = (ICFSecuritySecSessionEditObj) systemSession.beginEdit(); editSystemSession.setOptionalFinish(Calendar.getInstance()); editSystemSession.update(); editSystemSession.endEdit(); schemaObj.commit(); schemaObj.setAuthorization(null); sendConfirmationEMail(request, newUser, resolvedCluster); response.sendRedirect("CFAsteriskSMWarLoginHtml"); } catch (AddressException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Caught AddressException -- " + e.getMessage(), e); } catch (MessagingException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Caught MessagingException -- " + e.getMessage(), e); } catch (NamingException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Caught NamingException -- " + e.getMessage(), e); } catch (NoSuchAlgorithmException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Caught NoSuchAlgorithmException -- " + e.getMessage(), e); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Caught RuntimeException -- " + e.getMessage(), e); } finally { if (dbSchema != null) { try { if (schemaObj.isTransactionOpen()) { schemaObj.rollback(); } } catch (RuntimeException e) { } schemaObj.setBackingStore(null); CFAsteriskSchemaPool.getSchemaPool().releaseInstance(dbSchema); } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstSMWar.CFAstSMWarCreateNewAccountHtml.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) *///from w w w.ja v a2 s . c o m protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String S_ProcName = "doPost"; ICFAstSchemaObj schemaObj; HttpSession sess = request.getSession(false); if (sess == null) { sess = request.getSession(true); schemaObj = new CFAstSchemaObj(); sess.setAttribute("SchemaObj", schemaObj); } else { schemaObj = (ICFAstSchemaObj) sess.getAttribute("SchemaObj"); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "schemaObj"); } } ICFAstSchema dbSchema = null; try { CFAstAuthorization auth = schemaObj.getAuthorization(); if (auth != null) { response.sendRedirect("CFAstSMWarSecurityMainHtml"); return; } dbSchema = CFAstSchemaPool.getSchemaPool().getInstance(); schemaObj.setBackingStore(dbSchema); schemaObj.beginTransaction(); ICFAstSecUserObj systemUser = schemaObj.getSecUserTableObj().readSecUserByULoginIdx("system"); String passwordHash = systemUser.getRequiredPasswordHash(); if ((passwordHash == null) || (passwordHash.length() <= 0) || passwordHash.equals("bootstrap")) { response.sendRedirect("CFAstSMWarSetSystemPasswordHtml"); return; } ICFAstClusterObj resolvedCluster; ICFAstSysClusterObj sysCluster = schemaObj.getSysClusterTableObj().readSysClusterByIdIdx(1, false); if (sysCluster == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "sysCluster"); } resolvedCluster = sysCluster.getRequiredContainerCluster(); if (resolvedCluster == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, "resolvedCluster"); } String clusterDomainName = resolvedCluster.getRequiredFullDomainName(); String clusterDescription = resolvedCluster.getRequiredDescription(); String loginId = (String) request.getParameter("LoginId"); if ((loginId == null) || (loginId.length() <= 0)) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAstSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); out.println("Login Id must be specified."); out.println("<H2 style=\"text-align:center\">Create New Account</H2>"); out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAstSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } String emailAddress = (String) request.getParameter("EMailAddress"); if ((emailAddress == null) || (emailAddress.length() <= 0)) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAstSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); out.println("EMail Address must be specified."); out.println("<H2 style=\"text-align:center\">Create New Account</H2>"); out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAstSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } ICFAstSecUserObj existingUser = schemaObj.getSecUserTableObj().readSecUserByULoginIdx(loginId, true); if (existingUser != null) { if (null != existingUser.getOptionalEMailConfirmationUuid()) { sendConfirmationEMail(request, existingUser, resolvedCluster); } response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAstSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); if (null != existingUser.getOptionalEMailConfirmationUuid()) { out.println("User id \"" + loginId + "\" has already been registered. The confirmation email has been resent."); } else { out.println("User id \"" + loginId + "\" is already in use."); } out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); if (null == existingUser.getOptionalEMailConfirmationUuid()) { out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); } out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAstSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } String password = (String) request.getParameter("Password"); if ((password == null) || (password.length() <= 0)) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAstSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); out.println("Password must be specified."); out.println("<H2 style=\"text-align:center\">Create New Account</H2>"); out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAstSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } String confirmPassword = (String) request.getParameter("ConfirmPassword"); if ((confirmPassword == null) || (confirmPassword.length() <= 0)) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAstSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); out.println("Confirmation Password must be specified."); out.println("<H2 style=\"text-align:center\">Create New Account</H2>"); out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAstSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } if (!confirmPassword.equals(password)) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">"); out.println("<HTML>"); out.println("<BODY>"); out.println("<form method=\"post\" formaction=\"CFAstSMWarCreateNewAccountHtml\">"); out.println("<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>"); out.println("<H2 style=\"text-align:center\">ERROR</H2>"); out.println("<p style=\"text-align:center\">"); out.println("Password and Confirmation Password do not match."); out.println("<H2 style=\"text-align:center\">Create New Account</H2>"); out.println("<p>"); out.println("<center>"); out.println("<table style=\"width:75%\">"); out.println( "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">EMail Address:</th><td><input type=\"text\" name=\"EMailAddress\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Password:</th><td><input type=\"password\" name=\"Password\"/></td></tr>"); out.println( "<tr><th style=\"text-align:left\">Confirm Password:</th><td><input type=\"password\" name=\"ConfirmPassword\"/></td></tr>"); out.println( "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok\"\">Create Account</button></td></tr>"); out.println( "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAstSMWarLoginHtml\">Back to " + clusterDescription + " Security Manager Login</A></td></tr>"); out.println("</table>"); out.println("</center>"); out.println("</form>"); out.println("</BODY>"); out.println("</HTML>"); return; } MessageDigest msgDigest = MessageDigest.getInstance("SHA-512"); msgDigest.update(password.getBytes("UTF-8")); byte[] hash = msgDigest.digest(); byte[] encodedHash = Base64.encodeBase64(hash); msgDigest.update(encodedHash); hash = msgDigest.digest(); encodedHash = Base64.encodeBase64(hash); String hashedAndEncodedPassword = new String(encodedHash); ICFAstClusterObj systemCluster = schemaObj.getClusterTableObj().readClusterByUDomainNameIdx("system"); ICFAstTenantObj systemTenant = schemaObj.getTenantTableObj() .readTenantByUNameIdx(systemCluster.getRequiredId(), "system"); ICFAstSecSessionObj systemSession = schemaObj.getSecSessionTableObj().newInstance(); ICFAstSecSessionEditObj editSystemSession = (ICFAstSecSessionEditObj) systemSession.beginEdit(); editSystemSession.setRequiredContainerSecUser(systemUser); editSystemSession.setRequiredStart(Calendar.getInstance()); systemSession = editSystemSession.create(); editSystemSession.endEdit(); auth = new CFAstAuthorization(); auth.setSecCluster(systemCluster); auth.setSecTenant(systemTenant); auth.setSecSession(systemSession); schemaObj.setAuthorization(auth); ICFAstSecUserObj newUser = schemaObj.getSecUserTableObj().newInstance(); ICFAstSecUserEditObj editUser = (ICFAstSecUserEditObj) newUser.beginEdit(); editUser.setRequiredLoginId(loginId); editUser.setRequiredEMailAddress(emailAddress); editUser.setRequiredPasswordHash(hashedAndEncodedPassword); editUser.setOptionalEMailConfirmationUuid(UUID.randomUUID()); newUser = editUser.create(); editUser.endEdit(); editSystemSession = (ICFAstSecSessionEditObj) systemSession.beginEdit(); editSystemSession.setOptionalFinish(Calendar.getInstance()); editSystemSession.update(); editSystemSession.endEdit(); schemaObj.commit(); schemaObj.setAuthorization(null); sendConfirmationEMail(request, newUser, resolvedCluster); response.sendRedirect("CFAstSMWarLoginHtml"); } catch (AddressException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Caught AddressException -- " + e.getMessage(), e); } catch (MessagingException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Caught MessagingException -- " + e.getMessage(), e); } catch (NamingException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Caught NamingException -- " + e.getMessage(), e); } catch (NoSuchAlgorithmException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Caught NoSuchAlgorithmException -- " + e.getMessage(), e); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Caught RuntimeException -- " + e.getMessage(), e); } finally { if (dbSchema != null) { try { if (schemaObj.isTransactionOpen()) { schemaObj.rollback(); } } catch (RuntimeException e) { } schemaObj.setBackingStore(null); CFAstSchemaPool.getSchemaPool().releaseInstance(dbSchema); } } }
From source file:eionet.cr.harvest.BaseHarvest.java
/** * * @param messageBody/*from w w w .java 2 s .c om*/ */ private void sendErrorMessage(String messageBody) { String subject = "Error(s) when harvesting " + contextUrl; // Send to to those listed in this source's e-mails list. try { String[] emailReceivers = getContextSourceEmailReceivers(); if (emailReceivers != null && emailReceivers.length > 0) { EMailSender.send(emailReceivers, subject, messageBody, false); } } catch (AddressException e) { LOGGER.error("E-mail address formatting error: " + e.getMessage()); } catch (MessagingException e) { LOGGER.error("E-mail sending error", e); } // Send to sys-admins. try { EMailSender.sendToSysAdmin(subject, messageBody); } catch (AddressException e) { LOGGER.error("E-mail address formatting error: " + e.getMessage()); } catch (MessagingException e) { LOGGER.error("E-mail sending error", e); } }
From source file:org.unitime.timetable.events.SaveEventBackend.java
@Override public SaveOrApproveEventRpcResponse execute(SaveEventRpcRequest request, EventContext context) { if (request.getEvent().hasContact() && (request.getEvent().getContact().getExternalId() == null || !request .getEvent().getContact().getExternalId().equals(context.getUser().getExternalUserId()))) { switch (request.getEvent().getType()) { case Special: case Course: case Unavailabile: context.checkPermission(Right.EventLookupContact); }/*from w w w . j av a 2s.c om*/ } if (request.getEvent().getId() == null) { // new even switch (request.getEvent().getType()) { case Special: context.checkPermission(Right.EventAddSpecial); break; case Course: context.checkPermission(Right.EventAddCourseRelated); break; case Unavailabile: context.checkPermission(Right.EventAddUnavailable); break; default: throw context.getException(); } } else { // existing event context.checkPermission(request.getEvent().getId(), "Event", Right.EventEdit); } // Check main contact email if (request.getEvent().hasContact() && request.getEvent().getContact().hasEmail()) { try { new InternetAddress(request.getEvent().getContact().getEmail(), true); } catch (AddressException e) { throw new GwtRpcException( MESSAGES.badEmailAddress(request.getEvent().getContact().getEmail(), e.getMessage())); } } // Check additional emails if (request.getEvent().hasEmail()) { String suffix = ApplicationProperty.EmailDefaultAddressSuffix.value(); for (String address : request.getEvent().getEmail().split("[\n,]")) { String email = address.trim(); if (email.isEmpty()) continue; if (suffix != null && email.indexOf('@') < 0) email += suffix; try { new InternetAddress(email, true); } catch (AddressException e) { throw new GwtRpcException(MESSAGES.badEmailAddress(address, e.getMessage())); } } } org.hibernate.Session hibSession = SessionDAO.getInstance().getSession(); Transaction tx = hibSession.beginTransaction(); try { Session session = SessionDAO.getInstance().get(request.getSessionId(), hibSession); Date now = new Date(); Event event = null; if (request.getEvent().getId() != null) { event = EventDAO.getInstance().get(request.getEvent().getId(), hibSession); } else { switch (request.getEvent().getType()) { case Special: event = new SpecialEvent(); break; case Course: event = new CourseEvent(); break; case Unavailabile: event = new UnavailableEvent(); break; default: throw new GwtRpcException( MESSAGES.failedSaveEventWrongType(request.getEvent().getType().getName(CONSTANTS))); } } SaveOrApproveEventRpcResponse response = new SaveOrApproveEventRpcResponse(); event.setEventName(request.getEvent().getName()); if (event.getEventName() == null || event.getEventName().isEmpty() && request.getEvent().getType() == EventType.Unavailabile) event.setEventName(MESSAGES.unavailableEventDefaultName()); event.setEmail(request.getEvent().getEmail()); if (context.hasPermission(Right.EventSetExpiration) || event.getExpirationDate() != null) event.setExpirationDate(request.getEvent().getExpirationDate()); event.setSponsoringOrganization(request.getEvent().hasSponsor() ? SponsoringOrganizationDAO.getInstance().get(request.getEvent().getSponsor().getUniqueId()) : null); if (event instanceof UnavailableEvent) { } else if (event instanceof SpecialEvent) { event.setMinCapacity(request.getEvent().getMaxCapacity()); event.setMaxCapacity(request.getEvent().getMaxCapacity()); } if (event.getAdditionalContacts() == null) { event.setAdditionalContacts(new HashSet<EventContact>()); } if (context.hasPermission(Right.EventLookupContact)) { Set<EventContact> existingContacts = new HashSet<EventContact>(event.getAdditionalContacts()); event.getAdditionalContacts().clear(); if (request.getEvent().hasAdditionalContacts()) for (ContactInterface c : request.getEvent().getAdditionalContacts()) { if (c.getExternalId() == null) continue; EventContact contact = null; for (EventContact x : existingContacts) if (c.getExternalId().equals(x.getExternalUniqueId())) { contact = x; break; } if (contact == null) { contact = (EventContact) hibSession .createQuery("from EventContact where externalUniqueId = :externalId") .setString("externalId", c.getExternalId()).setMaxResults(1).uniqueResult(); } if (contact == null) { contact = new EventContact(); contact.setExternalUniqueId(c.getExternalId()); contact.setFirstName(c.getFirstName()); contact.setMiddleName(c.getMiddleName()); contact.setLastName(c.getLastName()); contact.setAcademicTitle(c.getAcademicTitle()); contact.setEmailAddress(c.getEmail()); contact.setPhone(c.getPhone()); hibSession.save(contact); } event.getAdditionalContacts().add(contact); } } EventContact main = event.getMainContact(); if (main == null || main.getExternalUniqueId() == null || !main.getExternalUniqueId().equals(request.getEvent().getContact().getExternalId())) { main = (EventContact) hibSession .createQuery("from EventContact where externalUniqueId = :externalId") .setString("externalId", request.getEvent().getContact().getExternalId()).setMaxResults(1) .uniqueResult(); if (main == null) { main = new EventContact(); main.setExternalUniqueId(request.getEvent().getContact().getExternalId()); } } main.setFirstName(request.getEvent().getContact().getFirstName()); main.setMiddleName(request.getEvent().getContact().getMiddleName()); main.setLastName(request.getEvent().getContact().getLastName()); main.setAcademicTitle(request.getEvent().getContact().getAcademicTitle()); main.setEmailAddress(request.getEvent().getContact().getEmail()); main.setPhone(request.getEvent().getContact().getPhone()); hibSession.saveOrUpdate(main); event.setMainContact(main); if (event.getNotes() == null) event.setNotes(new HashSet<EventNote>()); if (event.getMeetings() == null) event.setMeetings(new HashSet<Meeting>()); Set<Meeting> remove = new HashSet<Meeting>(event.getMeetings()); TreeSet<Meeting> createdMeetings = new TreeSet<Meeting>(); Set<Meeting> cancelledMeetings = new TreeSet<Meeting>(); Set<Meeting> updatedMeetings = new TreeSet<Meeting>(); for (MeetingInterface m : request.getEvent().getMeetings()) { Meeting meeting = null; if (m.getApprovalStatus() == ApprovalStatus.Deleted) { if (!context.hasPermission(meeting, Right.EventMeetingDelete) && context.hasPermission(meeting, Right.EventMeetingCancel)) { // Cannot delete, but can cancel --> cancel the meeting instead m.setApprovalStatus(ApprovalStatus.Cancelled); } else { continue; } } if (m.getId() != null) for (Iterator<Meeting> i = remove.iterator(); i.hasNext();) { Meeting x = i.next(); if (m.getId().equals(x.getUniqueId())) { meeting = x; i.remove(); break; } } if (meeting != null) { if (m.getApprovalStatus().ordinal() != meeting.getApprovalStatus()) { switch (m.getApprovalStatus()) { case Cancelled: switch (meeting.getEvent().getEventType()) { case Event.sEventTypeFinalExam: case Event.sEventTypeMidtermExam: if (!context.hasPermission(meeting, Right.EventMeetingCancelExam)) throw new GwtRpcException( MESSAGES.failedApproveEventNoRightsToCancel(toString(meeting))); break; case Event.sEventTypeClass: if (!context.hasPermission(meeting, Right.EventMeetingCancelClass)) throw new GwtRpcException( MESSAGES.failedApproveEventNoRightsToCancel(toString(meeting))); break; default: if (!context.hasPermission(meeting, Right.EventMeetingCancel)) throw new GwtRpcException( MESSAGES.failedApproveEventNoRightsToCancel(toString(meeting))); break; } meeting.setStatus(Meeting.Status.CANCELLED); meeting.setApprovalDate(now); hibSession.update(meeting); cancelledMeetings.add(meeting); response.addCancelledMeeting(m); } } else { if (m.getStartOffset() != (meeting.getStartOffset() == null ? 0 : meeting.getStartOffset()) || m.getEndOffset() != (meeting.getStopOffset() == null ? 0 : meeting.getStopOffset())) { if (!context.hasPermission(meeting, Right.EventMeetingEdit)) throw new GwtRpcException( MESSAGES.failedSaveEventCanNotEditMeeting(toString(meeting))); meeting.setStartOffset(m.getStartOffset()); meeting.setStopOffset(m.getEndOffset()); hibSession.update(meeting); response.addUpdatedMeeting(m); updatedMeetings.add(meeting); } } } else { response.addCreatedMeeting(m); meeting = new Meeting(); meeting.setEvent(event); Location location = null; if (m.hasLocation()) { if (m.getLocation().getId() != null) location = LocationDAO.getInstance().get(m.getLocation().getId(), hibSession); else if (m.getLocation().getName() != null) location = Location.findByName(hibSession, request.getSessionId(), m.getLocation().getName()); } if (location == null) throw new GwtRpcException(MESSAGES.failedSaveEventNoLocation(toString(m))); meeting.setLocationPermanentId(location.getPermanentId()); meeting.setStatus(Meeting.Status.PENDING); meeting.setApprovalDate(null); if (!context.hasPermission(location, Right.EventLocation)) throw new GwtRpcException(MESSAGES.failedSaveEventWrongLocation(m.getLocationName())); if (request.getEvent().getType() == EventType.Unavailabile && !context.hasPermission(location, Right.EventLocationUnavailable)) throw new GwtRpcException(MESSAGES.failedSaveCannotMakeUnavailable(m.getLocationName())); if (m.getApprovalStatus() == ApprovalStatus.Approved && context.hasPermission(location, Right.EventLocationApprove)) { meeting.setStatus(Meeting.Status.APPROVED); meeting.setApprovalDate(now); } if (context.isPastOrOutside(m.getMeetingDate())) throw new GwtRpcException( MESSAGES.failedSaveEventPastOrOutside(getDateFormat().format(m.getMeetingDate()))); if (!context.hasPermission(location, Right.EventLocationOverbook)) { List<MeetingConflictInterface> conflicts = computeConflicts(hibSession, m, event.getUniqueId()); if (!conflicts.isEmpty()) throw new GwtRpcException( MESSAGES.failedSaveEventConflict(toString(m), toString(conflicts.get(0)))); } m.setApprovalDate(meeting.getApprovalDate()); m.setApprovalStatus(meeting.getApprovalStatus()); meeting.setStartPeriod(m.getStartSlot()); meeting.setStopPeriod(m.getEndSlot()); meeting.setStartOffset(m.getStartOffset()); meeting.setStopOffset(m.getEndOffset()); meeting.setClassCanOverride(true); meeting.setMeetingDate(m.getMeetingDate()); event.getMeetings().add(meeting); createdMeetings.add(meeting); } // automatic approval if (meeting.getApprovalDate() == null) { switch (request.getEvent().getType()) { case Unavailabile: case Class: case FinalExam: case MidtermExam: meeting.setStatus(Meeting.Status.APPROVED); meeting.setApprovalDate(now); break; } } } if (!remove.isEmpty()) { for (Iterator<Meeting> i = remove.iterator(); i.hasNext();) { Meeting m = i.next(); if (!context.hasPermission(m, Right.EventMeetingDelete)) { if (m.getStatus() == Status.CANCELLED || m.getStatus() == Status.REJECTED) { i.remove(); continue; } throw new GwtRpcException(MESSAGES.failedSaveEventCanNotDeleteMeeting(toString(m))); } MeetingInterface meeting = new MeetingInterface(); meeting.setId(m.getUniqueId()); meeting.setMeetingDate(m.getMeetingDate()); meeting.setDayOfWeek(Constants.getDayOfWeek(m.getMeetingDate())); meeting.setStartTime(m.getStartTime().getTime()); meeting.setStopTime(m.getStopTime().getTime()); meeting.setDayOfYear( CalendarUtils.date2dayOfYear(session.getSessionStartYear(), m.getMeetingDate())); meeting.setStartSlot(m.getStartPeriod()); meeting.setEndSlot(m.getStopPeriod()); meeting.setStartOffset(m.getStartOffset() == null ? 0 : m.getStartOffset()); meeting.setEndOffset(m.getStopOffset() == null ? 0 : m.getStopOffset()); meeting.setPast(context.isPastOrOutside(m.getStartTime())); meeting.setApprovalDate(m.getApprovalDate()); meeting.setApprovalStatus(m.getApprovalStatus()); if (m.getLocation() != null) { ResourceInterface location = new ResourceInterface(); location.setType(ResourceType.ROOM); location.setId(m.getLocation().getUniqueId()); location.setName(m.getLocation().getLabel()); location.setSize(m.getLocation().getCapacity()); location.setRoomType(m.getLocation().getRoomTypeLabel()); location.setBreakTime(m.getLocation().getEffectiveBreakTime()); location.setMessage(m.getLocation().getEventMessage()); location.setIgnoreRoomCheck(m.getLocation().isIgnoreRoomCheck()); meeting.setLocation(location); } response.addDeletedMeeting(meeting); } event.getMeetings().removeAll(remove); } EventInterface.DateFormatter df = new EventInterface.DateFormatter() { Formats.Format<Date> dfShort = Formats.getDateFormat(Formats.Pattern.DATE_EVENT_SHORT); Formats.Format<Date> dfLong = Formats.getDateFormat(Formats.Pattern.DATE_EVENT_LONG); @Override public String formatFirstDate(Date date) { return dfShort.format(date); } @Override public String formatLastDate(Date date) { return dfLong.format(date); } }; FileItem attachment = (FileItem) context.getAttribute(UploadServlet.SESSION_LAST_FILE); boolean attached = false; if (response.hasCreatedMeetings()) { EventNote note = new EventNote(); note.setEvent(event); note.setNoteType(event.getUniqueId() == null ? EventNote.sEventNoteTypeCreateEvent : EventNote.sEventNoteTypeAddMeetings); note.setTimeStamp(now); note.setUser(context.getUser().getTrueName()); note.setUserId(context.getUser().getTrueExternalUserId()); if (request.hasMessage()) note.setTextNote(request.getMessage()); note.setMeetings(EventInterface.toString(response.getCreatedMeetings(), CONSTANTS, "\n", df)); note.setAffectedMeetings(createdMeetings); event.getNotes().add(note); NoteInterface n = new NoteInterface(); n.setDate(now); n.setMeetings(note.getMeetings()); n.setUser(context.getUser().getTrueName()); n.setType(NoteInterface.NoteType.values()[note.getNoteType()]); n.setNote(note.getTextNote()); if (attachment != null) { note.setAttachedName(attachment.getName()); note.setAttachedFile(attachment.get()); note.setAttachedContentType(attachment.getContentType()); attached = true; n.setAttachment(attachment.getName()); } response.addNote(n); } if (response.hasUpdatedMeetings() || (!response.hasCreatedMeetings() && !response.hasDeletedMeetings() && !response.hasCancelledMeetings())) { EventNote note = new EventNote(); note.setEvent(event); note.setNoteType(EventNote.sEventNoteTypeEditEvent); note.setTimeStamp(now); note.setUser(context.getUser().getTrueName()); note.setUserId(context.getUser().getTrueExternalUserId()); note.setAffectedMeetings(updatedMeetings); if (request.hasMessage()) note.setTextNote(request.getMessage()); if (response.hasUpdatedMeetings()) note.setMeetings(EventInterface.toString(response.getUpdatedMeetings(), CONSTANTS, "\n", df)); event.getNotes().add(note); NoteInterface n = new NoteInterface(); n.setDate(now); n.setMeetings(note.getMeetings()); n.setUser(context.getUser().getTrueName()); n.setType(NoteInterface.NoteType.values()[note.getNoteType()]); n.setNote(note.getTextNote()); if (attachment != null && !attached) { note.setAttachedName(attachment.getName()); note.setAttachedFile(attachment.get()); note.setAttachedContentType(attachment.getContentType()); attached = true; n.setAttachment(attachment.getName()); } response.addNote(n); } if (response.hasDeletedMeetings()) { EventNote note = new EventNote(); note.setEvent(event); note.setNoteType(EventNote.sEventNoteTypeDeletion); note.setTimeStamp(now); note.setUser(context.getUser().getTrueName()); note.setUserId(context.getUser().getTrueExternalUserId()); if (request.hasMessage()) note.setTextNote(request.getMessage()); note.setMeetings(EventInterface.toString(response.getDeletedMeetings(), CONSTANTS, "\n", df)); event.getNotes().add(note); NoteInterface n = new NoteInterface(); n.setDate(now); n.setMeetings(note.getMeetings()); n.setUser(context.getUser().getTrueName()); n.setType(NoteInterface.NoteType.values()[note.getNoteType()]); n.setNote(note.getTextNote()); if (attachment != null && !attached) { note.setAttachedName(attachment.getName()); note.setAttachedFile(attachment.get()); note.setAttachedContentType(attachment.getContentType()); attached = true; n.setAttachment(attachment.getName()); } response.addNote(n); } if (response.hasCancelledMeetings()) { EventNote note = new EventNote(); note.setEvent(event); note.setNoteType(EventNote.sEventNoteTypeCancel); note.setTimeStamp(now); note.setUser(context.getUser().getTrueName()); note.setUserId(context.getUser().getTrueExternalUserId()); note.setAffectedMeetings(cancelledMeetings); if (request.hasMessage()) note.setTextNote(request.getMessage()); note.setMeetings(EventInterface.toString(response.getCancelledMeetings(), CONSTANTS, "\n", df)); event.getNotes().add(note); NoteInterface n = new NoteInterface(); n.setDate(now); n.setMeetings(note.getMeetings()); n.setUser(context.getUser().getTrueName()); n.setType(NoteInterface.NoteType.values()[note.getNoteType()]); n.setNote(note.getTextNote()); if (attachment != null && !attached) { note.setAttachedName(attachment.getName()); note.setAttachedFile(attachment.get()); note.setAttachedContentType(attachment.getContentType()); attached = true; n.setAttachment(attachment.getName()); } response.addNote(n); } if (request.getEvent().getType() == EventType.Course) { CourseEvent ce = (CourseEvent) event; ce.setReqAttendance(request.getEvent().hasRequiredAttendance()); if (ce.getRelatedCourses() == null) ce.setRelatedCourses(new HashSet<RelatedCourseInfo>()); else ce.getRelatedCourses().clear(); if (request.getEvent().hasRelatedObjects()) for (RelatedObjectInterface r : request.getEvent().getRelatedObjects()) { RelatedCourseInfo related = new RelatedCourseInfo(); related.setEvent(ce); if (r.getSelection() != null) { related.setOwnerId(r.getUniqueId()); related.setOwnerType(r.getType().ordinal()); related.setCourse(CourseOfferingDAO.getInstance().get(r.getSelection()[1], hibSession)); } else { switch (r.getType()) { case Course: related.setOwner(CourseOfferingDAO.getInstance().get(r.getUniqueId())); break; case Class: related.setOwner(Class_DAO.getInstance().get(r.getUniqueId())); break; case Config: related.setOwner(InstrOfferingConfigDAO.getInstance().get(r.getUniqueId())); break; case Offering: related.setOwner(InstructionalOfferingDAO.getInstance().get(r.getUniqueId())); break; } } ce.getRelatedCourses().add(related); } } if (event.getUniqueId() == null) { hibSession.save(event); response.setEvent(EventDetailBackend.getEventDetail( SessionDAO.getInstance().get(request.getSessionId(), hibSession), event, context)); } else if (event.getMeetings().isEmpty()) { response.setEvent(EventDetailBackend.getEventDetail( SessionDAO.getInstance().get(request.getSessionId(), hibSession), event, context)); response.getEvent().setId(null); hibSession.delete(event); } else { hibSession.update(event); response.setEvent(EventDetailBackend.getEventDetail( SessionDAO.getInstance().get(request.getSessionId(), hibSession), event, context)); } tx.commit(); new EventEmail(request, response).send(context); return response; } catch (Exception ex) { tx.rollback(); if (ex instanceof GwtRpcException) throw (GwtRpcException) ex; throw new GwtRpcException(ex.getMessage(), ex); } }
From source file:org.etudes.jforum.util.mail.TopicSpammer.java
public TopicSpammer(Topic topic, Post post, List users, String messageFile, List attachments) { // Prepare the users. In this current version, the email // is not personalized, so then we'll just use his address List recipients = new ArrayList(); for (Iterator iter = users.iterator(); iter.hasNext();) { User u = (User) iter.next();/*from w ww . ja v a 2 s. com*/ try { new InternetAddress(u.getEmail()); } catch (AddressException e) { if (logger.isWarnEnabled()) logger.warn("TopicSpammer(...) : " + u.getEmail() + " is invalid. And exception is : " + e); continue; } recipients.add(u.getEmail()); } // Make the topic url String page = ""; // int postsPerPage = SystemGlobals.getIntValue(ConfigKeys.POST_PER_PAGE); int postsPerPage = SakaiSystemGlobals.getIntValue(ConfigKeys.POST_PER_PAGE); if (topic.getTotalReplies() > postsPerPage) { page += (((topic.getTotalReplies() / postsPerPage)) * postsPerPage) + "/"; } SimpleHash params = new SimpleHash(); if (logger.isDebugEnabled()) logger.debug("TopicSpammer- this is the CODE!"); String sitetitle = null; Site currentSite = null; try { currentSite = SiteService.getSite(ToolManager.getCurrentPlacement().getContext()); sitetitle = currentSite.getTitle(); } catch (Exception e) { logger.error(this.getClass().getName() + ".TopicSpammer() : " + e.getMessage(), e); } params.put("topic", topic); params.put("post", post); params.put("siteTitle", sitetitle); String topicFrom = ""; if (topic.getPostedBy() != null) { topicFrom = topic.getPostedBy().getFirstName() + " " + topic.getPostedBy().getLastName(); } params.put("topicFrom", topicFrom); StringBuilder siteNavUrl = new StringBuilder(); String portalUrl = ServerConfigurationService.getPortalUrl(); params.put("portalUrl", portalUrl); siteNavUrl.append(portalUrl); String currToolId = ToolManager.getCurrentPlacement().getId(); ToolConfiguration toolConfiguration = currentSite.getTool(currToolId); siteNavUrl.append("/"); siteNavUrl.append("site"); siteNavUrl.append("/"); siteNavUrl.append(Web.escapeUrl(currentSite.getId())); if (toolConfiguration != null) { siteNavUrl.append("/"); siteNavUrl.append("page"); siteNavUrl.append("/"); siteNavUrl.append(Web.escapeUrl(toolConfiguration.getPageId())); } //params.put("serverurl", siteNavUrl); params.put("siteToolUrl", siteNavUrl); Object obj[] = new String[] { sitetitle, topic.getTitle() }; if (attachments != null && attachments.size() > 0) { super.prepareAttachmentMessage(recipients, params, "[" + sitetitle + "] " + MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_SUBJECT), obj), SystemGlobals.getValue(messageFile), attachments); } else { super.prepareMessage(recipients, params, "[" + sitetitle + "] " + MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_SUBJECT), obj), SystemGlobals.getValue(messageFile)); } }
From source file:org.etudes.jforum.util.mail.TopicSpammer.java
public TopicSpammer(Topic topic, List users, String messageFile, Post post, List attachments) { // Prepare the users. In this current version, the email // is not personalized, so then we'll just use his address List recipients = new ArrayList(); for (Iterator iter = users.iterator(); iter.hasNext();) { User u = (User) iter.next();/* ww w . j a v a 2 s . co m*/ try { new InternetAddress(u.getEmail()); } catch (AddressException e) { if (logger.isWarnEnabled()) logger.warn("TopicSpammer(...) : " + u.getEmail() + " is invalid. And exception is : " + e); continue; } recipients.add(u.getEmail()); } // Make the topic url String page = ""; // int postsPerPage = SystemGlobals.getIntValue(ConfigKeys.POST_PER_PAGE); int postsPerPage = SakaiSystemGlobals.getIntValue(ConfigKeys.POST_PER_PAGE); if (topic.getTotalReplies() > postsPerPage) { page += (((topic.getTotalReplies() / postsPerPage)) * postsPerPage) + "/"; } SimpleHash params = new SimpleHash(); if (logger.isDebugEnabled()) logger.debug("TopicSpammer- this is the CODE!"); String sitetitle = null; Site currentSite = null; try { currentSite = SiteService.getSite(ToolManager.getCurrentPlacement().getContext()); sitetitle = currentSite.getTitle(); } catch (Exception e) { logger.error(this.getClass().getName() + ".TopicSpammer() : " + e.getMessage(), e); } params.put("topic", topic); params.put("post", post); params.put("siteTitle", sitetitle); String postfrom = ""; if (post.getFirstName() != null) { postfrom = post.getFirstName(); } if (post.getLastName() != null) { postfrom = postfrom + " " + post.getLastName(); } params.put("postfrom", postfrom); StringBuilder siteNavUrl = new StringBuilder(); String portalUrl = ServerConfigurationService.getPortalUrl(); siteNavUrl.append(portalUrl); String currToolId = ToolManager.getCurrentPlacement().getId(); ToolConfiguration toolConfiguration = currentSite.getTool(currToolId); siteNavUrl.append("/"); siteNavUrl.append("site"); siteNavUrl.append("/"); siteNavUrl.append(Web.escapeUrl(currentSite.getId())); if (toolConfiguration != null) { siteNavUrl.append("/"); siteNavUrl.append("page"); siteNavUrl.append("/"); siteNavUrl.append(Web.escapeUrl(toolConfiguration.getPageId())); } params.put("siteToolUrl", siteNavUrl); Object obj[] = new String[] { sitetitle, topic.getTitle() }; if (attachments != null && attachments.size() > 0) { super.prepareAttachmentMessage(recipients, params, //"[" + path + "] " + MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_SUBJECT), obj), MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_SUBJECT), obj), SystemGlobals.getValue(messageFile), attachments); } else { super.prepareMessage(recipients, params, //"[" + path + "] " + MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_SUBJECT), obj), MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_SUBJECT), obj), SystemGlobals.getValue(messageFile)); } }
From source file:org.sakaiproject.evaluation.logic.externals.EvalExternalLogicImpl.java
/** * Handle the actual sending of the email * @param fromAddress// w ww. jav a 2 s . c o m * @param toEmails * @param subject * @param message * @param deferExceptions * @param exceptionTracker * @return an array of all email addresses that were sent to */ private String[] sendEmails(InternetAddress fromAddress, List<String> toEmails, String subject, String message, boolean deferExceptions, String exceptionTracker) { InternetAddress[] replyTo = new InternetAddress[1]; List<InternetAddress> listAddresses = new ArrayList<>(); for (int i = 0; i < toEmails.size(); i++) { String email = toEmails.get(i); try { InternetAddress toAddress = new InternetAddress(email); listAddresses.add(toAddress); } catch (AddressException e) { if (deferExceptions) { exceptionTracker += e.getMessage() + " :: "; LOG.debug("Invalid to address (" + email + "), skipping it, error:(" + e + ")..."); if (LOG.isDebugEnabled()) { LOG.warn(e); } } else { // die here since we were unable to find this user at all throw new IllegalArgumentException("Invalid to address: " + email + ", cannot send emails", e); } } } replyTo[0] = fromAddress; InternetAddress[] toAddresses = listAddresses.toArray(new InternetAddress[listAddresses.size()]); // headers are set globally and used for all emails going out (see top of this file) // added to ensure non-blank TO header: http://bugs.sakaiproject.org/jira/browse/EVALSYS-724 emailService.sendMail(fromAddress, toAddresses, subject, message, new InternetAddress[] { fromAddress }, replyTo, this.emailHeaders); if (deferExceptions && exceptionTracker != null) { // exceptions occurred so we have to die here throw new IllegalArgumentException( "The following exceptions were deferred (full trace above in the log): " + "Sent emails to " + toAddresses.length + " addresses before failure ocurred: Failure summary: " + exceptionTracker); } // now we send back the list of people who the email was sent to String[] addresses = new String[toAddresses.length]; for (int i = 0; i < toAddresses.length; i++) { addresses[i] = toAddresses[i].getAddress(); } return addresses; }
From source file:org.silverpeas.core.mail.engine.SmtpMailSender.java
@Override public void send(final MailToSend mail) { SmtpConfiguration smtpConfiguration = SmtpConfiguration.fromDefaultSettings(); MailAddress fromMailAddress = mail.getFrom(); Session session = getMailSession(smtpConfiguration); try {/*from ww w . j av a 2 s .c om*/ InternetAddress fromAddress = fromMailAddress.getAuthorizedInternetAddress(); InternetAddress replyToAddress = null; List<InternetAddress[]> toAddresses = new ArrayList<>(); // Parsing destination address for compliance with RFC822. final Collection<ReceiverMailAddressSet> addressBatches = mail.getTo().getBatchedReceiversList(); for (ReceiverMailAddressSet addressBatch : addressBatches) { try { toAddresses.add(InternetAddress.parse(addressBatch.getEmailsSeparatedByComma(), false)); } catch (AddressException e) { SilverTrace.warn("mail", "MailSender.send()", "root.MSG_GEN_PARAM_VALUE", "From = " + fromMailAddress + ", To = " + addressBatch.getEmailsSeparatedByComma(), e); } } try { if (mail.isReplyToRequired()) { replyToAddress = new InternetAddress(fromMailAddress.getEmail(), false); if (StringUtil.isDefined(fromMailAddress.getName())) { replyToAddress.setPersonal(fromMailAddress.getName(), Charsets.UTF_8.name()); } } } catch (AddressException e) { SilverTrace.warn("mail", "MailSender.send()", "root.MSG_GEN_PARAM_VALUE", "ReplyTo = " + fromMailAddress + " is malformed.", e); } MimeMessage email = new MimeMessage(session); email.setFrom(fromAddress); if (replyToAddress != null) { email.setReplyTo(new InternetAddress[] { replyToAddress }); } email.setHeader("Precedence", "list"); email.setHeader("List-ID", fromAddress.getAddress()); email.setSentDate(new Date()); email.setSubject(mail.getSubject(), CharEncoding.UTF_8); mail.getContent().applyOn(email); // Sending. performSend(mail, smtpConfiguration, session, email, toAddresses); } catch (MessagingException | UnsupportedEncodingException e) { SilverLogger.getLogger(this).error(e.getMessage(), e); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.stratelia.silverpeas.notificationserver.channel.smtp.SMTPListener.java
/** * send email to destination using SMTP protocol and JavaMail 1.3 API (compliant with MIME * format)./*from w w w. j av a2 s .c o m*/ * * @param pFrom : from field that will appear in the email header. * @param personalName : * @see {@link InternetAddress} * @param pTo : the email target destination. * @param pSubject : the subject of the email. * @param pMessage : the message or payload of the email. */ private void sendEmail(String pFrom, String personalName, String pTo, String pSubject, String pMessage, boolean htmlFormat) throws NotificationServerException { // retrieves system properties and set up Delivery Status Notification // @see RFC1891 Properties properties = System.getProperties(); properties.put("mail.smtp.host", getMailServer()); properties.put("mail.smtp.auth", String.valueOf(isAuthenticated())); javax.mail.Session session = javax.mail.Session.getInstance(properties, null); session.setDebug(isDebug()); // print on the console all SMTP messages. Transport transport = null; try { InternetAddress fromAddress = getAuthorizedEmailAddress(pFrom, personalName); InternetAddress replyToAddress = null; InternetAddress[] toAddress = null; // parsing destination address for compliance with RFC822 try { toAddress = InternetAddress.parse(pTo, false); if (!AdminReference.getAdminService().getAdministratorEmail().equals(pFrom) && (!fromAddress.getAddress().equals(pFrom) || isForceReplyToSenderField())) { replyToAddress = new InternetAddress(pFrom, false); if (StringUtil.isDefined(personalName)) { replyToAddress.setPersonal(personalName, CharEncoding.UTF_8); } } } catch (AddressException e) { SilverTrace.warn("smtp", "SMTPListner.sendEmail()", "root.MSG_GEN_PARAM_VALUE", "From = " + pFrom + ", To = " + pTo); } MimeMessage email = new MimeMessage(session); email.setFrom(fromAddress); if (replyToAddress != null) { email.setReplyTo(new InternetAddress[] { replyToAddress }); } email.setRecipients(javax.mail.Message.RecipientType.TO, toAddress); email.setHeader("Precedence", "list"); email.setHeader("List-ID", fromAddress.getAddress()); String subject = pSubject; if (subject == null) { subject = ""; } String content = pMessage; if (content == null) { content = ""; } email.setSubject(subject, CharEncoding.UTF_8); if (content.toLowerCase().contains("<html>") || htmlFormat) { email.setContent(content, "text/html; charset=\"UTF-8\""); } else { email.setText(content, CharEncoding.UTF_8); } email.setSentDate(new Date()); // create a Transport connection (TCP) if (isSecure()) { transport = session.getTransport(SECURE_TRANSPORT); } else { transport = session.getTransport(SIMPLE_TRANSPORT); } if (isAuthenticated()) { SilverTrace.info("smtp", "SMTPListner.sendEmail()", "root.MSG_GEN_PARAM_VALUE", "Host = " + getMailServer() + " Port=" + getPort() + " User=" + getLogin()); transport.connect(getMailServer(), getPort(), getLogin(), getPassword()); } else { transport.connect(); } transport.sendMessage(email, toAddress); } catch (MessagingException e) { Logger.getLogger(getClass().getSimpleName()).log(Level.SEVERE, e.getMessage(), e); } catch (UnsupportedEncodingException e) { Logger.getLogger(getClass().getSimpleName()).log(Level.SEVERE, e.getMessage(), e); } catch (Exception e) { throw new NotificationServerException("SMTPListner.sendEmail()", SilverpeasException.ERROR, "smtp.EX_CANT_SEND_SMTP_MESSAGE", e); } finally { if (transport != null) { try { transport.close(); } catch (Exception e) { SilverTrace.error("smtp", "SMTPListner.sendEmail()", "root.EX_IGNORED", "ClosingTransport", e); } } } }
From source file:org.etudes.jforum.util.mail.TopicSpammer.java
public TopicSpammer(Topic topic, List users, String messageFile, Post post) { // Prepare the users. In this current version, the email // is not personalized, so then we'll just use his address List recipients = new ArrayList(); for (Iterator iter = users.iterator(); iter.hasNext();) { User u = (User) iter.next();/*from w ww. ja v a 2 s.c om*/ try { new InternetAddress(u.getEmail()); } catch (AddressException e) { if (logger.isWarnEnabled()) logger.warn("TopicSpammer(...) : " + u.getEmail() + " is invalid. And exception is : " + e); continue; } recipients.add(u.getEmail()); } // Make the topic url String page = ""; // int postsPerPage = SystemGlobals.getIntValue(ConfigKeys.POST_PER_PAGE); int postsPerPage = SakaiSystemGlobals.getIntValue(ConfigKeys.POST_PER_PAGE); if (topic.getTotalReplies() > postsPerPage) { page += (((topic.getTotalReplies() / postsPerPage)) * postsPerPage) + "/"; } //Mallika-comments beg /*String forumLink = SystemGlobals.getValue(ConfigKeys.FORUM_LINK); if (!forumLink.endsWith("/")) { forumLink += "/"; } String path = forumLink + "posts/list/" + page + topic.getId() + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION) + "#" + topic.getLastPostId(); String unwatch = forumLink + "posts/unwatch/" + topic.getId() + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION); */ //Mallika-comments end SimpleHash params = new SimpleHash(); if (logger.isDebugEnabled()) logger.debug("TopicSpammer- this is the CODE!"); //Mallika - new code beg String sitetitle = null; Site currentSite = null; try { currentSite = SiteService.getSite(ToolManager.getCurrentPlacement().getContext()); sitetitle = currentSite.getTitle(); } catch (Exception e) { //System.out.println("Exception thrown "+e.toString()); logger.error(this.getClass().getName() + ".TopicSpammer() : " + e.getMessage(), e); } //Mallika - new code end params.put("topic", topic); params.put("post", post); params.put("siteTitle", sitetitle); String postfrom = ""; if (post.getFirstName() != null) { postfrom = post.getFirstName(); } if (post.getLastName() != null) { postfrom = postfrom + " " + post.getLastName(); } params.put("postfrom", postfrom); StringBuilder siteNavUrl = new StringBuilder(); String portalUrl = ServerConfigurationService.getPortalUrl(); params.put("portalUrl", portalUrl); siteNavUrl.append(portalUrl); String currToolId = ToolManager.getCurrentPlacement().getId(); ToolConfiguration toolConfiguration = currentSite.getTool(currToolId); siteNavUrl.append("/"); siteNavUrl.append("site"); siteNavUrl.append("/"); siteNavUrl.append(Web.escapeUrl(currentSite.getId())); if (toolConfiguration != null) { siteNavUrl.append("/"); siteNavUrl.append("page"); siteNavUrl.append("/"); siteNavUrl.append(Web.escapeUrl(toolConfiguration.getPageId())); } //params.put("serverurl", siteNavUrl); params.put("siteToolUrl", siteNavUrl); //Mallika-comments beg /*params.put("forumLink", forumLink); params.put("unwatch", unwatch);*/ //Mallika-comments end //Mallika-code below changed to add course id Object obj[] = new String[] { sitetitle, topic.getTitle() }; /*super.prepareMessage(recipients, params, "[" + path + "] " + MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_SUBJECT), new String[] { topic.getTitle() }), SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_MESSAGE_FILE));*/ /*super.prepareMessage(recipients, params, "[" + path + "] " + MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_SUBJECT), obj), SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_MESSAGE_FILE));*/ super.prepareMessage(recipients, params, //"[" + path + "] " + MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_SUBJECT), obj), MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_SUBJECT), obj), SystemGlobals.getValue(messageFile)); }