Search in sources :

Example 6 with Email

use of org.cerberus.service.email.entity.Email in project cerberus-source by cerberustesting.

the class GetNotification method processRequest.

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 * @throws org.cerberus.exception.CerberusException
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, CerberusException, JSONException {
    JSONObject jsonResponse = new JSONObject();
    Answer answer = new Answer();
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    answer.setResultMessage(msg);
    PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
    response.setContentType("application/json");
    /**
     * Parsing and securing all required parameters.
     */
    String system = policy.sanitize(request.getParameter("system"));
    String country = policy.sanitize(request.getParameter("country"));
    String env = policy.sanitize(request.getParameter("environment"));
    String build = policy.sanitize(request.getParameter("build"));
    String revision = policy.sanitize(request.getParameter("revision"));
    String chain = policy.sanitize(request.getParameter("chain"));
    // Init Answer with potencial error from Parsing parameter.
    // AnswerItem answer = new AnswerItem(msg);
    String eMailContent = "";
    ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IEmailGenerationService emailService = appContext.getBean(IEmailGenerationService.class);
    if (request.getParameter("system") == null) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", "GetNotification").replace("%OPERATION%", "Get").replace("%REASON%", "System name is missing!"));
        answer.setResultMessage(msg);
    } else if (request.getParameter("event") == null) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", "GetNotification").replace("%OPERATION%", "Get").replace("%REASON%", "event is missing!"));
        answer.setResultMessage(msg);
    } else if (request.getParameter("event").equals("newbuildrevision")) {
        try {
            // ID parameter is specified so we return the unique record of object.
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
            msg.setDescription(msg.getDescription().replace("%ITEM%", "GetNotification").replace("%OPERATION%", "Get"));
            answer.setResultMessage(msg);
            Email email = emailService.generateRevisionChangeEmail(system, country, env, build, revision);
            jsonResponse.put("notificationTo", email.getTo());
            jsonResponse.put("notificationCC", email.getCc());
            jsonResponse.put("notificationSubject", email.getSubject());
            jsonResponse.put("notificationBody", email.getBody());
        } catch (Exception ex) {
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
            msg.setDescription(msg.getDescription().replace("%ITEM%", "GetNotification").replace("%OPERATION%", "Get").replace("%REASON%", ex.toString()));
            answer.setResultMessage(msg);
        }
    } else if (request.getParameter("event").equals("disableenvironment")) {
        try {
            // ID parameter is specified so we return the unique record of object.
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
            msg.setDescription(msg.getDescription().replace("%ITEM%", "GetNotification").replace("%OPERATION%", "Get"));
            answer.setResultMessage(msg);
            Email email = emailService.generateDisableEnvEmail(system, country, env);
            jsonResponse.put("notificationTo", email.getTo());
            jsonResponse.put("notificationCC", email.getCc());
            jsonResponse.put("notificationSubject", email.getSubject());
            jsonResponse.put("notificationBody", email.getBody());
        } catch (Exception ex) {
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
            msg.setDescription(msg.getDescription().replace("%ITEM%", "GetNotification").replace("%OPERATION%", "Get").replace("%REASON%", ex.toString()));
            answer.setResultMessage(msg);
        }
    } else if (request.getParameter("event").equals("newchain")) {
        try {
            // ID parameter is specified so we return the unique record of object.
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
            msg.setDescription(msg.getDescription().replace("%ITEM%", "GetNotification").replace("%OPERATION%", "Get"));
            answer.setResultMessage(msg);
            Email email = emailService.generateNewChainEmail(system, country, env, chain);
            jsonResponse.put("notificationTo", email.getTo());
            jsonResponse.put("notificationCC", email.getCc());
            jsonResponse.put("notificationSubject", email.getSubject());
            jsonResponse.put("notificationBody", email.getBody());
        } catch (Exception ex) {
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
            msg.setDescription(msg.getDescription().replace("%ITEM%", "GetNotification").replace("%OPERATION%", "Get").replace("%REASON%", ex.toString()));
            answer.setResultMessage(msg);
        }
    } else {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", "GetNotification").replace("%OPERATION%", "Get").replace("%REASON%", "Unknown invalidityReason!"));
        answer.setResultMessage(msg);
    }
    /**
     * Formating and returning the json result.
     */
    jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());
    jsonResponse.put("message", answer.getResultMessage().getDescription());
    response.getWriter().print(jsonResponse);
    response.getWriter().flush();
}
Also used : Answer(org.cerberus.util.answer.Answer) ApplicationContext(org.springframework.context.ApplicationContext) Email(org.cerberus.service.email.entity.Email) JSONObject(org.json.JSONObject) PolicyFactory(org.owasp.html.PolicyFactory) MessageEvent(org.cerberus.engine.entity.MessageEvent) IEmailGenerationService(org.cerberus.service.email.IEmailGenerationService) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) CerberusException(org.cerberus.exception.CerberusException) JSONException(org.json.JSONException)

