com.konakartadmin.bl
Class AdminEmailMgr

java.lang.Object
  extended by com.konakartadmin.bl.AdminBaseMgr
      extended by com.konakartadmin.bl.AdminEmailMgr
All Implemented Interfaces:
AdminEmailMgrIf

public class AdminEmailMgr
extends AdminBaseMgr
implements AdminEmailMgrIf

Manager for sending emails


Nested Class Summary
 
Nested classes/interfaces inherited from class com.konakartadmin.bl.AdminBaseMgr
AdminBaseMgr.StaticData
 
Field Summary
protected  java.lang.String imageBase
           
protected static org.apache.commons.logging.Log log
          the log
protected  java.lang.String logFileDirectory
           
protected static java.lang.String NEW_PASSWORD_TEMPLATE
           
protected static java.lang.String ORDER_STATUS_CHANGE_TEMPLATE
           
protected  java.lang.String pdfBase
           
protected  java.lang.String storeName
           
protected  java.lang.String storeOwner
           
protected  java.lang.String storeOwnerEmailAddr
           
 
Fields inherited from class com.konakartadmin.bl.AdminBaseMgr
adminEng, baseMgrMutex, baseStaticDataHM, cDataEnd, cDataStart, kkConf, kkInstanceId, mgrFactory, STORE_ID, templateBaseDir
 
Constructor Summary
AdminEmailMgr(KKAdminIf eng)
          Constructor
 
Method Summary
protected  com.konakart.bl.EmailConfig getConfigData()
          Return an EmailConfig object that contains attributes required to configure the eMail.
 com.konakart.bl.Emailer getEmailer()
           
protected  javax.mail.Address getMailAddressFromString(java.lang.String addrString)
          Return an Address for the specified String.
protected  org.apache.velocity.app.VelocityEngine getVelocityEngine()
          Returns the Velocity engine
protected  void refreshPrivateConfigs()
          Refresh the Configuration variables for this manager Setup variables needed to send the mail
 boolean sendEmail(AdminEmail adminEmailData)
          To send an email
 void sendHTML(java.lang.String toAddressString, java.lang.String theSubject, java.lang.String theContentHTML, boolean doBlindCopy, boolean async)
          Send a HTML-only email message to the specified recipient, with the specified subject and HTML content.
 void sendHTML(java.lang.String toAddressString, java.lang.String theSubject, java.lang.String theContentHTML, boolean doBlindCopy, java.lang.String fullAttachmentFilename, java.lang.String friendlyAttachmentName, boolean deleteAttachmentAfterSend, boolean async)
          Send a HTML-only email message to the specified recipient, with the specified subject and HTML content.
 void sendNewPasswordEmail(java.lang.String emailAddr, java.lang.String newPassword, java.lang.String mailSubject, java.lang.String countryCode)
          Send out an email notifying a user of a new password
 void sendStatusChangeEmail(int orderId)
          A status change email is sent when the status of an order is changed
 void sendStatusChangeEmailForState(int orderId, int state)
          A status change email is sent when the status of an order is changed.
protected  void sendStatusChangeEmailPrivate(int orderId, int state)
          A status change email is sent when the status of an order is changed.
 void sendTemplateEmail(AdminCustomer customer, java.lang.String templateName, java.lang.Object obj1, java.lang.Object obj2, java.lang.Object obj3, java.lang.Object obj4, java.lang.Object obj5, AdminEmailOptions options)
          An email is sent to the customer.
 void sendText(java.lang.String toAddressString, java.lang.String theSubject, java.lang.String theContentText, boolean doBlindCopy, boolean async)
          Send a text-only email message to the specified recipient, with the specified subject and text content.
 void sendText(java.lang.String toAddressString, java.lang.String fromAddressString, java.lang.String replyToAddressString, java.lang.String theSubject, java.lang.String theContentText, boolean doBlindCopy, boolean async)
          Send a text-only email message to the specified recipient, with the specified subject and text content.
 
