Commit 0ae727ff authored by Ajit Deshmukh's avatar Ajit Deshmukh

Change in sendEmailToMe method: replaced loginEmpCode with loginCode fetched...

Change in sendEmailToMe method: replaced loginEmpCode with loginCode fetched from xtraparams to send the mail to the user.
parent c1ac2910
......@@ -13,7 +13,13 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import ibase.utility.BaseLogger;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.EMail;
import ibase.utility.MailInfo;
......@@ -37,22 +43,54 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
BaseLogger.log("2", null, null,
"sendEmailToMe calling buildMailXMLStr-----------------[" + mailFormatDetails + " ]");
String mailXMLStr = "";
String mailXMLStr = "";
// Fetch mail format details from the database
String emailID = mailFormatDetails.get("SEND_TO").toString();
BaseLogger.log("3", null, null, "buildMailXMLStr emailID [" + emailID + "]");
/*
* Changes by Gagan B. on 08-OCT-24 to upload HTML to alfresco server in MAIL_FORMAT object and store the doc ID in MAIL_FORMAT.BODY_TEXT and use the same doc ID to retrieve
* the document and use it to display data in template and while sending the mail. -- START
*/
String getDocumentURL = CommonConstants.TOMCAT_HOME +
"/ibase/rest/E12ExtService/getDocumentStream";
Unirest.setTimeouts(0, 0);
HttpResponse<String> getDocumentResponse = null;
try {
getDocumentResponse = Unirest.post(getDocumentURL)
.header("TOKEN_ID", userInfo.getTokenID())
.field("DOC_ID", mailFormatDetails.get("BODY").toString())
.asString();
} catch (Exception e) {
BaseLogger.log("3", null, null, "Exception in MktgCmpgnPreSend.buildXMLStr [" + E12GenericUtility.getStackTrace(e) + "]");
String bodyFilePath = mailFormatDetails.get("BODY").toString();
}
String statusText = getDocumentResponse.getStatusText();
int statusCode = getDocumentResponse.getStatus();
String responseString = getDocumentResponse.getBody().toString();
BaseLogger.log("3", null, null, "Inside saveNewEmailTemplate getSelectedEmailXmlData [" + statusText + "]");
BaseLogger.log("3", null, null, "Inside saveNewEmailTemplate getSelectedEmailXmlData [" + statusCode + "]");
BaseLogger.log("3", null, null, "Inside saveNewEmailTemplate getSelectedEmailXmlData [" + responseString + "]");
// String bodyFilePath = mailFormatDetails.get("BODY").toString();
String body = "";
try {
body = readHtmlFile(bodyFilePath);
} catch (IOException e1) {
// body = readHtmlFile(bodyFilePath);
body = responseString;
} catch (Exception e) {
mailXMLStr = "NULLHTML";
BaseLogger.log("3", null, null, "Exception in readHtmlFile method [" + e1.getMessage() + "]");
e1.printStackTrace();
BaseLogger.log("3", null, null, "Exception in readHtmlFile method [" + e.getMessage() + "]");
e.printStackTrace();
return mailXMLStr;
}
/*
* Changes by Gagan B. on 08-OCT-24 to upload HTML to alfresco server in MAIL_FORMAT object and store the doc ID in MAIL_FORMAT.BODY_TEXT and use the same doc ID to retrieve
* the document and use it to display data in template and while sending the mail. -- END
*/
String formatCode = "";
......@@ -113,6 +151,8 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
List<String> mailList = new ArrayList<String>();
UserInfoBean userInfo = getUserInfo();
System.out.println("********************userinfo****************" + userInfo);
BaseLogger.log("3", null, null, "sendEmail : xtraParams [" + xtraParams + "]");
try {
conn = getConnection();
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
......@@ -359,9 +399,10 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
UserInfoBean userInfo = getUserInfo();
System.out.println("********************userinfo****************" + userInfo);
BaseLogger.log("3", null, null, "sendEmailToMe : xtraParams [" + xtraParams + "]");
try {
conn = getConnection();
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
BaseLogger.log("3", null, null, "user id [" + userId + "]");
BaseLogger.log("3", null, null, "tran id [" + tranId + "]");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment