lumis.portal.sendmail.dao.hibernate
Class SendMailDaoHib

Package class diagram package SendMailDaoHib
java.lang.Object
  extended by lumis.portal.sendmail.dao.hibernate.SendMailDaoHib
All Implemented Interfaces:
ISendMailDao

public class SendMailDaoHib
extends Object
implements ISendMailDao

Hibernate based implementation of ISendMailDao.

Since:
4.0.4

Constructor Summary
SendMailDaoHib()
           
 
Method Summary
 void addMailToSendQueue(IMultipleMail mail, String queueId, ITransaction transaction)
          Adds an mail to the send queue.
 void addMailToSendQueue(ISingleMail mail, String queueId, ITransaction transaction)
          Adds an mail to the send queue.
 IMailAttachment createMailAttachment()
          Factory method for creating a new mail attachment instance.
 IMailDestination createMailDestination()
          Factory method for creating a new mail destination instance.
 IMultipleMail createMultipleMail()
          Factory method for creating a new blank mail instance.
 ISingleMail createSingleMail()
          Factory method for creating a new blank mail instance.
 ISingleMail createSingleMail(IMultipleMail mail, IMailDestination destination)
          This implementation actually uses the same mail instance, only sets the values in the to, cc and bcc fields.
 void deleteMail(String mailId, ITransaction transaction)
          Deletes the whole mail structure, including the body, attachments, destinations.
 void deleteMailBody(String mailId, ITransaction transaction)
          Deletes the whole mail's body, including the body message and the attachments.
 IMailDestination fetchNextPendingDestination(IMultipleMail mail)
          Returns for the next destination pending for sending for the given mail, and marks its status as sending.
 IBaseMail fetchNextQueuedMail(String queueId)
          Returns the next queued mail pending for sending, and marks its status as sending.
 String generateNewQueueId()
          Returns a new generated queue id.
 IMailConfig getMailConfig(ITransaction transaction)
          Returns the IMailConfig containing the configurations for sending e-mails.
 String lockNextQueue()
          Locks the next queue mail available and returns its id.
 void setMailConfig(IMailConfig mailConfig, ITransaction transaction)
          Sets the IMailConfig containing the configurations for sending e-mails.
 void unfetchMail(String mailId)
          Puts a mail back on its place in the queue to be available to another queue processing.
 void unlockQueue(String queueId)
          Unlocks a mail queue.
 void updateMailSendStatus(IMailSendStatus mailSendStatus)
          Updates the mail send status as set in the given instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SendMailDaoHib

public SendMailDaoHib()
Method Detail

createMultipleMail

public IMultipleMail createMultipleMail()
                                 throws PortalException
Description copied from interface: ISendMailDao
Factory method for creating a new blank mail instance. Use this method to obtain an instance of IMultipleMail, to fill it with the required data and use it in the other methods in this interface.

Specified by:
createMultipleMail in interface ISendMailDao
Returns:
a new blank mail instance.
Throws:
PortalException
See Also:
ISendMailDao.createSingleMail(), ISendMailDao.createMailAttachment(), ISendMailDao.createMailDestination()

createSingleMail

public ISingleMail createSingleMail()
                             throws PortalException
Description copied from interface: ISendMailDao
Factory method for creating a new blank mail instance. Use this method to obtain an instance of ISingleMail, to fill it with the required data and use it in the other methods in this interface.

Specified by:
createSingleMail in interface ISendMailDao
Returns:
a new blank mail instance.
Throws:
PortalException
See Also:
ISendMailDao.createMultipleMail(), ISendMailDao.createMailAttachment()

createMailAttachment

public IMailAttachment createMailAttachment()
Description copied from interface: ISendMailDao
Factory method for creating a new mail attachment instance. Use this method to obtain an instance of IMailAttachment, to fill it with the required data and use it in the other methods in this interface.

Specified by:
createMailAttachment in interface ISendMailDao
Returns:
a new mail attachment instance.
See Also:
ISendMailDao.createSingleMail(), ISendMailDao.createMultipleMail(), IMailBody.getAttachments()

createMailDestination

public IMailDestination createMailDestination()
Description copied from interface: ISendMailDao
Factory method for creating a new mail destination instance. Use this method to obtain an instance of IMailDestination, to fill it with the required data and use it in the other methods in this interface.

Specified by:
createMailDestination in interface ISendMailDao
Returns:
a new mail destination instance.
See Also:
ISendMailDao.createMultipleMail(), IMultipleMail.getDestinations()

generateNewQueueId

public String generateNewQueueId()
                          throws DaoException
Description copied from interface: ISendMailDao
Returns a new generated queue id.

Specified by:
generateNewQueueId in interface ISendMailDao
Returns:
a new generated queue id.
Throws:
DaoException - if the queue id could not be generated.

getMailConfig

public IMailConfig getMailConfig(ITransaction transaction)
                          throws DaoException
Description copied from interface: ISendMailDao
Returns the IMailConfig containing the configurations for sending e-mails.

Specified by:
getMailConfig in interface ISendMailDao
Parameters:
transaction - the transaction for persistence access.
Returns:
the IMailConfig, never null.
Throws:
DaoException - if it was not possible to obtain the IMailConfig.
See Also:
ISendMailDao.setMailConfig(IMailConfig, ITransaction)

setMailConfig

public void setMailConfig(IMailConfig mailConfig,
                          ITransaction transaction)
                   throws DaoException
Description copied from interface: ISendMailDao
Sets the IMailConfig containing the configurations for sending e-mails.

Specified by:
setMailConfig in interface ISendMailDao
Parameters:
mailConfig - the IMailConfig.
transaction - the transaction for persistence access.
Throws:
DaoException - if it was not possible to set the IMailConfig.
See Also:
ISendMailDao.getMailConfig(ITransaction)

