Package org.xwiki.mail.script
Class MailStorageScriptService
- java.lang.Object
-
- org.xwiki.mail.script.AbstractMailScriptService
-
- org.xwiki.mail.script.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 $
-
-
Field Summary
-
Fields inherited from class org.xwiki.mail.script.AbstractMailScriptService
componentManagerProvider, execution, mailSender, senderConfiguration, sessionFactory
-
-
Constructor Summary
Constructors Constructor Description MailStorageScriptService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
count(Map<String,Object> filterMap)
Count the number of message statuses matching the passed filters.void
delete(String batchId)
Delete all messages from a batch (both the statuses in the database and the serialized messages on the file system).void
delete(String batchId, String uniqueMessageId)
Delete a message (both the status in the database and the serialized messages on the file system).void
deleteAll()
Delete all messages having a status in the database and their serialized messages on the file system.MailStorageConfiguration
getConfiguration()
protected String
getErrorKey()
MailStatus
load(String uniqueMessageId)
Load message status for the message matching the given message Id.List<MailStatus>
load(Map<String,Object> filterMap, int offset, int count, String sortField, boolean sortAscending)
Loads all message statuses matching the passed filters.ScriptMailResult
resend(String batchId, String uniqueMessageId)
Resend the serialized MimeMessage synchronously.List<ScriptMailResult>
resend(Map<String,Object> filterMap, int offset, int count)
Resends all mails matching the passed filter map, synchronously (one mail after another).ScriptMailResult
resendAsynchronously(String batchId, String uniqueMessageId)
Resend the serialized MimeMessage asynchronously.List<ScriptMailResult>
resendAsynchronously(Map<String,Object> filterMap, int offset, int count)
Resends all mails matching the passed filter map, asynchronously.-
Methods inherited from class org.xwiki.mail.script.AbstractMailScriptService
getLastError, sendAsynchronously, setError
-
-
-
-
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 MimeMessageuniqueMessageId
- 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 MimeMessageuniqueMessageId
- 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 returnedsortField
- the name of the field used to order returned statussortAscending
- 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 deleteuniqueMessageId
- the unique id of the message to delete
-
getConfiguration
public MailStorageConfiguration getConfiguration()
- Returns:
- the configuration for the Mail Storage
-
getErrorKey
protected String getErrorKey()
- Specified by:
getErrorKey
in classAbstractMailScriptService
-
-