Methods inherited from class com.konakartadmin.bl.AdminBaseMgr
addInsertAttr, addInsertAttr, checkIntIsSet, checkRequired, getAdminAddressMgr, getAdminAuditMgr, getAdminBillingMgr, getAdminBookableProductMgr, getAdminCatMgr, getAdminConfigMgr, getAdminCurrMgr, getAdminCustMgr, getAdminCustTagMgr, getAdminEmailMgr, getAdminEng, getAdminHtmlMgr, getAdminLanguageMgr, getAdminManuMgr, getAdminMessageMgr, getAdminMiscItemMgr, getAdminModulesMgr, getAdminMultiStoreMgr, getAdminOrderMgr, getAdminPdfMgr, getAdminProdAttrMgr, getAdminProdMgr, getAdminPromMgr, getAdminPublishProdMgr, getAdminReviewMgr, getAdminSearchRuleMgr, getAdminSecMgr, getAdminSolrMgr, getAdminStoreMgr, getAdminTagMgr, getAdminTaxMgr, getAdminValidationMgr, getAdminVelocityContextMgr, getAdminWishListMgr, getBooleanFromString, getExportXMLData, getIntFromString, getKkConfig, getKkInstanceId, getMode, getModeString, getMqMgr, getNewCriteria, getNewCriteria, getPostSearchText, getPreSearchText, getPropertyValue, getRecordCount, getRewardPointMgr, getSingleIntResult, getStoreId, getTemplate, getTemplateBase, getXml_io, init, isConfigSet, isEnterprise, isMultiStoreLanguagesShared, isMultiStoreMode, isMultiStoreShareCategories, isMultiStoreShareCustomers, isMultiStoreShareProducts, isMultiStoreSingleDBCSMode, isMultiStoreSingleDBMode, isMultiStoreSingleDBNonCSMode, manageException, refreshConfigs, removeCData, setAdminEng, setupWildCardRules, setWildCardAfter, setWildCardBefore, shutdownGracefully, shutdownGracefully, timestampStr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
the log


storeOwner

protected java.lang.String storeOwner

storeName

protected java.lang.String storeName

storeOwnerEmailAddr

protected java.lang.String storeOwnerEmailAddr

logFileDirectory

protected java.lang.String logFileDirectory

pdfBase

protected java.lang.String pdfBase

imageBase

protected java.lang.String imageBase

NEW_PASSWORD_TEMPLATE

protected static final java.lang.String NEW_PASSWORD_TEMPLATE
See Also:
Constant Field Values

ORDER_STATUS_CHANGE_TEMPLATE

protected static final java.lang.String ORDER_STATUS_CHANGE_TEMPLATE
See Also:
Constant Field Values
Constructor Detail

AdminEmailMgr

public AdminEmailMgr(KKAdminIf eng)
              throws java.lang.Exception
Constructor

Parameters:
eng - KKAdmin engine
Throws:
java.lang.Exception
Method Detail

refreshPrivateConfigs

protected void refreshPrivateConfigs()
                              throws java.lang.Exception
Refresh the Configuration variables for this manager Setup variables needed to send the mail

Throws:
java.lang.Exception

sendEmail

public boolean sendEmail(AdminEmail adminEmailData)
                  throws KKAdminException
To send an email

Specified by:
sendEmail in interface AdminEmailMgrIf
Parameters:
adminEmailData - the Email object to fill out to define the email to send
Returns:
true if the email is sent successfully, and exception is raised in other cases
Throws:
KKAdminException - typically when the email could not be sent

sendNewPasswordEmail

public void sendNewPasswordEmail(java.lang.String emailAddr,
                                 java.lang.String newPassword,
                                 java.lang.String mailSubject,
                                 java.lang.String countryCode)
                          throws java.lang.Exception
Send out an email notifying a user of a new password

Specified by:
sendNewPasswordEmail in interface AdminEmailMgrIf
Parameters:
emailAddr - Email address to send to - the TO: address
newPassword - the new password that was randomly generated
mailSubject - the email subject line
countryCode - country code (to pick the appropriate velocity template)
Throws:
java.lang.Exception

sendHTML

public void sendHTML(java.lang.String toAddressString,
                     java.lang.String theSubject,
                     java.lang.String theContentHTML,
                     boolean doBlindCopy,
                     boolean async)
              throws KKAdminException
Send a HTML-only email message to the specified recipient, with the specified subject and HTML content.

Specified by:
sendHTML in interface AdminEmailMgrIf
Parameters:
toAddressString - the TO: address
theSubject - the subject line of the email
theContentHTML - the HTML body of the email
doBlindCopy - if true the defined Blind Copy address will be added
async - set to true to send the mail asynchronously or false to send it synchronously
Throws:
KKAdminException

sendHTML

public void sendHTML(java.lang.String toAddressString,
                     java.lang.String theSubject,
                     java.lang.String theContentHTML,
                     boolean doBlindCopy,
                     java.lang.String fullAttachmentFilename,
                     java.lang.String friendlyAttachmentName,
                     boolean deleteAttachmentAfterSend,
                     boolean async)
              throws KKAdminException
Send a HTML-only email message to the specified recipient, with the specified subject and HTML content.

Parameters:
toAddressString - the TO: address
theSubject - the subject line of the email
theContentHTML - the HTML body of the email
doBlindCopy - if true the defined Blind Copy address will be added
fullAttachmentFilename - full filename of the attachment
friendlyAttachmentName - friendly name to use for the attachment * @param async set to true to send the mail asynchronously or false to send it synchronously
deleteAttachmentAfterSend -
async -
Throws:
KKAdminException

sendText