Example 7 with Email

use of org.cerberus.service.email.entity.Email in project cerberus-source by cerberustesting.

the class NewBuildRev method processRequest.

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, JSONException {
    JSONObject jsonResponse = new JSONObject();
    AnswerItem answerItem = new AnswerItem();
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    answerItem.setResultMessage(msg);
    PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
    response.setContentType("application/json");
    /**
     * Parsing and securing all required parameters.
     */
    String system = policy.sanitize(request.getParameter("system"));
    String country = policy.sanitize(request.getParameter("country"));
    String env = policy.sanitize(request.getParameter("environment"));
    String build = policy.sanitize(request.getParameter("build"));
    String revision = policy.sanitize(request.getParameter("revision"));
    // Init Answer with potencial error from Parsing parameter.
    // AnswerItem answer = new AnswerItem(msg);
    String eMailContent;
    ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IEmailService emailService = appContext.getBean(IEmailService.class);
    IEmailGenerationService emailGenerationService = appContext.getBean(IEmailGenerationService.class);
    IParameterService parameterService = appContext.getBean(IParameterService.class);
    ICountryEnvParamService countryEnvParamService = appContext.getBean(ICountryEnvParamService.class);
    ICountryEnvParam_logService countryEnvParam_logService = appContext.getBean(ICountryEnvParam_logService.class);
    ILogEventService logEventService = appContext.getBean(LogEventService.class);
    if (request.getParameter("system") == null) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", ITEM).replace("%OPERATION%", OPERATION).replace("%REASON%", "System name is missing!"));
        answerItem.setResultMessage(msg);
    } else if (request.getParameter("country") == null) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", ITEM).replace("%OPERATION%", OPERATION).replace("%REASON%", "Country is missing!"));
        answerItem.setResultMessage(msg);
    } else if (request.getParameter("environment") == null) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", ITEM).replace("%OPERATION%", OPERATION).replace("%REASON%", "Environment is missing!"));
        answerItem.setResultMessage(msg);
    } else if (request.getParameter("build") == null) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", ITEM).replace("%OPERATION%", OPERATION).replace("%REASON%", "Build is missing!"));
        answerItem.setResultMessage(msg);
    } else if (request.getParameter("revision") == null) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", ITEM).replace("%OPERATION%", OPERATION).replace("%REASON%", "Revision is missing!"));
        answerItem.setResultMessage(msg);
    } else {
        // All parameters are OK we can start performing the operation.
        // Getting the contryEnvParam based on the parameters.
        answerItem = countryEnvParamService.readByKey(system, country, env);
        if (!(answerItem.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && answerItem.getItem() != null)) {
            /**
             * Object could not be found. We stop here and report the error.
             */
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
            msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", OPERATION).replace("%REASON%", OBJECT_NAME + " ['" + system + "','" + country + "','" + env + "'] does not exist. Cannot activate it!"));
            answerItem.setResultMessage(msg);
        } else {
            /**
             * The service was able to perform the query and confirm the
             * object exist, then we can update it.
             */
            // Email Calculation. Email must be calcuated before we update the Build and revision in order to have the old build revision still available in the mail.
            String OutputMessage = "";
            Email email = null;
            try {
                email = emailGenerationService.generateRevisionChangeEmail(system, country, env, build, revision);
            } catch (Exception ex) {
                LOG.warn(Infos.getInstance().getProjectNameAndVersion() + " - Exception catched.", ex);
                logEventService.createForPrivateCalls("/NewBuildRev", "NEWBUILDREV", "Warning on New Build/Revision environment : ['" + system + "','" + country + "','" + env + "'] " + ex.getMessage(), request);
                OutputMessage = ex.getMessage();
            }
            // We update the object.
            CountryEnvParam cepData = (CountryEnvParam) answerItem.getItem();
            cepData.setBuild(build);
            cepData.setRevision(revision);
            cepData.setActive(true);
            Answer answer = countryEnvParamService.update(cepData);
            if (!(answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()))) {
                /**
                 * Object could not be updated. We stop here and report the
                 * error.
                 */
                answerItem.setResultMessage(answer.getResultMessage());
            } else {
                /**
                 * Update was successful.
                 */
                // Adding Log entry.
                logEventService.createForPrivateCalls("/NewBuildRev", "UPDATE", "Updated CountryEnvParam : ['" + system + "','" + country + "','" + env + "']", request);
                // Adding CountryEnvParam Log entry.
                countryEnvParam_logService.createLogEntry(system, country, env, build, revision, "New Build Revision.", request.getUserPrincipal().getName());
                /**
                 * Email notification.
                 */
                try {
                    emailService.sendHtmlMail(email);
                } catch (Exception e) {
                    LOG.warn(Infos.getInstance().getProjectNameAndVersion() + " - Exception catched.", e);
                    logEventService.createForPrivateCalls("/NewBuildRev", "NEWBUILDREV", "Warning on New Build/Revision environment : ['" + system + "','" + country + "','" + env + "'] " + e.getMessage(), request);
                    OutputMessage = e.getMessage();
                }
                if (OutputMessage.equals("")) {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
                    msg.setDescription(msg.getDescription().replace("%ITEM%", "Environment").replace("%OPERATION%", OPERATION));
                    answerItem.setResultMessage(msg);
                } else {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
                    msg.setDescription(msg.getDescription().replace("%ITEM%", "Environment").replace("%OPERATION%", OPERATION).concat(" Just one warning : ").concat(OutputMessage));
                    answerItem.setResultMessage(msg);
                }
            }
        }
    }
    /**
     * Formating and returning the json result.
     */
    jsonResponse.put("messageType", answerItem.getResultMessage().getMessage().getCodeString());
    jsonResponse.put("message", answerItem.getResultMessage().getDescription());
    response.getWriter().print(jsonResponse);
    response.getWriter().flush();
}
Also used : Email(org.cerberus.service.email.entity.Email) PolicyFactory(org.owasp.html.PolicyFactory) MessageEvent(org.cerberus.engine.entity.MessageEvent) IParameterService(org.cerberus.crud.service.IParameterService) AnswerItem(org.cerberus.util.answer.AnswerItem) ServletException(javax.servlet.ServletException) JSONException(org.json.JSONException) IOException(java.io.IOException) ICountryEnvParam_logService(org.cerberus.crud.service.ICountryEnvParam_logService) Answer(org.cerberus.util.answer.Answer) ApplicationContext(org.springframework.context.ApplicationContext) JSONObject(org.json.JSONObject) ILogEventService(org.cerberus.crud.service.ILogEventService) ICountryEnvParamService(org.cerberus.crud.service.ICountryEnvParamService) IEmailService(org.cerberus.service.email.IEmailService) CountryEnvParam(org.cerberus.crud.entity.CountryEnvParam) IEmailGenerationService(org.cerberus.service.email.IEmailGenerationService)

Example 8 with Email

use of org.cerberus.service.email.entity.Email in project cerberus-source by cerberustesting.

the class EmailGenerationService method generateNotifyEndTagExecution.

@Override
public Email generateNotifyEndTagExecution(String tag, String campaign, String to, String ciResult, double ciScore) throws Exception {
    Email email = new Email();
    String system = "";
    String from = parameterService.getParameterStringByKey("cerberus_notification_tagexecutionend_from", system, "Cerberus <no.reply@cerberus-testing.org>");
    String host = parameterService.findParameterByKey("cerberus_smtp_host", system).getValue();
    int port = Integer.valueOf(parameterService.findParameterByKey("cerberus_smtp_port", system).getValue());
    String userName = parameterService.findParameterByKey("cerberus_smtp_username", system).getValue();
    String password = parameterService.findParameterByKey("cerberus_smtp_password", system).getValue();
    String subject = parameterService.getParameterStringByKey("cerberus_notification_tagexecutionend_subject", system, "Empty Subject. Please define parameter 'cerberus_notification_tagexecutionend_subject'.");
    String body = parameterService.getParameterStringByKey("cerberus_notification_tagexecutionend_body", system, "Empty Body. Please define parameter 'cerberus_notification_tagexecutionend_body'.");
    String cerberusUrl = parameterService.findParameterByKey("cerberus_url", system).getValue();
    StringBuilder urlreporttag = new StringBuilder();
    urlreporttag.append(cerberusUrl);
    urlreporttag.append("/ReportingExecutionByTag.jsp?Tag=");
    urlreporttag.append(tag);
    // Body replace.
    body = body.replace("%TAG%", tag);
    body = body.replace("%URLTAGREPORT%", urlreporttag.toString());
    body = body.replace("%CAMPAIGN%", campaign);
    body = body.replace("%CIRESULT%", ciResult);
    body = body.replace("%CISCORE%", String.format("%.2f", ciScore));
    Tag mytag = tagService.convert(tagService.readByKey(tag));
    long tagDur = (mytag.getDateEndQueue().getTime() - mytag.getDateCreated().getTime()) / 60000;
    body = body.replace("%TAGDURATION%", String.valueOf(tagDur));
    body = body.replace("%TAGSTART%", String.valueOf(mytag.getDateCreated()));
    body = body.replace("%TAGEND%", String.valueOf(mytag.getDateEndQueue()));
    // Get TestcaseExecutionDetail in order to replace %TAGGLOBALSTATUS% or %TAGTCDETAIL%.
    List<TestCaseExecution> testCaseExecutions = testCaseExecutionService.readLastExecutionAndExecutionInQueueByTag(tag);
    StringBuilder globalStatus = new StringBuilder();
    globalStatus.append("<table><thead><tr style=\"background-color:#cad3f1; font-style:bold\"><td>Status</td><td>Number</td><td>%</td></tr></thead><tbody>");
    Map<String, Integer> axisMap = new HashMap<String, Integer>();
    Integer total;
    total = testCaseExecutions.size();
    for (TestCaseExecution execution : testCaseExecutions) {
        if (axisMap.containsKey(execution.getControlStatus())) {
            axisMap.put(execution.getControlStatus(), axisMap.get(execution.getControlStatus()) + 1);
        } else {
            axisMap.put(execution.getControlStatus(), 1);
        }
    }
    float per = 0;
    DecimalFormat df = new DecimalFormat("#.##");
    for (Map.Entry<String, Integer> entry : axisMap.entrySet()) {
        globalStatus.append("<tr>");
        globalStatus.append("<td>").append(entry.getKey()).append("</td>");
        globalStatus.append("<td>").append(entry.getValue()).append("</td>");
        per = (float) entry.getValue() / (float) total;
        per = per * 100;
        globalStatus.append("<td>").append(String.format("%.2f", per)).append("</td>");
        globalStatus.append("</tr>");
    }
    globalStatus.append("<tr style=\"background-color:#cad3f1; font-style:bold\"><td>TOTAL</td>");
    globalStatus.append("<td>").append(total).append("</td>");
    globalStatus.append("<td></td></tr>");
    globalStatus.append("</tbody></table>");
    body = body.replace("%TAGGLOBALSTATUS%", globalStatus.toString());
    Integer totalTC = 0;
    StringBuilder detailStatus = new StringBuilder();
    detailStatus.append("<table><thead><tr style=\"background-color:#cad3f1; font-style:bold\"><td>Test</td><td>Test Case</td><td>Description</td><td>Environment</td><td>Country</td><td>Status</td></tr></thead><tbody>");
    for (TestCaseExecution execution : testCaseExecutions) {
        if (!TestCaseExecution.CONTROLSTATUS_OK.equals(execution.getControlStatus())) {
            detailStatus.append("<tr>");
            detailStatus.append("<td>").append(execution.getTest()).append("</td>");
            detailStatus.append("<td>").append(execution.getTestCase()).append("</td>");
            detailStatus.append("<td>").append(execution.getDescription()).append("</td>");
            detailStatus.append("<td>").append(execution.getEnvironment()).append("</td>");
            detailStatus.append("<td>").append(execution.getCountry()).append("</td>");
            detailStatus.append("<td>").append(execution.getControlStatus()).append("</td>");
            detailStatus.append("</tr>");
            totalTC++;
        }
    }
    detailStatus.append("<tr style=\"background-color:#cad3f1; font-style:bold\">");
    detailStatus.append("<td>TOTAL</td>");
    detailStatus.append("<td colspan=\"5\">").append(totalTC).append("</td>");
    detailStatus.append("</tr>");
    detailStatus.append("</tbody></table>");
    body = body.replace("%TAGTCDETAIL%", detailStatus.toString());
    // Subject replace.
    subject = subject.replace("%TAG%", tag);
    subject = subject.replace("%CAMPAIGN%", campaign);
    email = emailFactory.create(host, port, userName, password, true, subject, body, from, to, null);
    return email;
}
Also used : TestCaseExecution(org.cerberus.crud.entity.TestCaseExecution) Email(org.cerberus.service.email.entity.Email) HashMap(java.util.HashMap) DecimalFormat(java.text.DecimalFormat) Tag(org.cerberus.crud.entity.Tag) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with Email

