use of org.cerberus.service.email.entity.Email in project cerberus-source by cerberustesting.
the class EmailFactory method create.
@Override
public Email create(String host, int smtpPort, String userName, String password, boolean setTls, String subject, String body, String from, String to, String cc) {
Email email = new Email();
email.setBody(body);
email.setCc(cc);
email.setFrom(from);
email.setHost(host);
email.setPassword(password);
email.setSetTls(setTls);
email.setSmtpPort(smtpPort);
email.setSubject(subject);
email.setTo(to);
email.setUserName(userName);
return email;
}
use of org.cerberus.service.email.entity.Email in project cerberus-source by cerberustesting.
the class EmailGenerationService method generateAccountCreationEmail.
@Override
public Email generateAccountCreationEmail(User user) throws Exception {
String system = "";
Email email = new Email();
/* Pick the datas from the database */
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 to = user.getEmail();
String cc = cc = parameterService.findParameterByKey("cerberus_notification_accountcreation_cc", system).getValue();
String subject = parameterService.findParameterByKey("cerberus_notification_accountcreation_subject", system).getValue();
String body = parameterService.findParameterByKey("cerberus_notification_accountcreation_body", system).getValue();
body = body.replace("%NAME%", user.getName());
body = body.replace("%LOGIN%", user.getLogin());
body = body.replace("%DEFAULT_PASSWORD%", parameterService.findParameterByKey("cerberus_accountcreation_defaultpassword", system).getValue());
email = emailFactory.create(host, port, userName, password, true, subject, body, from, to, cc);
return email;
}
use of org.cerberus.service.email.entity.Email in project cerberus-source by cerberustesting.
the class EmailGenerationService method generateNewChainEmail.
@Override
public Email generateNewChainEmail(String system, String country, String env, String chain) throws Exception {
Email email = new Email();
/* Page Display - START */
CountryEnvParam myCountryEnvParam;
myCountryEnvParam = countryEnvParamService.convert(countryEnvParamService.readByKey(system, country, env));
BatchInvariant myBatchInvariant;
myBatchInvariant = batchInvariantService.convert(batchInvariantService.readByKey(chain));
String lastchain = myBatchInvariant.getBatch() + " (" + myBatchInvariant.getDescription() + ")";
/* 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_newchain_to", system).getValue();
String cc = parameterService.findParameterByKey("cerberus_notification_newchain_cc", system).getValue();
String subject = parameterService.findParameterByKey("cerberus_notification_newchain_subject", system).getValue();
String body = parameterService.findParameterByKey("cerberus_notification_newchain_body", system).getValue();
if (!StringUtil.isNullOrEmptyOrNull(myCountryEnvParam.geteMailBodyChain())) {
body = myCountryEnvParam.geteMailBodyChain();
}
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());
subject = subject.replace("%CHAIN%", lastchain);
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());
body = body.replace("%CHAIN%", lastchain);
email = emailFactory.create(host, port, userName, password, true, subject, body, from, to, cc);
return email;
}
use of org.cerberus.service.email.entity.Email in project cerberus-source by cerberustesting.
the class EmailGenerationService method generateRevisionChangeEmail.
@Override
public Email generateRevisionChangeEmail(String system, String country, String env, String build, String revision) 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_newbuildrevision_to", system).getValue();
String cc = parameterService.findParameterByKey("cerberus_notification_newbuildrevision_cc", system).getValue();
String subject = parameterService.findParameterByKey("cerberus_notification_newbuildrevision_subject", system).getValue();
String body = parameterService.findParameterByKey("cerberus_notification_newbuildrevision_body", system).getValue();
if (!StringUtil.isNullOrEmptyOrNull(myCountryEnvParam.geteMailBodyRevision())) {
body = myCountryEnvParam.geteMailBodyRevision();
}
if (!StringUtil.isNullOrEmptyOrNull(myCountryEnvParam.getDistribList())) {
to = myCountryEnvParam.getDistribList();
}
/* Replace the Keywords from the fed text */
subject = subject.replace("%SYSTEM%", system);
subject = subject.replace("%COUNTRY%", country);
subject = subject.replace("%ENV%", env);
subject = subject.replace("%BUILD%", build);
subject = subject.replace("%REVISION%", revision);
body = body.replace("%SYSTEM%", system);
body = body.replace("%COUNTRY%", country);
body = body.replace("%ENV%", env);
body = body.replace("%BUILD%", build);
body = body.replace("%REVISION%", revision);
// Generate the Table Contented in the mail
String content;
String lastBuild = myCountryEnvParam.getBuild();
String lastRev = myCountryEnvParam.getRevision();
content = emailBodyGeneration.GenerateBuildContentTable(system, build, revision, lastBuild, lastRev);
content = content.replace("$", " ");
body = body.replace("%BUILDCONTENT%", content);
content = emailBodyGeneration.GenerateTestRecapTable(system, build, revision, country);
content = content.replace("$", " ");
body = body.replace("%TESTRECAP%", content);
content = emailBodyGeneration.GenerateTestRecapTable(system, build, revision, "ALL");
content = content.replace("$", " ");
body = body.replace("%TESTRECAPALL%", content);
// End
email = emailFactory.create(host, port, userName, password, true, subject, body, from, to, cc);
return email;
}
use of org.cerberus.service.email.entity.Email in project cerberus-source by cerberustesting.
the class EmailService method generateAndSendNotifyEndTagExecution.
@Override
public MessageEvent generateAndSendNotifyEndTagExecution(String tag, String campaign) {
try {
Campaign myCampaign = campaignService.convert(campaignService.readByKey(campaign));
if (!StringUtil.isNullOrEmpty(myCampaign.getDistribList())) {
if (myCampaign.getNotifyEndTagExecution().equalsIgnoreCase(Campaign.NOTIFYSTARTTAGEXECUTION_Y) || myCampaign.getNotifyEndTagExecution().equalsIgnoreCase(Campaign.NOTIFYSTARTTAGEXECUTION_CIKO)) {
// Flag is activated.
JSONObject jsonResponse = new JSONObject();
jsonResponse = ciService.getCIResult(tag);
if (myCampaign.getNotifyEndTagExecution().equalsIgnoreCase(Campaign.NOTIFYSTARTTAGEXECUTION_Y) || (myCampaign.getNotifyEndTagExecution().equalsIgnoreCase(Campaign.NOTIFYSTARTTAGEXECUTION_CIKO) && jsonResponse.getString("result").equalsIgnoreCase("KO"))) {
// Flag is Y or CIKO with KO result.
Email email = null;
try {
email = emailGenerationService.generateNotifyEndTagExecution(tag, campaign, myCampaign.getDistribList(), jsonResponse.getString("result"), (double) jsonResponse.get("CI_finalResult"));
} catch (Exception ex) {
LOG.warn("Exception generating email for End Tag Execution :" + ex);
return new MessageEvent(MessageEventEnum.GENERIC_ERROR).resolveDescription("REASON", ex.toString());
}
try {
this.sendHtmlMail(email);
} catch (Exception ex) {
LOG.warn("Exception sending email for End Tag Execution :" + ex);
return new MessageEvent(MessageEventEnum.GENERIC_ERROR).resolveDescription("REASON", ex.toString());
}
}
}
}
} catch (Exception ex) {
LOG.warn("Exception generating email for End Tag Execution :" + ex);
return new MessageEvent(MessageEventEnum.GENERIC_ERROR).resolveDescription("REASON", ex.toString());
}
return new MessageEvent(MessageEventEnum.GENERIC_OK);
}
Aggregations