Class MailHandlerImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseNetworkedHandlerImpl
-
- org.cyclos.impl.utils.notifications.MailHandlerImpl
-
- All Implemented Interfaces:
MailHandler,MailHandlerImplementor
public class MailHandlerImpl extends BaseNetworkedHandlerImpl implements MailHandlerImplementor
Implementation forMailHandler
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description MailHandlerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringapplyTemplate(ApplyMailTemplateParams params)Applies the configured e-mail template.MailProcessingContextcreateMailProcessingContext(String toName, String toEmail, String subject, String body, ConfigurationAccessor configurationAccessor, FileInfo... attachments)Returns the context for sending an e-mail with the given information.protected MailProcessingContextcreateMailProcessingContext(BasicUser from, BasicUser to, MailContext context, MailContentProducer producer, FileInfo... attachments)Creates the context to process the mail with the given information and makes some validations.JavaMailSendergetMailSender()Returns a JavaMailSender for the current configurationJavaMailSendergetMailSender(Configuration configuration)Returns a JavaMailSender for the given configurationJavaMailSendergetMailSender(ConfigurationAccessor configuration)Returns a JavaMailSender for the given configuration accessorprotected voidprocessMailProcessingContext(MailProcessingContext mail)voidsend(String toName, String toEmail, String subject, String body, FileInfo... attachments)Sends a new e-mail with the given information.voidsend(BasicUser from, BasicUser to, MailContext context, MailContentProducer producer, FileInfo... attachments)Creates a new e-mail pending to be sent byMailProcessingPollingTask.
If context is FORWARD_INTERNAL_MESSAGE: The "From name" of the message will be the name of the given from user The "From address" of the message will be the one declared in the configuration of the given from user. The "Reply-to address" of the message will be the address of the given from user. If context is NEW_EMAIL_VALIDATION: The "To address" will be the new emailbooleansendNow(MailProcessingContext mail, JavaMailSender mailSender)Actually send the e-mail-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Method Detail
-
applyTemplate
public String applyTemplate(ApplyMailTemplateParams params)
Description copied from interface:MailHandlerApplies the configured e-mail template. Variables in the form{name}are replaced. All profile field variables are supported (seeProfileFieldHandler#getProfileFieldVariables(BasicUser)), plus others, such as:subject,message,salutation,unsubscribe,applicationName,date,dateTime,day,monthandyear.- Specified by:
applyTemplatein interfaceMailHandler
-
createMailProcessingContext
public MailProcessingContext createMailProcessingContext(String toName, String toEmail, String subject, String body, ConfigurationAccessor configurationAccessor, FileInfo... attachments)
Description copied from interface:MailHandlerReturns the context for sending an e-mail with the given information.- Specified by:
createMailProcessingContextin interfaceMailHandler- Parameters:
toName- Name of the receiver.toEmail- Email of the receiver.subject- Subject of the e-mailbody- Body of the e-mailconfigurationAccessor- The configuration accessor to get the from name/e-mailattachments- The e-mail attachments
-
getMailSender
public JavaMailSender getMailSender()
Description copied from interface:MailHandlerReturns a JavaMailSender for the current configuration- Specified by:
getMailSenderin interfaceMailHandler
-
getMailSender
public JavaMailSender getMailSender(Configuration configuration)
Description copied from interface:MailHandlerReturns a JavaMailSender for the given configuration- Specified by:
getMailSenderin interfaceMailHandler
-
getMailSender
public JavaMailSender getMailSender(ConfigurationAccessor configuration)
Description copied from interface:MailHandlerReturns a JavaMailSender for the given configuration accessor- Specified by:
getMailSenderin interfaceMailHandler
-
send
public void send(BasicUser from, BasicUser to, MailContext context, MailContentProducer producer, FileInfo... attachments)
Description copied from interface:MailHandlerCreates a new e-mail pending to be sent byMailProcessingPollingTask.
If context is FORWARD_INTERNAL_MESSAGE:- The "From name" of the message will be the name of the given from user
- The "From address" of the message will be the one declared in the configuration of the given from user.
- The "Reply-to address" of the message will be the address of the given from user.
If context is NEW_EMAIL_VALIDATION:- The "To address" will be the new email
- Specified by:
sendin interfaceMailHandler
-
send
public void send(String toName, String toEmail, String subject, String body, FileInfo... attachments)
Description copied from interface:MailHandlerSends a new e-mail with the given information.- Specified by:
sendin interfaceMailHandler- Parameters:
toName- Name of the receiver.toEmail- Email of the receiver.subject- Subject of the e-mailbody- Body of the e-mailattachments- The e-mail attachments
-
sendNow
public boolean sendNow(MailProcessingContext mail, JavaMailSender mailSender)
Description copied from interface:MailHandlerImplementorActually send the e-mail- Specified by:
sendNowin interfaceMailHandlerImplementor- Returns:
- false means the email was not send because an error has occurred otherwise true
-
createMailProcessingContext
protected MailProcessingContext createMailProcessingContext(BasicUser from, BasicUser to, MailContext context, MailContentProducer producer, FileInfo... attachments)
Creates the context to process the mail with the given information and makes some validations.
-
processMailProcessingContext
protected void processMailProcessingContext(MailProcessingContext mail)
-
-