use of org.cerberus.service.email.entity.Email in project cerberus-source by cerberustesting.

the class EmailGenerationService method generateForgotPasswordEmail.

@Override
public Email generateForgotPasswordEmail(User user) throws Exception {
    Email email = new Email();
    String system = "";
    String to = user.getEmail();
    String from = parameterService.findParameterByKey("cerberus_notification_accountcreation_from", system).getValue();
    String host = parameterService.findParameterByKey("cerberus_smtp_host", system).getValue();
    int port = Integer.valueOf(parameterService.findParameterByKey("cerberus_smtp_port", system).getValue());
    String userName = parameterService.findParameterByKey("cerberus_smtp_username", system).getValue();
    String password = parameterService.findParameterByKey("cerberus_smtp_password", system).getValue();
    String cc = parameterService.findParameterByKey("cerberus_notification_accountcreation_cc", system).getValue();
    String subject = parameterService.findParameterByKey("cerberus_notification_forgotpassword_subject", system).getValue();
    String body = parameterService.findParameterByKey("cerberus_notification_forgotpassword_body", system).getValue();
    body = body.replace("%NAME%", user.getName());
    body = body.replace("%LOGIN%", user.getLogin());
    String cerberusUrl = parameterService.findParameterByKey("cerberus_url", system).getValue();
    StringBuilder sb = new StringBuilder();
    sb.append("<a href='");
    sb.append(cerberusUrl);
    sb.append("/ChangePassword.jsp?login=");
    sb.append(user.getLogin());
    sb.append("&confirmationToken=");
    sb.append(user.getResetPasswordToken());
    sb.append("'>Click here to reset your password</a>");
    body = body.replace("%LINK%", sb.toString());
    email = emailFactory.create(host, port, userName, password, true, subject, body, from, to, cc);
    return email;
}
Also used : Email(org.cerberus.service.email.entity.Email)

Example 10 with Email

use of org.cerberus.service.email.entity.Email in project cerberus-source by cerberustesting.

the class EmailGenerationService method generateDisableEnvEmail.

@Override
public Email generateDisableEnvEmail(String system, String country, String env) throws Exception {
    Email email = new Email();
    CountryEnvParam myCountryEnvParam;
    myCountryEnvParam = countryEnvParamService.convert(countryEnvParamService.readByKey(system, country, env));
    /* Pick the datas from the database */
    String from = parameterService.findParameterByKey("cerberus_smtp_from", system).getValue();
    String host = parameterService.findParameterByKey("cerberus_smtp_host", system).getValue();
    int port = Integer.valueOf(parameterService.findParameterByKey("cerberus_smtp_port", system).getValue());
    String userName = parameterService.findParameterByKey("cerberus_smtp_username", system).getValue();
    String password = parameterService.findParameterByKey("cerberus_smtp_password", system).getValue();
    String to = parameterService.findParameterByKey("cerberus_notification_disableenvironment_to", system).getValue();
    String cc = parameterService.findParameterByKey("cerberus_notification_disableenvironment_cc", system).getValue();
    String subject = parameterService.findParameterByKey("cerberus_notification_disableenvironment_subject", system).getValue();
    String body = parameterService.findParameterByKey("cerberus_notification_disableenvironment_body", system).getValue();
    if (!StringUtil.isNullOrEmptyOrNull(myCountryEnvParam.geteMailBodyDisableEnvironment())) {
        body = myCountryEnvParam.geteMailBodyDisableEnvironment();
    }
    if (!StringUtil.isNullOrEmptyOrNull(myCountryEnvParam.getDistribList())) {
        to = myCountryEnvParam.getDistribList();
    }
    subject = subject.replace("%SYSTEM%", system);
    subject = subject.replace("%COUNTRY%", country);
    subject = subject.replace("%ENV%", env);
    subject = subject.replace("%BUILD%", myCountryEnvParam.getBuild());
    subject = subject.replace("%REVISION%", myCountryEnvParam.getRevision());
    body = body.replace("%SYSTEM%", system);
    body = body.replace("%COUNTRY%", country);
    body = body.replace("%ENV%", env);
    body = body.replace("%BUILD%", myCountryEnvParam.getBuild());
    body = body.replace("%REVISION%", myCountryEnvParam.getRevision());
    email = emailFactory.create(host, port, userName, password, true, subject, body, from, to, cc);
    return email;
}
Also used : Email(org.cerberus.service.email.entity.Email) CountryEnvParam(org.cerberus.crud.entity.CountryEnvParam)

