Interface ISendMailDao

  • All Known Implementing Classes:
    SendMailDaoHib

    public interface ISendMailDao
    The DAO for sendmail persistence information.
    Since:
    4.0.4
    Version:
    $Revision: 17593 $ $Date: 2015-07-17 11:21:36 -0300 (Fri, 17 Jul 2015) $
    • Method Detail

      • createSingleMail

        ISingleMail createSingleMail​(IMultipleMail mail,
                                     IMailDestination destination)
        Returns a ISingleMail instance as the given mail addressed to the given destination.
        Parameters:
        mail - the mail.
        destination - the destination.
        Returns:
        the corresponding ISingleMail instance.
        Since:
        4.0.4
      • setMailConfig

        void setMailConfig​(IMailConfig mailConfig,
                           ITransaction transaction)
                    throws DaoException
        Sets the IMailConfig containing the configurations for sending e-mails.
        Parameters:
        mailConfig - the IMailConfig.
        transaction - the transaction for persistence access.
        Throws:
        DaoException - if it was not possible to set the IMailConfig.
        Since:
        4.0.4
        See Also:
        getMailConfig(ITransaction)
      • updateMailSendStatus

        void updateMailSendStatus​(IMailSendStatus mailSendStatus)
                           throws DaoException
        Updates the mail send status as set in the given instance. The update is committed immediatelly.
        Parameters:
        mailSendStatus - the mail send status information.
        Throws:
        DaoException
        Since:
        4.0.4
      • fetchNextQueuedMail

        IBaseMail fetchNextQueuedMail​(java.lang.String queueId)
                               throws DaoException
        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.

        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
        Since:
        4.0.4
      • unfetchMail

        void unfetchMail​(java.lang.String mailId)
                  throws DaoException
        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.
        Parameters:
        mailId - the mail id.
        Throws:
        DaoException
        Since:
        4.0.4
      • fetchNextPendingDestination

        IMailDestination fetchNextPendingDestination​(IMultipleMail multipleMail)
                                              throws DaoException
        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.

        Parameters:
        multipleMail - the mail.
        Returns:
        the destination or null if none was found.
        Throws:
        DaoException
        Since:
        4.0.4
      • lockNextQueue

        java.lang.String lockNextQueue()
                                throws DaoException
        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.

        Returns:
        the id of the locked queue, or null if there was no queue pending.
        Throws:
        DaoException
        Since:
        4.0.4
      • generateNewQueueId

        java.lang.String generateNewQueueId()
                                     throws DaoException
        Returns a new generated queue id.
        Returns:
        a new generated queue id.
        Throws:
        DaoException - if the queue id could not be generated.
        Since:
        4.0.4
      • unlockQueue

        void unlockQueue​(java.lang.String queueId)
                  throws DaoException
        Unlocks a mail queue.
        Parameters:
        queueId - the queue's id.
        Throws:
        DaoException
        Since:
        4.0.4
      • deleteMail

        void deleteMail​(java.lang.String mailId,
                        ITransaction transaction)
                 throws DaoException
        Deletes the whole mail structure, including the body, attachments, destinations.
        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.
        Since:
        4.0.4
      • deleteMailBody

        void deleteMailBody​(java.lang.String mailId,
                            ITransaction transaction)
                     throws DaoException
        Deletes the whole mail's body, including the body message and the attachments.
        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.
        Since:
        4.0.4
      • deleteMailDestination

        void deleteMailDestination​(java.lang.String mailDestinationId,
                                   ITransaction transaction)
                            throws DaoException
        Deletes the mail destination.
        Parameters:
        mailDestinationId - the id of the mail destination to be deleted.
        transaction - the transaction for persistence access.
        Throws:
        DaoException - if it was not possible to delete the mail destination.
        Since:
        8.1.0