addMailToSendQueue

public void addMailToSendQueue(ISingleMail mail,
                               String queueId,
                               ITransaction transaction)
                        throws DaoException
Description copied from interface: ISendMailDao
Adds an mail to the send queue.

Specified by:
addMailToSendQueue in interface ISendMailDao
Parameters:
mail - the mail. This instance must have been created by ISendMailDao.createSingleMail().
queueId - the id of the queue where the mail will be added to. If null a new queue will be generated.
transaction - the transaction for persistence access.
Throws:
DaoException - if it was not possible to add the mail to the send queue.
See Also:
ISendMailDao.addMailToSendQueue(IMultipleMail, String, ITransaction), #createMail(), ISendMailDao.createMailAttachment()

addMailToSendQueue

public void addMailToSendQueue(IMultipleMail mail,
                               String queueId,
                               ITransaction transaction)
                        throws DaoException
Description copied from interface: ISendMailDao
Adds an mail to the send queue.

Specified by:
addMailToSendQueue in interface ISendMailDao
Parameters:
mail - the mail. This instance must have been created by ISendMailDao.createMultipleMail().
queueId - the id of the queue where the mail will be added to. If null a new queue will be generated.
transaction - the transaction for persistence access.
Throws:
DaoException - if it was not possible to add the mail to the send queue.
See Also:
ISendMailDao.addMailToSendQueue(ISingleMail, String, ITransaction), #createMail(), ISendMailDao.createMailAttachment(), ISendMailDao.createMailDestination()

createSingleMail

public ISingleMail createSingleMail(IMultipleMail mail,
                                    IMailDestination destination)
This implementation actually uses the same mail instance, only sets the values in the to, cc and bcc fields.

This can be done because both IMultipleMail and ISingleMail are implemented by the Mail class, but the ISingleMail destination fields are ignored when used as a IMultipleMail in this Dao.

Specified by:
createSingleMail in interface ISendMailDao
Parameters:
mail - the mail.
destination - the destination
Returns:
the corresponding ISingleMail instance.

fetchNextQueuedMail

public IBaseMail fetchNextQueuedMail(String queueId)
                              throws DaoException
Description copied from interface: ISendMailDao
Returns the next queued mail pending for sending, and marks its status as sending. Must also update the queue lock expiration date time.

This operation must be atomic and garantee that the same mail will not be returned many times, even if this method is called simultaneously by many threads in many servers in the cluster.

Specified by:
fetchNextQueuedMail in interface ISendMailDao
Parameters:
queueId - the id of the queue from where the mail will be taken.
Returns:
the mail or null if none was found.
Throws:
DaoException

unfetchMail

public void unfetchMail(String mailId)
                 throws DaoException
Description copied from interface: ISendMailDao
Puts a mail back on its place in the queue to be available to another queue processing. It status will be changed to IMailSendStatus.STATUS_SEND_PENDING.

Specified by:
unfetchMail in interface ISendMailDao
Parameters:
mailId - the mail id.
Throws:
DaoException

fetchNextPendingDestination

public IMailDestination fetchNextPendingDestination(IMultipleMail mail)
                                             throws DaoException
Description copied from interface: ISendMailDao
Returns for the next destination pending for sending for the given mail, and marks its status as sending. Must also update the corresponding queue lock expiration date time.

This operation must be atomic and garantee that the same destination will not be returned many times, even if this method is called simultaneously by many threads in many servers in the cluster.

Specified by:
fetchNextPendingDestination in interface ISendMailDao
Parameters:
mail - the mail.
Returns:
the destination or null if none was found.
Throws:
DaoException

updateMailSendStatus

public void updateMailSendStatus(IMailSendStatus mailSendStatus)
                          throws DaoException
Description copied from interface: ISendMailDao
Updates the mail send status as set in the given instance. The update is committed immediatelly.

Specified by:
updateMailSendStatus in interface ISendMailDao
Parameters:
mailSendStatus - the mail send status information.
Throws:
DaoException

lockNextQueue

public String lockNextQueue()
                     throws DaoException
Description copied from interface: ISendMailDao
Locks the next queue mail available and returns its id.

This operation must be atomic and garantee that a locked queue will not be returned, even if this method is called simultaneously by many threads in many servers in the cluster.

Specified by:
lockNextQueue in interface ISendMailDao
Returns:
the id of the locked queue, or null if there was no queue pending.
Throws:
DaoException

unlockQueue

public void unlockQueue(String queueId)
                 throws DaoException
Description copied from interface: ISendMailDao
Unlocks a mail queue.

Specified by:
unlockQueue in interface ISendMailDao
Parameters:
queueId - the queue's id.
Throws:
DaoException

deleteMail

public void deleteMail(String mailId,
                       ITransaction transaction)
                throws DaoException
Description copied from interface: ISendMailDao
Deletes the whole mail structure, including the body, attachments, destinations.

Specified by:
deleteMail in interface ISendMailDao
Parameters:
mailId - the id of the mail to be deleted.
transaction - the transaction for persistence access.
Throws:
DaoException - if it was not possible to delete the mail.

deleteMailBody

public void deleteMailBody(String mailId,
                           ITransaction transaction)
                    throws DaoException
Description copied from interface: ISendMailDao
Deletes the whole mail's body, including the body message and the attachments.

Specified by:
deleteMailBody in interface ISendMailDao
Parameters:
mailId - the id of the mail whose body is to be deleted.
transaction - the transaction for persistence access.
Throws:
DaoException - if it was not possible to delete the mail.


Lumisportal  4.1.0.071221 - Copyright © 2001-2007, Lumis. All Rights Reserved.