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; ...@@ -13,7 +13,13 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; 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.BaseLogger;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.utility.EMail; import ibase.utility.EMail;
import ibase.utility.MailInfo; import ibase.utility.MailInfo;
...@@ -43,16 +49,48 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB { ...@@ -43,16 +49,48 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
String emailID = mailFormatDetails.get("SEND_TO").toString(); String emailID = mailFormatDetails.get("SEND_TO").toString();
BaseLogger.log("3", null, null, "buildMailXMLStr emailID [" + emailID + "]"); BaseLogger.log("3", null, null, "buildMailXMLStr emailID [" + emailID + "]");
String bodyFilePath = mailFormatDetails.get("BODY").toString(); /*
* 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 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 = ""; String body = "";
try { try {
body = readHtmlFile(bodyFilePath); // body = readHtmlFile(bodyFilePath);
} catch (IOException e1) { body = responseString;
} catch (Exception e) {
mailXMLStr = "NULLHTML"; mailXMLStr = "NULLHTML";
BaseLogger.log("3", null, null, "Exception in readHtmlFile method [" + e1.getMessage() + "]"); BaseLogger.log("3", null, null, "Exception in readHtmlFile method [" + e.getMessage() + "]");
e1.printStackTrace(); e.printStackTrace();
return mailXMLStr; 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 = ""; String formatCode = "";
...@@ -113,6 +151,8 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB { ...@@ -113,6 +151,8 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
List<String> mailList = new ArrayList<String>(); List<String> mailList = new ArrayList<String>();
UserInfoBean userInfo = getUserInfo(); UserInfoBean userInfo = getUserInfo();
System.out.println("********************userinfo****************" + userInfo); System.out.println("********************userinfo****************" + userInfo);
BaseLogger.log("3", null, null, "sendEmail : xtraParams [" + xtraParams + "]");
try { try {
conn = getConnection(); conn = getConnection();
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
...@@ -359,9 +399,10 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB { ...@@ -359,9 +399,10 @@ public class MarketingCampaignPreSend extends ActionHandlerEJB {
UserInfoBean userInfo = getUserInfo(); UserInfoBean userInfo = getUserInfo();
System.out.println("********************userinfo****************" + userInfo); System.out.println("********************userinfo****************" + userInfo);
BaseLogger.log("3", null, null, "sendEmailToMe : xtraParams [" + xtraParams + "]");
try { try {
conn = getConnection(); 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, "user id [" + userId + "]");
BaseLogger.log("3", null, null, "tran id [" + tranId + "]"); 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