public void sendText(java.lang.String toAddressString,
                     java.lang.String theSubject,
                     java.lang.String theContentText,
                     boolean doBlindCopy,
                     boolean async)
              throws KKAdminException
Send a text-only email message to the specified recipient, with the specified subject and text content.

Specified by:
sendText in interface AdminEmailMgrIf
Parameters:
toAddressString - the TO: address
theSubject - the subject line of the email
theContentText - the plain text body of the email
doBlindCopy - if true the defined Blind Copy address will be added
async - set to true to send the mail asynchronously or false to send it synchronously
Throws:
KKAdminException

sendText

public void sendText(java.lang.String toAddressString,
                     java.lang.String fromAddressString,
                     java.lang.String replyToAddressString,
                     java.lang.String theSubject,
                     java.lang.String theContentText,
                     boolean doBlindCopy,
                     boolean async)
              throws KKAdminException
Send a text-only email message to the specified recipient, with the specified subject and text content.

Specified by:
sendText in interface AdminEmailMgrIf
Parameters:
toAddressString - TO: address
fromAddressString - From address
replyToAddressString - reply to address
theSubject -
theContentText - the plain text body of the email
doBlindCopy - if true the defined Blind Copy address will be added
async - set to true to send the mail asynchronously or false to send it synchronously
Throws:
KKAdminException

sendStatusChangeEmailForState

public void sendStatusChangeEmailForState(int orderId,
                                          int state)
                                   throws java.lang.Exception
A status change email is sent when the status of an order is changed. A different template can be picked up depending on the state of the order. Set state to -1 to pick up the default template.

Specified by:
sendStatusChangeEmailForState in interface AdminEmailMgrIf
Parameters:
orderId - the order Id of the order whose status has changed
state - the state of the order
Throws:
java.lang.Exception

sendStatusChangeEmail

public void sendStatusChangeEmail(int orderId)
                           throws java.lang.Exception
A status change email is sent when the status of an order is changed

Specified by:
sendStatusChangeEmail in interface AdminEmailMgrIf
Parameters:
orderId - the order Id of the order whose status has changed
Throws:
java.lang.Exception

sendStatusChangeEmailPrivate

protected void sendStatusChangeEmailPrivate(int orderId,
                                            int state)
                                     throws java.lang.Exception
A status change email is sent when the status of an order is changed. A different template can be picked up depending on the state of the order.

Parameters:
orderId - the order Id of the order whose status has changed
state - the state of the order
Throws:
java.lang.Exception

getEmailer

public com.konakart.bl.Emailer getEmailer()
                                   throws KKAdminException
Specified by:
getEmailer in interface AdminEmailMgrIf
Returns:
Returns a new Emailer.
Throws:
KKAdminException

getConfigData

protected com.konakart.bl.EmailConfig getConfigData()
                                             throws java.lang.Exception
Return an EmailConfig object that contains attributes required to configure the eMail. The values are stored in configuration parameters and konakart_mail.properties

Returns:
returns an EmailConfig object
Throws:
java.lang.Exception

getMailAddressFromString

protected javax.mail.Address getMailAddressFromString(java.lang.String addrString)
                                               throws KKAdminException
Return an Address for the specified String.

Parameters:
addrString - the address in String form
Returns:
An Internet Address
Throws:
com.konakart.app.KKException
KKAdminException

sendTemplateEmail

public void sendTemplateEmail(AdminCustomer customer,
                              java.lang.String templateName,
                              java.lang.Object obj1,
                              java.lang.Object obj2,
                              java.lang.Object obj3,
                              java.lang.Object obj4,
                              java.lang.Object obj5,
                              AdminEmailOptions options)
                       throws java.lang.Exception
An email is sent to the customer. The email is generated by the template called templateName and the objects obj1-obj5 are passed to the template. The subject of the eMail is picked up from the first line of the template.

Specified by:
sendTemplateEmail in interface AdminEmailMgrIf
Parameters:
customer - The customer to which the eMail will be sent. It will be passed to the velocity template with the name "cust".
templateName - The name of the template. The country code and .vm will be appended automatically. i.e. If the template name is newsletter and the country code is en, then we will look for a file called newsletter_en.vm. This file should be in the classpath.
obj1 - This object will be passed to the velocity template with the name "obj1".
obj2 - This object will be passed to the velocity template with the name "obj2".
obj3 - This object will be passed to the velocity template with the name "obj3".
obj4 - This object will be passed to the velocity template with the name "obj4".
obj5 - This object will be passed to the velocity template with the name "obj5".
options - Email Options
Throws:
java.lang.Exception

getVelocityEngine

protected org.apache.velocity.app.VelocityEngine getVelocityEngine()
                                                            throws java.lang.Exception
Returns the Velocity engine

Returns:
Returns a VelocityEngine
Throws:
java.lang.Exception


Copyright © 2011 DS Data Systems UK Ltd.