List of usage examples for javax.mail MessagingException printStackTrace
public void printStackTrace()
From source file:it.infn.ct.wrf.Wrf.java
private void sendHTMLEmail(String USERNAME, String TO, String FROM, String SMTP_HOST, String ApplicationAcronym, String GATEWAY) {/*from w ww . j a va 2 s . c om*/ log.info("\n- Sending email notification to the user " + USERNAME + " [ " + TO + " ]"); log.info("\n- SMTP Server = " + SMTP_HOST); log.info("\n- Sender = " + FROM); log.info("\n- Receiver = " + TO); log.info("\n- Application = " + ApplicationAcronym); log.info("\n- Gateway = " + GATEWAY); // Assuming you are sending email from localhost String HOST = "localhost"; // Get system properties Properties properties = System.getProperties(); properties.setProperty(SMTP_HOST, HOST); // Get the default Session object. Session session = Session.getDefaultInstance(properties); try { // Create a default MimeMessage object. MimeMessage message = new MimeMessage(session); // Set From: header field of the header. message.setFrom(new InternetAddress(FROM)); // Set To: header field of the header. message.addRecipient(Message.RecipientType.TO, new InternetAddress(TO)); //message.addRecipient(Message.RecipientType.CC, new InternetAddress(FROM)); // Set Subject: header field message.setSubject(" [liferay-sg-gateway] - [ " + GATEWAY + " ] "); Date currentDate = new Date(); currentDate.setTime(currentDate.getTime()); // Send the actual HTML message, as big as you like message.setContent("<br/><H4>" + "<img src=\"http://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc6/195775_220075701389624_155250493_n.jpg\" width=\"100\">Science Gateway Notification" + "</H4><hr><br/>" + "<b>Description:</b> Notification for the application <b>[ " + ApplicationAcronym + " ]</b><br/><br/>" + "<i>The application has been successfully submitted from the [ " + GATEWAY + " ]</i><br/><br/>" + "<b>TimeStamp:</b> " + currentDate + "<br/><br/>" + "<b>Disclaimer:</b><br/>" + "<i>This is an automatic message sent by the Science Gateway based on Liferay technology.<br/>" + "If you did not submit any jobs through the Science Gateway, please " + "<a href=\"mailto:" + FROM + "\">contact us</a></i>", "text/html"); // Send message Transport.send(message); } catch (MessagingException mex) { mex.printStackTrace(); } }
From source file:com.krawler.hrms.hrmsHandler.java
public static JSONObject sendappraisalreportEmail(Session session, HttpServletRequest request) throws ServiceException, HibernateException, SessionExpiredException, JSONException { try {/* ww w . j a v a2 s .co m*/ JSONObject jobj = new JSONObject(); String mailcontent = ""; String htmlmailcontent = ""; String plnmailcontent = ""; String email = request.getSession().getAttribute("sysemailid").toString(); String plainmsg = ""; String htmlmsg = ""; String title = ""; String url = ""; // User usr = (User) session.load(User.class, AuthHandler.getUserid(request)); // if (usr.getEmailID() != null) { // email = usr.getEmailID(); // } Company cmpid = (Company) session.get(Company.class, AuthHandler.getCompanyid(request)); String appcycleid = request.getParameter("appraisalcycleid"); url = URLUtil.getPageURL(request, Links.loginpagewthFull, cmpid.getSubDomain()) + "appraise.jsp?pdfEmail=true&reviewappraisal=false&appraisalcycid=" + appcycleid + "&userid="; JSONObject eobj = EmailCases(hrms_EmailTemplates.emailemployeeReport, session, request); plainmsg = eobj.getString("plainmessage"); htmlmsg = eobj.getString("htmlmessage"); title = eobj.getString("title"); Appraisalcycle app = (Appraisalcycle) session.load(Appraisalcycle.class, appcycleid); mailcontent = "Appraisal Cycle: "; String hql = "select distinct employee.userID,employee.firstName,employee.lastName,employee.employeeid,employee.emailID from Appraisalmanagement where appcycle.id=? and reviewstatus=2"; List list1 = HibernateUtil.executeQuery(session, hql, new Object[] { appcycleid }); Iterator ite1 = list1.iterator(); if (!list1.isEmpty()) { while (ite1.hasNext()) { Object[] row = (Object[]) ite1.next(); String target = "_parent"; plnmailcontent += "" + app.getCyclename() + " (" + url + row[0] + "&d=" + row[0] + ")\n\n"; htmlmailcontent += "<a target='" + target + "' href='" + url + row[0] + "&d=" + row[0] + "'>" + app.getCyclename() + "</a>\n\n"; plnmailcontent = mailcontent + plnmailcontent; htmlmailcontent = mailcontent + htmlmailcontent; String intpmsg = String.format(plainmsg, row[1].toString() + " " + row[2].toString(), plnmailcontent); String inthtmlmsg = String.format(htmlmsg, row[1].toString() + " " + row[2].toString(), htmlmailcontent.replaceAll("\n", "<br>")); htmlmailcontent = ""; plnmailcontent = ""; try { SendMailHandler.postMail(new String[] { row[4].toString() }, title, inthtmlmsg, intpmsg, email); } catch (MessagingException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } jobj.put("message", mailcontent); return jobj; } catch (HibernateException e) { throw ServiceException.FAILURE("hrmsHandler.sendappraisalreportEmail", e); } }
From source file:com.krawler.hrms.hrmsHandler.java
public static JSONObject sendappraisalemailFunction(Session session, HttpServletRequest request) throws ServiceException, HibernateException, SessionExpiredException, JSONException { try {//from w w w. j ava 2s .co m String cyclename = ""; JSONObject jobj = new JSONObject(); String cycledate = ""; String mailcontent = ""; List recordTotalCount = null; String email = request.getSession().getAttribute("sysemailid").toString(); boolean flag = true; String plainmsg = ""; String htmlmsg = ""; String title = ""; // User usr = (User) session.load(User.class, AuthHandler.getUserid(request)); // if (usr.getEmailID() != null) { // email = usr.getEmailID(); // } Date userdate = com.krawler.common.util.Timezone.toUserSystemTimezoneDate(session, request, dateFmt.format(new Date()), AuthHandler.getUserid(request)); Appraisalcycle app = (Appraisalcycle) session.load(Appraisalcycle.class, request.getParameter("appraisalcycleid")); String hql1 = "select id from Appraisalcycle where id=? and submitenddate>=?"; List tabledata = HibernateUtil.executeQuery(session, hql1, new Object[] { request.getParameter("appraisalcycleid"), userdate }); if (!tabledata.isEmpty()) { JSONObject eobj = EmailCases(hrms_EmailTemplates.appraisalRemainder, session, request); plainmsg = eobj.getString("plainmessage"); htmlmsg = eobj.getString("htmlmessage"); title = eobj.getString("title"); String query = "select userID,emailID,firstName,lastName from User where company.companyID=? and deleted=?"; List list = HibernateUtil.executeQuery(session, query, new Object[] { AuthHandler.getCompanyid(request), false }); Iterator itr = list.iterator(); while (itr.hasNext()) { Object[] u = (Object[]) itr.next(); cyclename = app.getCyclename(); cycledate = AuthHandler.getUserDateFormatter(request, session).format(app.getSubmitenddate()); mailcontent = "<p>Appraisal Cycle: " + cyclename + "<br>Deadline for submission: " + cycledate; String hql = "select appm.employeestatus from Appraisalmanagement appm where appm.employee.userID=? and appm.appcycle.id=? group by appm.appcycle.id"; recordTotalCount = HibernateUtil.executeQuery(session, hql, new Object[] { u[0].toString(), app.getId() }); if (!recordTotalCount.isEmpty()) { Object log = (Object) recordTotalCount.get(0); if ((Integer) log == 0) { mailcontent += "<br>Self Appraisal: " + "Not Submitted"; } } mailcontent += "</p>"; String intpmsg = String.format(plainmsg, u[2].toString() + " " + u[3].toString(), mailcontent); String inthtmlmsg = String.format(htmlmsg, u[2].toString() + " " + u[3].toString(), mailcontent); try { SendMailHandler.postMail(new String[] { u[1].toString() }, title, inthtmlmsg, intpmsg, email); } catch (MessagingException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } else { flag = false; } jobj.put("message", flag); return jobj; } catch (HibernateException e) { throw ServiceException.FAILURE("hrmsHandler.sendappraisalemailFunction", e); } }
From source file:com.krawler.hrms.hrmsHandler.java
public static void addRecruitersFunction(Session session, HttpServletRequest request) throws ServiceException, SessionException, HibernateException { //Status 0=pending,1=accepted,2=rejected,3=Not sent List tabledata = null;/*from ww w . j ava 2 s. c o m*/ String hql = null; Recruiter pos = null; try { String[] recids = null; Company cmpid = (Company) session.get(Company.class, AuthHandler.getCompanyid(request)); User u = (User) session.get(User.class, AuthHandler.getUserid(request)); if (StringUtil.isNullOrEmpty(request.getParameter("delrec"))) { recids = request.getParameterValues("jobids"); for (int i = 0; i < recids.length; i++) { hql = "from Recruiter where recruit.userID=? "; tabledata = HibernateUtil.executeQuery(session, hql, recids[i]); if (!tabledata.isEmpty()) { pos = (Recruiter) tabledata.get(0); pos.setDelflag(0); session.update(pos); //@@ProfileHandler.insertAuditLog(session, AuditAction.SET_AS_INTERVIEWER, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has set " + AuthHandler.getFullName(pos.getRecruit()) + " as interviewer",request); } else { User md = (User) session.load(User.class, recids[i]); String id = UUID.randomUUID().toString(); Recruiter contact = new Recruiter(); contact.setRid(id); contact.setRecruit(md); contact.setDelflag(0); session.save(contact); //@@ProfileHandler.insertAuditLog(session, AuditAction.SET_AS_INTERVIEWER, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has set " + AuthHandler.getFullName(contact.getRecruit()) + " as interviewer",request); } } } else { String[] delrecids = request.getParameterValues("appid"); for (int i = 0; i < delrecids.length; i++) { String query = "from Recruiter where recruit.userID=?"; tabledata = HibernateUtil.executeQuery(session, query, delrecids[i]); if (!tabledata.isEmpty()) { pos = (Recruiter) tabledata.get(0); pos.setDelflag(3); //@@ProfileHandler.insertAuditLog(session, AuditAction.UNASSIGN_INTERVIEWER, "User " + AuthHandler.getFullName(pos.getRecruit()) + " has been unassigned as interviewer by " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)),request); session.update(pos); } } } if (StringUtil.isNullOrEmpty(request.getParameter("delrec"))) { for (int i = 0; i < recids.length; i++) { User r = (User) session.get(User.class, recids[i]); Useraccount ua = (Useraccount) session.get(Useraccount.class, r.getUserID()); String fullname = AuthHandler.getFullName(r); String uri = URLUtil.getPageURL(request, Links.loginpagewthFull, cmpid.getSubDomain()) + "jspfiles/Confirmation.jsp?c=" + cmpid.getCompanyID() + "&u=" + r.getUserID() + "&acpt="; String pmsg = String.format(HrmsMsgs.interviewerSelectionpln, fullname); String htmlmsg = String.format(HrmsMsgs.interviewerSelectionHTML, fullname, uri + "1", uri + "0", AuthHandler.getFullName(u), ua.getDesignationid().getValue(), cmpid.getCompanyName()); try { SendMailHandler.postMail(new String[] { r.getEmailID() }, HrmsMsgs.interviewerSubject, htmlmsg, pmsg, u.getEmailID()); } catch (MessagingException e) { e.printStackTrace(); } } } } catch (SessionExpiredException e) { throw ServiceException.FAILURE(e.getMessage(), e); } catch (HibernateException ex) { throw ServiceException.FAILURE("Failure hrms.Handler", ex); } }
From source file:com.krawler.hrms.hrmsHandler.java
public static JSONObject sendRevieweremailFunction(Session session, HttpServletRequest request) throws ServiceException, HibernateException, SessionExpiredException, JSONException { try {/*from w ww. java 2s. c o m*/ JSONObject jobj = new JSONObject(); String mailcontent = ""; String htmlmailcontent = ""; String plnmailcontent = ""; String email = request.getSession().getAttribute("sysemailid").toString(); String plainmsg = ""; String htmlmsg = ""; String title = ""; String url = ""; // User usr = (User) session.load(User.class, AuthHandler.getUserid(request)); // if (usr.getEmailID() != null) { // email = usr.getEmailID(); // } Company cmpid = (Company) session.get(Company.class, AuthHandler.getCompanyid(request)); String appcycleid = request.getParameter("appraisalcycleid"); url = URLUtil.getPageURL(request, Links.loginpagewthFull, cmpid.getSubDomain()) + "appraise.jsp?pdfEmail=true&reviewappraisal=false&appraisalcycid=" + appcycleid + "&userid="; JSONObject eobj = EmailCases(hrms_EmailTemplates.pdfMailtoReviewer, session, request); plainmsg = eobj.getString("plainmessage"); htmlmsg = eobj.getString("htmlmessage"); title = eobj.getString("title"); Appraisalcycle app = (Appraisalcycle) session.load(Appraisalcycle.class, appcycleid); mailcontent = "Appraisal Cycle: " + app.getCyclename() + "\n\n"; String query = "select distinct reviewer.userID,reviewer.firstName,reviewer.lastName,reviewer.emailID from Assignreviewer where reviewer.company.companyID=? and reviewer.deleted=? and reviewerstatus=1"; List list = HibernateUtil.executeQuery(session, query, new Object[] { AuthHandler.getCompanyid(request), false }); Iterator itr = list.iterator(); while (itr.hasNext()) { Object[] reviewer = (Object[]) itr.next(); String hql = "select distinct employee.userID,employee.firstName,employee.lastName,employee.employeeid from Appraisalmanagement where appcycle.id=? and reviewstatus=2 and employee.userID in " + "(select employee.userID from Assignreviewer where reviewer.userID=? and reviewerstatus=1)"; List list1 = HibernateUtil.executeQuery(session, hql, new Object[] { appcycleid, reviewer[0].toString() }); Iterator ite1 = list1.iterator(); if (!list1.isEmpty()) { while (ite1.hasNext()) { Object[] row = (Object[]) ite1.next(); String target = "_parent"; String empid = hrmsManager.getEmpidFormatEdit(session, request, (Integer) row[3]); plnmailcontent += "" + row[1] + " " + row[2] + " - " + url + row[0] + "&d=" + reviewer[0] + "\n"; htmlmailcontent += "<a target='" + target + "' href='" + url + row[0] + "&d=" + reviewer[0] + "'>" + row[1] + " " + row[2] + "</a>\n"; } plnmailcontent = mailcontent + plnmailcontent; htmlmailcontent = mailcontent + htmlmailcontent; String intpmsg = String.format(plainmsg, reviewer[1].toString() + " " + reviewer[2].toString(), plnmailcontent); String inthtmlmsg = String.format(htmlmsg, reviewer[1].toString() + " " + reviewer[2], htmlmailcontent.replaceAll("\n", "<br>")); htmlmailcontent = ""; plnmailcontent = ""; try { SendMailHandler.postMail(new String[] { reviewer[3].toString() }, title, inthtmlmsg, intpmsg, email); } catch (MessagingException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } jobj.put("message", mailcontent); return jobj; } catch (HibernateException e) { throw ServiceException.FAILURE("hrmsHandler.sendRevieweremailFunction", e); } }
From source file:com.krawler.hrms.hrmsHandler.java
public static void applyforjobexternal(Session session, HttpServletRequest request) throws ServiceException, SessionExpiredException, ParseException, JSONException { String status = "Pending"; Date date1;//from ww w. j av a 2s.co m DateFormat formatter; String positions = ""; Jobapplicant applicant = null; User user = null; String applicantid; try { formatter = new SimpleDateFormat("MM/dd/yyyy"); date1 = (Date) formatter.parse(request.getParameter("applydt")); Allapplications allapl = null; if (StringUtil.isNullOrEmpty(request.getParameter("apcntid"))) { applicantid = AuthHandler.getUserid(request); } else { applicantid = request.getParameter("apcntid"); } if (Integer.parseInt(request.getParameter("employeetype")) == 1) { user = (User) session.load(User.class, applicantid); } else { applicant = (Jobapplicant) session.load(Jobapplicant.class, applicantid); } Company cmp = (Company) session.load(Company.class, AuthHandler.getCompanyid(request)); CompanyPreferences cmpPref = (CompanyPreferences) session.load(CompanyPreferences.class, cmp.getCompanyID()); String[] ids = request.getParameterValues("posid"); for (int i = 0; i < ids.length; i++) { Positionmain position = (Positionmain) session.load(Positionmain.class, ids[i]); allapl = new Allapplications(); allapl.setStatus(status); allapl.setApplydate(date1); if (Integer.parseInt(request.getParameter("employeetype")) == 1) { allapl.setEmployee(user); allapl.setEmployeetype(1); } else { allapl.setJobapplicant(applicant); allapl.setEmployeetype(0); } allapl.setPosition(position); allapl.setCompany(cmp); allapl.setDelflag(0); allapl.setApplicationflag(0); allapl.setRejectedbefore(0); session.save(allapl); positions += "" + position.getJobid() + ":" + position.getPosition().getValue() + ","; if (Integer.parseInt(request.getParameter("employeetype")) == 1) { //@@ProfileHandler.insertAuditLog(session, AuditAction.APPLY_FOR_JOB, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has applied for job position " + allapl.getPosition().getJobid(),request); } else { if (request.getSession().getAttribute("userid") != null) { //@@ProfileHandler.insertAuditLog(session, AuditAction.APPLY_FOR_JOB, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has applied external applicant " + allapl.getJobapplicant().getFirstname() + " " + allapl.getJobapplicant().getLastname() + " for job position " + allapl.getPosition().getJobid(),request); } } } if (!(Integer.parseInt(request.getParameter("employeetype")) == 1)) { String cmpname = cmp.getCompanyName(); positions = positions.replace(positions.substring(positions.length() - 1), ""); String pmsg = String.format(HrmsMsgs.jobPlnmsg, (applicant.getFirstname() + " " + applicant.getLastname()), cmpname, cmpname); String htmlmsg = String.format(HrmsMsgs.jobHTMLmsg, allapl.getPosition().getPosition().getValue() + "[" + (allapl.getPosition().getJobid() != null ? allapl.getPosition().getJobid() : "") + "]", cmpname, cmpname); String subject = String.format(HrmsMsgs.jobSubject, (allapl.getPosition().getJobid() != null ? allapl.getPosition().getJobid() : ""), allapl.getPosition().getPosition().getValue()); try { SendMailHandler.postMail(new String[] { applicant.getEmail() }, subject, htmlmsg, pmsg, cmp.getEmailID()); } catch (MessagingException e) { e.printStackTrace(); } } } catch (ParseException ex) { throw new JSONException("applyforjobexternal"); } catch (SessionExpiredException e) { throw ServiceException.FAILURE(e.getMessage(), e); } }
From source file:com.krawler.hrms.hrmsHandler.java
public static JSONObject setConfirmation(Session session, HttpServletRequest request, String cmp, String user) throws ServiceException, HibernateException, JSONException { JSONObject jobj = new JSONObject(); try {/* ww w .ja v a2 s . c om*/ Integer accept = Integer.parseInt(request.getParameter("acpt")); String hql = "from Recruiter where recruit.userID=? and recruit.company.companyID=? and allapplication is null"; List lst = HibernateUtil.executeQuery(session, hql, new Object[] { user, cmp }); if (lst.size() == 1) { Recruiter r = (Recruiter) lst.get(0); int statusFlag = r.getDelflag(); if (statusFlag == 0) { String ipaddr = ""; if (StringUtil.isNullOrEmpty(request.getHeader("x-real-ip"))) { ipaddr = request.getRemoteAddr(); } else { ipaddr = request.getHeader("x-real-ip"); } User usr = (User) session.get(User.class, user); if (accept == 1) { r.setDelflag(1); AuditAction action = (AuditAction) session.load(AuditAction.class, com.krawler.common.util.AuditAction.ACCEPT_AS_INTERVIEWER); //@@ProfileHandler.insertAuditLog(session, action, "User " + usr.getFirstName() + " " + usr.getLastName() + " has accepted interviewer position", ipaddr, usr); } else { r.setDelflag(2); AuditAction action = (AuditAction) session.load(AuditAction.class, com.krawler.common.util.AuditAction.REJECT_AS_INTERVIEWER); //@@ProfileHandler.insertAuditLog(session, action, "User " + usr.getFirstName() + " " + usr.getLastName() + " has rejected interviewer position", ipaddr, usr); } session.save(r); if (accept == 1) { Company cmpid = (Company) session.get(Company.class, cmp); String fullname = r.getRecruit().getFirstName() + " " + r.getRecruit().getLastName(); User u = cmpid.getCreator(); Useraccount ua = (Useraccount) session.get(Useraccount.class, u.getUserID()); String pmsg = String.format(HrmsMsgs.Thankspln, fullname); String htmlmsg = ""; if (ua.getDesignationid() == null) htmlmsg = String.format(HrmsMsgs.ThanksHTML, fullname, u.getFirstName() + " " + u.getLastName(), cmpid.getCompanyName(), ""); else htmlmsg = String.format(HrmsMsgs.ThanksHTML, fullname, u.getFirstName() + " " + u.getLastName(), ua.getDesignationid().getValue(), cmpid.getCompanyName()); try { SendMailHandler.postMail(new String[] { r.getRecruit().getEmailID() }, HrmsMsgs.ThanksSubject, htmlmsg, pmsg, u.getEmailID()); } catch (MessagingException e) { e.printStackTrace(); } } jobj.put("success", true); jobj.put("msg", MessageSourceProxy.getMessage("hrms.hrmshandler.msg.operationhasbeendonesuccessfully", null, "Operation has been done successfully11.", LocaleUtil.getCompanyLocale(cmp, 0))); } else { jobj.put("success", false); jobj.put("msg", MessageSourceProxy.getMessage( "hrms.hrmshandler.msg.alreadyacceptedrejectedinviation", null, "It seems you've already accepted/rejected the invitation. Please send an email to support@deskera.com if this message is incorrect.", LocaleUtil.getCompanyLocale(cmp, 0))); } } else { jobj.put("success", false); jobj.put("msg", MessageSourceProxy.getMessage( "hrms.hrmshandler.msg.itseemsyouarenotrequestedasrecruiter", null, "It seems you are not requested as recruiter. Please send an email to support@deskera.com if this message is incorrect.", LocaleUtil.getCompanyLocale(cmp, 0))); } } catch (HibernateException e) { throw ServiceException.FAILURE("hrmsHandler.setConfirmation", e); } catch (JSONException e) { throw ServiceException.FAILURE("hrmsHandler.setConfirmation", e); } catch (Exception e) { throw ServiceException.FAILURE("hrmsHandler.setConfirmation", e); } return jobj; }
From source file:com.krawler.hrms.hrmsHandler.java
public static String Externalapplicant(Session session, HttpServletRequest request, String subdomain) throws ServiceException, JSONException { String result = ""; JSONObject jobj = new JSONObject(); String id = ""; String fname = ""; String lname = ""; String uname = ""; String pass = ""; String ipaddr = ""; try {// ww w .j a va 2 s.c om Company cmp = null; fname = request.getParameter("fname"); lname = request.getParameter("lname"); uname = request.getParameter("u"); pass = request.getParameter("p"); if (!StringUtil.isNullOrEmpty(subdomain)) { String hql = "from Company where subDomain=?"; List lst = HibernateUtil.executeQuery(hql, subdomain); if (!lst.isEmpty()) { Company cmpt = (Company) lst.get(0); cmp = (Company) session.load(Company.class, cmpt.getCompanyID()); String companyid = cmp.getCompanyID(); if (StringUtil.isNullOrEmpty(request.getParameter("userid"))) { String SELECT_USER_INFO = "from Jobapplicant where username=? and company.companyID=?"; List list = HibernateUtil.executeQuery(session, SELECT_USER_INFO, new Object[] { request.getParameter("u"), companyid }); if (list.size() == 0) { id = UUID.randomUUID().toString(); Jobapplicant jobapp = new Jobapplicant(); jobapp.setApplicantid(id); jobapp.setFirstname(fname); jobapp.setLastname(lname); jobapp.setEmail(request.getParameter("e")); jobapp.setAddress1(request.getParameter("c")); jobapp.setContactno(request.getParameter("contact")); jobapp.setUsername(uname); jobapp.setPassword(pass); jobapp.setCompany(cmp); session.save(jobapp); jobj.put("success", true); jobj.put("uri", "./applicantLogin.html"); String uri = URLUtil.getPageURL(request, Links.loginpagewthFull, cmp.getSubDomain()) + "applicantLogin.html"; String pmsg = String.format(KWLErrorMsgs.msgMailInvite, fname, "Demo", fname, lname, uri, "Demo"); String htmlmsg = String.format(HrmsMsgs.msgMailInviteUsernamePassword, fname + " " + lname, cmp.getCreator().getFirstName() + " " + cmp.getCreator().getLastName(), cmp.getCompanyName(), uname, pass, uri, uri, ""); try { String email = request.getSession().getAttribute("sysemailid").toString(); SendMailHandler.postMail(new String[] { request.getParameter("e") }, "[Deskera] Welcome to Deskera HRMS", htmlmsg, pmsg, email); } catch (MessagingException e) { e.printStackTrace(); } AuditAction action = (AuditAction) session.load(AuditAction.class, com.krawler.common.util.AuditAction.CREATE_APPLICANT); String details = "Job applicant " + fname + "" + lname + " has been signed up through web site."; if (StringUtil.isNullOrEmpty(request.getHeader("x-real-ip"))) { ipaddr = request.getRemoteAddr(); } else { ipaddr = request.getHeader("x-real-ip"); } //@@ProfileHandler.insertAuditLog(session, action, details, ipaddr, cmp.getCreator()); } else { jobj.put("failure", 0); } result = jobj.toString(); } else { Jobapplicant jobapp = (Jobapplicant) session.load(Jobapplicant.class, request.getParameter("userid")); jobapp.setFirstname(request.getParameter("fname")); jobapp.setLastname(request.getParameter("lname")); jobapp.setEmail(request.getParameter("email")); jobapp.setAddress1(request.getParameter("addr")); jobapp.setContactno(request.getParameter("mobileno")); jobapp.setState(request.getParameter("state")); jobapp.setCountry(request.getParameter("country")); jobapp.setOtheremail(request.getParameter("alternateemail")); jobapp.setMobileno(request.getParameter("phno")); session.save(jobapp); result = "{\"success\":\"true\"}"; } } } } catch (ServiceException ex) { throw ServiceException.FAILURE("Externalapplicant", ex); } catch (JSONException ex) { throw ServiceException.FAILURE("Externalapplicant", ex); } finally { } return result; }
From source file:com.krawler.hrms.hrmsHandler.java
public static void scheduleinterview(Session session, HttpServletRequest request) throws ServiceException, ParseException, SessionExpiredException { Date date1;//from w ww . j a v a2s .c om DateFormat formatter; String interviewdate; boolean reflag = false; String htmlmsg = ""; String pmsg = ""; String interviewsub = ""; try { String interviewtime = request.getParameter("interviewtime"); String location = request.getParameter("interviewplace"); Company cmp = (Company) session.get(Company.class, AuthHandler.getCompanyid(request)); formatter = new SimpleDateFormat("MM/dd/yyyy"); date1 = (Date) formatter.parse(request.getParameter("interviewdt")); interviewdate = (AuthHandler.getUserDateFormatter(request, session).format(date1)); Allapplications allapl = null; String[] ids = request.getParameterValues("ids"); String[] emailids = new String[ids.length]; String[] jobs = new String[ids.length]; String[] applicant = new String[ids.length]; for (int i = 0; i < ids.length; i++) { allapl = (Allapplications) session.load(Allapplications.class, ids[i]); if (allapl.getStatus().equalsIgnoreCase("In Process")) { reflag = true; } allapl.setStatus("In Process"); allapl.setInterviewdate(date1); allapl.setInterviewtime(interviewtime); allapl.setInterviewplace(location); allapl.setContactperson((User) session.load(User.class, request.getParameter("contactperson"))); allapl.setInterviewcomment(request.getParameter("interviewcomment")); allapl.setRecruiter(request.getParameter("rid")); if (Integer.parseInt(request.getParameter("employeetype")) == 1) { emailids[i] = allapl.getEmployee().getEmailID(); applicant[i] = (allapl.getEmployee().getFirstName() + " " + allapl.getEmployee().getLastName()); } else { emailids[i] = allapl.getJobapplicant().getEmail(); applicant[i] = (allapl.getJobapplicant().getFirstname() + " " + allapl.getJobapplicant().getLastname()); } jobs[i] = ("[" + allapl.getPosition().getJobid() + "] " + allapl.getPosition().getPosition().getValue() + ""); session.update(allapl); String usrnm; if (allapl.getEmployee() != null) { usrnm = AuthHandler.getFullName(allapl.getEmployee()); } else { usrnm = allapl.getJobapplicant().getFirstname() + " " + allapl.getJobapplicant().getLastname(); } //@@ProfileHandler.insertAuditLog(session, AuditAction.INTERVIEW_SCHEDULED, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has scheduled interview for " + usrnm + " on "+ interviewdate + " at " + allapl.getInterviewplace(),request); } User usr = (User) session.get(User.class, AuthHandler.getUserid(request)); Useraccount ua = (Useraccount) session.get(Useraccount.class, usr.getUserID()); if (!StringUtil.isNullOrEmpty(request.getParameter("mail"))) { for (int j = 0; j < emailids.length; j++) { if (reflag) { pmsg = String.format(HrmsMsgs.rescheduleinterviewPlnmsg, applicant[j], jobs[j], cmp.getCompanyName(), interviewdate, interviewtime, location, usr.getContactNumber(), usr.getEmailID(), usr.getFirstName() + " " + usr.getLastName(), ua.getDesignationid() != null ? ua.getDesignationid().getValue() : " ", cmp.getCompanyName()); htmlmsg = String.format(HrmsMsgs.rescheduleinterviewHTMLmsg, applicant[j], jobs[j], cmp.getCompanyName(), interviewdate, interviewtime, location, usr.getContactNumber(), usr.getEmailID(), usr.getFirstName() + " " + usr.getLastName(), ua.getDesignationid() != null ? ua.getDesignationid().getValue() : " ", cmp.getCompanyName()); interviewsub = String.format(HrmsMsgs.rescheduleinterviewSubject, allapl.getPosition().getJobid(), allapl.getPosition().getPosition().getValue(), cmp.getCompanyName()); try { SendMailHandler.postMail(new String[] { emailids[j] }, interviewsub, htmlmsg, pmsg, usr.getEmailID()); } catch (MessagingException e) { e.printStackTrace(); } } else { pmsg = String.format(HrmsMsgs.interviewPlnmsg, jobs[j], interviewdate, interviewtime, location); htmlmsg = String.format(HrmsMsgs.interviewHTMLmsg, applicant[j], jobs[j], cmp.getCompanyName(), interviewdate, interviewtime, location, usr.getContactNumber(), usr.getEmailID(), usr.getFirstName() + " " + usr.getLastName(), ua.getDesignationid() != null ? ua.getDesignationid().getValue() : " ", cmp.getCompanyName()); interviewsub = String.format(HrmsMsgs.interviewSubject, allapl.getPosition().getJobid(), allapl.getPosition().getPosition().getValue(), cmp.getCompanyName()); try { SendMailHandler.postMail(new String[] { emailids[j] }, interviewsub, htmlmsg, pmsg, usr.getEmailID()); } catch (MessagingException e) { e.printStackTrace(); } } String[] recruit = request.getParameter("rid").split(","); for (int k = 0; k < recruit.length; k++) { Recruiter r = (Recruiter) session.get(Recruiter.class, recruit[k]); String interviewer = r.getRecruit().getFirstName() + " " + r.getRecruit().getLastName(); String intpmsg = String.format(HrmsMsgs.interviewinvitePlnmsg, interviewer, jobs[j], interviewdate, interviewtime, location); String inthtmlmsg = String.format(HrmsMsgs.interviewinviteHTMLmsg, interviewer, jobs[j], interviewdate, interviewtime, location, usr.getFirstName() + " " + usr.getLastName(), ua.getDesignationid() != null ? ua.getDesignationid().getValue() : " ", cmp.getCompanyName()); String interviewinvitesub = String.format(HrmsMsgs.interviewinviteSubject, allapl.getPosition().getJobid(), allapl.getPosition().getPosition().getValue(), cmp.getCompanyName()); try { SendMailHandler.postMail(new String[] { r.getRecruit().getEmailID() }, interviewinvitesub, inthtmlmsg, intpmsg, usr.getEmailID()); } catch (MessagingException e) { e.printStackTrace(); } } } } } catch (ParseException ex) { throw ServiceException.FAILURE("scheduleinterview", ex); } catch (NullPointerException ex) { throw ServiceException.FAILURE("scheduleinterview", ex); } finally { } }
From source file:com.krawler.hrms.hrmsHandler.java
public static JSONObject saveJobs(Session session, HttpServletRequest request, String cmp, String desig, String colnumbers) throws ServiceException, JSONException { JSONObject jobj = new JSONObject(); JSONArray jArr = new JSONArray(); int cnt = 0;//from w w w . j av a 2s .c om String pwd = "1234"; String status = "Pending"; SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yyyy"); HashMap<String, String> arrParam = new HashMap<String, String>(); HashMap<Integer, String> filemap = new HashMap<Integer, String>(); boolean fileUpload = false; String filledcols = ""; String datecols = ""; Allapplications allapl = null; ArrayList<FileItem> hm = new ArrayList<FileItem>(); String datenumbers = request.getParameter("datenumbers"); String mandatorynumbers = request.getParameter("mandatorynumbers"); String[] mandatoryfields = null; HashMap<String, String> mandatorymap = new HashMap<String, String>(); if (!StringUtil.isNullOrEmpty(mandatorynumbers)) { mandatoryfields = mandatorynumbers.split(","); for (int i = 0; i < mandatoryfields.length; i++) { mandatorymap.put(mandatoryfields[i], "true"); } } try { Company company = (Company) session.get(Company.class, cmp); fileUploader.parseRequest(request, arrParam, hm, fileUpload, filemap); String[] cols = colnumbers.split(","); HashMap<String, Object> requestParams = new HashMap<String, Object>(); boolean mandatory = false; for (int i = 0; i < cols.length; i++) { if (arrParam.get("Col" + cols[i]) != null && !arrParam.get("Col" + cols[i]).trim().equals("")) { requestParams.put("Col" + cols[i], arrParam.get("Col" + cols[i]).trim()); jobj.put("Col" + cols[i], arrParam.get("Col" + cols[i]).trim()); filledcols += cols[i] + ","; } else { if (mandatorymap.containsKey(cols[i])) { mandatory = true; } } } if (!StringUtil.isNullOrEmpty(datenumbers)) { String[] dates = datenumbers.split(","); for (int i = 0; i < dates.length; i++) { if (!StringUtil.isNullOrEmpty((String) arrParam.get("Col" + dates[i] + "_dd")) && !StringUtil.isNullOrEmpty((String) arrParam.get("Col" + dates[i] + "_mm")) && !StringUtil.isNullOrEmpty((String) arrParam.get("Col" + dates[i] + "_yy"))) { String date = arrParam.get("Col" + dates[i] + "_mm") + "/" + arrParam.get("Col" + dates[i] + "_dd") + "/" + arrParam.get("Col" + dates[i] + "_yy"); requestParams.put("Col" + dates[i], date); jobj.put("Col" + dates[i], date); datecols += dates[i] + ","; } else { if (mandatorymap.containsKey(dates[i])) { mandatory = true; } } } } if (!mandatory) { requestParams.put("Company", cmp); requestParams.put("Referenceid", desig); KwlReturnObject result = addConfigRecruitmentData(session, requestParams); ConfigRecruitmentData ConfigRecruitmentDataobj = (ConfigRecruitmentData) result.getEntityList() .get(0); arrParam.put("docname", "_Resume"); arrParam.put("docdesc", "Resume"); for (int j = 0; j < filemap.size(); j++) { HrmsDocs doc = fileUploader.uploadFile(session, hm.get(j), ConfigRecruitmentDataobj, arrParam, false); HrmsDocmap docMap = new HrmsDocmap(); docMap.setDocid(doc); docMap.setRecid(ConfigRecruitmentDataobj.getId()); session.save(docMap); String classstr = "com.krawler.hrms.recruitment.ConfigRecruitmentData"; Class cl = Class.forName(classstr); Method setter = cl.getMethod("set" + filemap.get(j), String.class); setter.invoke(ConfigRecruitmentDataobj, doc.getDocid()); } session.save(ConfigRecruitmentDataobj); Positionmain position = (Positionmain) session.load(Positionmain.class, desig); allapl = new Allapplications(); allapl.setStatus(status); allapl.setApplydate(new Date()); allapl.setConfigjobapplicant(ConfigRecruitmentDataobj); allapl.setEmployeetype(4); //configjobapplicant=4 reset to 0 allapl.setPosition(position); allapl.setCompany(company); allapl.setDelflag(0); allapl.setApplicationflag(0); allapl.setRejectedbefore(0); session.save(allapl); String companyname = company.getCompanyName(); String subject = String.format(HrmsMsgs.jobSubject, (position.getJobid() != null ? position.getJobid() : ""), position.getPosition().getValue()); String pmsg = String.format(HrmsMsgs.jobPlnmsg, (ConfigRecruitmentDataobj.getCol1() + " " + ConfigRecruitmentDataobj.getCol2()), companyname, companyname); String htmlmsg = String.format(HrmsMsgs.jobHTMLmsg, position.getPosition().getValue() + " [" + (position.getJobid() != null ? position.getJobid() : "") + "]", companyname, companyname); try { String email = getRecruitmentEmailId(request); SendMailHandler.postMail(new String[] { ConfigRecruitmentDataobj.getCol3() }, subject, htmlmsg, pmsg, email); } catch (MessagingException e) { e.printStackTrace(); } jobj.put("msg", "<div style='text-align: left;'><p>Your application for " + position.getPosition().getValue() + " [" + (position.getJobid() != null ? position.getJobid() : "") + "] at " + companyname + " has been submitted successfully.</p>" + "<p>If your resume get shortlisted, we will get in touch with you.</p>" + "With best wishes,<br>Recruitment Team at " + companyname + "</div>"); jobj.put("success", true); jobj.put("fields", false); } else { jobj.put("msg", "Please fill all the fields marked with *"); jobj.put("success", false); jobj.put("fields", true); if (!StringUtil.isNullOrEmpty(filledcols)) { filledcols = filledcols.substring(0, filledcols.length() - 1); jobj.put("filledcols", filledcols); } if (!StringUtil.isNullOrEmpty(datecols)) { datecols = datecols.substring(0, datecols.length() - 1); jobj.put("datecols", datecols); } } } catch (JSONException e) { e.printStackTrace(); throw ServiceException.FAILURE("hrmsHandler.savejobs", e); } catch (Exception e) { e.printStackTrace(); throw ServiceException.FAILURE("hrmsHandler.savejobs", e); } return jobj; }