1. Project Clover database Wed Jan 17 2024 23:40:18 CST
  2. Package org.europa.together.business

File MailClient.java

 

Code metrics

0
0
0
1
129
41
0
-
-
0
-

Classes

Class Line # Actions
MailClient 26 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package org.europa.together.business;
2   
3    import java.io.IOException;
4    import java.util.Map;
5    import jakarta.mail.MessagingException;
6    import jakarta.mail.NoSuchProviderException;
7    import jakarta.mail.Session;
8    import jakarta.mail.internet.MimeMessage;
9    import org.apiguardian.api.API;
10    import static org.apiguardian.api.API.Status.STABLE;
11    import org.europa.together.domain.Mail;
12    import org.springframework.stereotype.Component;
13   
14    /**
15    * Simple SMTP e-mail client with SSL to send E-Mails from a configured mail
16    * account (SMTP server). The mailer allows sending mass mails (e.g.
17    * newsletter), this feature needs a timer to interrupt after a configured
18    * amount of mails for a few seconds.
19    *
20    * @author elmar.dott@gmail.com
21    * @version 3.0
22    * @since 1.0
23    */
24    @API(status = STABLE, since = "1.0", consumers = "JakartaMailClient")
25    @Component
 
26    public interface MailClient {
27   
28    /**
29    * Identifier for the given feature.
30    */
31    @API(status = STABLE, since = "1.2")
32    String FEATURE_ID = "CM-06";
33   
34    /**
35    * Define the configuration set for the MailClient.
36    */
37    @API(status = STABLE, since = "1.0")
38    String CONFIG_SET = "email";
39   
40    /**
41    * Defines for which MODULE_VERSION the configuration will work.
42    */
43    @API(status = STABLE, since = "1.1")
44    String CONFIG_VERSION = "1.0";
45   
46    /**
47    * Get the full active configuration of the mail client for debugging.
48    *
49    * @return configuration as Map
50    */
51    @API(status = STABLE, since = "3.0")
52    Map<String, String> getDebugActiveConfiguration();
53   
54    /**
55    * Clean (reset) the mailer configuration.
56    */
57    @API(status = STABLE, since = "2.0")
58    void clearConfiguration();
59   
60    /**
61    * Load the e-mail configuration from a given property file.
62    *
63    * @param resource as String return true on success
64    * @return true on success
65    * @throws java.io.IOException
66    */
67    @API(status = STABLE, since = "3.0")
68    boolean loadConfigurationFromProperties(String resource) throws IOException;
69   
70    /**
71    * Load the e-mail configuration from the database.
72    *
73    * @return true on success
74    */
75    @API(status = STABLE, since = "1.0")
76    boolean loadConfigurationFromDatabase();
77   
78    /**
79    * Get the limitation of the maximum amount of sending e-mails until a time
80    * interrupt will be processed.
81    *
82    * @return limitOfBulkMails as int
83    */
84    @API(status = STABLE, since = "1.0")
85    int getBulkMailLimiter();
86   
87    /**
88    * Get the configured wait time in milliseconds until the next mail bulk can
89    * be send.
90    *
91    * @return waitTime as long
92    */
93    @API(status = STABLE, since = "1.0")
94    long getWaitTime();
95   
96    /**
97    * Compose a full e-mail, ready to send.
98    *
99    * @param mail as Mail
100    * @throws jakarta.mail.MessagingException
101    */
102    @API(status = STABLE, since = "3.0")
103    void composeMail(Mail mail) throws MessagingException;
104   
105    /**
106    * Get the configured session to connect the SMTP server.
107    *
108    * @return session as Session
109    * @throws jakarta.mail.NoSuchProviderException
110    */
111    @API(status = STABLE, since = "3.0")
112    Session getSession() throws NoSuchProviderException;
113   
114    /**
115    * Get the composing Mail Object.
116    *
117    * @return email as Mail
118    */
119    @API(status = STABLE, since = "3.0")
120    Mail getMailObject();
121   
122    /**
123    * Get the MimeMessage ready for sending.
124    *
125    * @return message as MimeMessage
126    */
127    @API(status = STABLE, since = "3.0")
128    MimeMessage getMimeMessage();
129    }