Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
ScriptMailResult | 33 | 6 | 0% | 5 | 4 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.mail.script; | |
21 | ||
22 | import org.xwiki.mail.MailResult; | |
23 | import org.xwiki.mail.MailStatusResult; | |
24 | ||
25 | /** | |
26 | * Implementation used by the Mail Sender Script Service. It wraps the Java {@link org.xwiki.mail.MailResult} class to | |
27 | * add a new {@link #getStatusResult()} method since in the Scripting API the {@link org.xwiki.mail.MailListener} is | |
28 | * passed as a hint and thus the user cannot call {@link org.xwiki.mail.MailListener#getMailStatusResult()} on it. | |
29 | * | |
30 | * @version $Id: 94315a4f7812f943e2f4b91180921c795e7c7a33 $ | |
31 | * @since 6.4M3 | |
32 | */ | |
33 | public class ScriptMailResult implements MailResult | |
34 | { | |
35 | private MailResult wrappedMailResult; | |
36 | ||
37 | private MailStatusResult mailStatusResult; | |
38 | ||
39 | /** | |
40 | * @param wrappedMailResult the {@link org.xwiki.mail.MailResult} instance to wrap | |
41 | * @param mailStatusResult see {@link #getStatusResult()} | |
42 | */ | |
43 | 7 | ![]() |
44 | { | |
45 | 7 | this.wrappedMailResult = wrappedMailResult; |
46 | 7 | this.mailStatusResult = mailStatusResult; |
47 | } | |
48 | ||
49 | /** | |
50 | * @return the {@link org.xwiki.mail.MailListener}'s {@link org.xwiki.mail.MailStatusResult} object which is useful | |
51 | * for script users to get the status of each mail from the batch | |
52 | */ | |
53 | 20 | ![]() |
54 | { | |
55 | 20 | return this.mailStatusResult; |
56 | } | |
57 | ||
58 | 1 | ![]() |
59 | public String getBatchId() | |
60 | { | |
61 | 1 | return this.wrappedMailResult.getBatchId(); |
62 | } | |
63 | ||
64 | /** | |
65 | * Wait till all messages on the sending queue have been sent (for this batch) before returning. | |
66 | * | |
67 | * @param timeout the maximum amount of time to wait in milliseconds | |
68 | * @since 6.4 | |
69 | * @deprecated since 7.1M2 use {@link MailStatusResult#waitTillProcessed(long)} instead. Kept to not break | |
70 | * script backward compatibility | |
71 | */ | |
72 | 0 | ![]() |
73 | public void waitTillProcessed(long timeout) | |
74 | { | |
75 | 0 | getStatusResult().waitTillProcessed(timeout); |
76 | } | |
77 | ||
78 | /** | |
79 | * @return true if all the mails from this batch have been processed (sent successfully or not) or false otherwise | |
80 | * @since 6.4RC1 | |
81 | * @deprecated since 7.1M2 use {@link MailStatusResult#isProcessed()} instead. Kept to not break | |
82 | * script backward compatibility | |
83 | */ | |
84 | 0 | ![]() |
85 | public boolean isProcessed() | |
86 | { | |
87 | 0 | return getStatusResult().isProcessed(); |
88 | } | |
89 | } |