Aggregations

Email (org.cerberus.service.email.entity.Email)13 CountryEnvParam (org.cerberus.crud.entity.CountryEnvParam)5 MessageEvent (org.cerberus.engine.entity.MessageEvent)5 IOException (java.io.IOException)3 ServletException (javax.servlet.ServletException)3 IEmailGenerationService (org.cerberus.service.email.IEmailGenerationService)3 Answer (org.cerberus.util.answer.Answer)3 JSONObject (org.json.JSONObject)3 ApplicationContext (org.springframework.context.ApplicationContext)3 HtmlEmail (org.apache.commons.mail.HtmlEmail)2 Campaign (org.cerberus.crud.entity.Campaign)2 ICountryEnvParamService (org.cerberus.crud.service.ICountryEnvParamService)2 ICountryEnvParam_logService (org.cerberus.crud.service.ICountryEnvParam_logService)2 ILogEventService (org.cerberus.crud.service.ILogEventService)2 IParameterService (org.cerberus.crud.service.IParameterService)2 IEmailService (org.cerberus.service.email.IEmailService)2 JSONException (org.json.JSONException)2 PolicyFactory (org.owasp.html.PolicyFactory)2 PrintWriter (java.io.PrintWriter)1 DecimalFormat (java.text.DecimalFormat)1