Class MailStorageScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Named("mail.storage")
    @Singleton
    public class MailStorageScriptService
    extends AbstractMailScriptService
    Expose Mail Storage API to scripts.
    Since:
    12.4RC1
    Version:
    $Id: 1d4e818d835178ff601e3662a17d048c87d84e39 $
    • Constructor Detail

      • MailStorageScriptService

        public MailStorageScriptService()
    • Method Detail

      • resend

        public ScriptMailResult resend​(String batchId,
                                       String uniqueMessageId)
        Resend the serialized MimeMessage synchronously.
        Parameters:
        batchId - the name of the directory that contains serialized MimeMessage
        uniqueMessageId - the unique id of the serialized MimeMessage
        Returns:
        the result and status of the send batch; null if an error occurred when getting the message from the store
      • resendAsynchronously

        public ScriptMailResult resendAsynchronously​(String batchId,
                                                     String uniqueMessageId)
        Resend the serialized MimeMessage asynchronously.
        Parameters:
        batchId - the name of the directory that contains serialized MimeMessage
        uniqueMessageId - the unique id of the serialized MimeMessage
        Returns:
        the result and status of the send batch; null if an error occurred when getting the message from the store
        Since:
        9.3RC1
      • resendAsynchronously

        public List<ScriptMailResult> resendAsynchronously​(Map<String,​Object> filterMap,
                                                           int offset,
                                                           int count)
        Resends all mails matching the passed filter map, asynchronously.
        Parameters:
        filterMap - the map of Mail Status parameters to match (e.g. "state", "wiki", "batchId", etc)
        offset - the number of rows to skip (0 means don't skip any row)
        count - the number of rows to return. If 0 then all rows are returned
        Returns:
        the mail results for the resent mails and null if an error occurred while loading the mail statuses from the store
        Since:
        9.3RC1
      • resend

        public List<ScriptMailResult> resend​(Map<String,​Object> filterMap,
                                             int offset,
                                             int count)
        Resends all mails matching the passed filter map, synchronously (one mail after another).
        Parameters:
        filterMap - the map of Mail Status parameters to match (e.g. "state", "wiki", "batchId", etc)
        offset - the number of rows to skip (0 means don't skip any row)
        count - the number of rows to return. If 0 then all rows are returned
        Returns:
        the mail results for the resent mails and null if an error occurred while loading the mail statuses from the store
        Since:
        12.10
      • load

        public MailStatus load​(String uniqueMessageId)
        Load message status for the message matching the given message Id.
        Parameters:
        uniqueMessageId - the unique identifier of the message.
        Returns:
        the loaded MailStatus or null if not allowed or an error happens
        Since:
        7.1M2
      • load

        public List<MailStatus> load​(Map<String,​Object> filterMap,
                                     int offset,
                                     int count,
                                     String sortField,
                                     boolean sortAscending)
        Loads all message statuses matching the passed filters.
        Parameters:
        filterMap - the map of Mail Status parameters to match (e.g. "status", "wiki", "batchId", etc)
        offset - the number of rows to skip (0 means don't skip any row)
        count - the number of rows to return. If 0 then all rows are returned
        sortField - the name of the field used to order returned status
        sortAscending - when true, sort is done in ascending order of sortField, else in descending order
        Returns:
        the loaded MailStatus instances or null if not allowed or an error happens
        Since:
        7.1M2
      • count

        public long count​(Map<String,​Object> filterMap)
        Count the number of message statuses matching the passed filters.
        Parameters:
        filterMap - the map of Mail Status parameters to match (e.g. "status", "wiki", "batchId", etc)
        Returns:
        the number of mail statuses or 0 if not allowed or an error happens
      • delete

        public void delete​(String batchId)
        Delete all messages from a batch (both the statuses in the database and the serialized messages on the file system).
        Parameters:
        batchId - the id of the batch for which to delete all messages
      • deleteAll

        public void deleteAll()
        Delete all messages having a status in the database and their serialized messages on the file system.
        Since:
        9.4RC1
      • delete

        public void delete​(String batchId,
                           String uniqueMessageId)
        Delete a message (both the status in the database and the serialized messages on the file system).
        Parameters:
        batchId - the id of the batch for the message to delete
        uniqueMessageId - the unique id of the message to delete