| 1 | package fr.sii.ogham.core.builder; | |
| 2 | ||
| 3 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilder; | |
| 4 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderHelper; | |
| 5 | import fr.sii.ogham.core.builder.configurer.ConfigurationPhase; | |
| 6 | import fr.sii.ogham.core.builder.configurer.Configurer; | |
| 7 | import fr.sii.ogham.core.builder.configurer.ConfigurerFor; | |
| 8 | import fr.sii.ogham.core.builder.configurer.MessagingConfigurer; | |
| 9 | import fr.sii.ogham.core.builder.context.BuildContext; | |
| 10 | import fr.sii.ogham.core.builder.context.EnvBuilderBasedContext; | |
| 11 | import fr.sii.ogham.core.builder.env.EnvironmentBuilder; | |
| 12 | import fr.sii.ogham.core.builder.env.SimpleEnvironmentBuilder; | |
| 13 | import fr.sii.ogham.core.builder.mimetype.MimetypeDetectionBuilder; | |
| 14 | import fr.sii.ogham.core.builder.mimetype.SimpleMimetypeDetectionBuilder; | |
| 15 | import fr.sii.ogham.core.builder.registry.CleanableRegistry; | |
| 16 | import fr.sii.ogham.core.builder.registry.Registry; | |
| 17 | import fr.sii.ogham.core.builder.resolution.ResourceResolutionBuilder; | |
| 18 | import fr.sii.ogham.core.builder.resolution.StandaloneResourceResolutionBuilder; | |
| 19 | import fr.sii.ogham.core.clean.Cleanable; | |
| 20 | import fr.sii.ogham.core.exception.MessagingException; | |
| 21 | import fr.sii.ogham.core.exception.builder.BuildException; | |
| 22 | import fr.sii.ogham.core.exception.configurer.ConfigureException; | |
| 23 | import fr.sii.ogham.core.sender.ConditionalSender; | |
| 24 | import fr.sii.ogham.core.service.CleanableMessagingService; | |
| 25 | import fr.sii.ogham.core.service.EverySupportingMessagingService; | |
| 26 | import fr.sii.ogham.core.service.MessagingService; | |
| 27 | import fr.sii.ogham.core.service.WrapExceptionMessagingService; | |
| 28 | import fr.sii.ogham.core.util.PriorizedList; | |
| 29 | import fr.sii.ogham.email.builder.EmailBuilder; | |
| 30 | import fr.sii.ogham.email.message.Email; | |
| 31 | import fr.sii.ogham.sms.builder.SmsBuilder; | |
| 32 | import fr.sii.ogham.sms.message.Sms; | |
| 33 | import org.reflections.Reflections; | |
| 34 | import org.reflections.scanners.SubTypesScanner; | |
| 35 | import org.slf4j.Logger; | |
| 36 | import org.slf4j.LoggerFactory; | |
| 37 | ||
| 38 | import java.io.InputStream; | |
| 39 | import java.nio.file.Files; | |
| 40 | import java.util.*; | |
| 41 | import java.util.function.Supplier; | |
| 42 | ||
| 43 | import static java.util.Arrays.asList; | |
| 44 | ||
| 45 | /** | |
| 46 | * Ogham provides many useful behaviors to focus on the message content and not | |
| 47 | * the need of understanding and implementing complex protocols. Sending emails | |
| 48 | * seems to be easy but the RFCs | |
| 49 | * (RFC5321, | |
| 50 | * RFC821, ...) are long and | |
| 51 | * complex. If you don't know those RFCs, some email clients won't be able to | |
| 52 | * read your emails. This is the same with the | |
| 53 | * SMPP protocol used for | |
| 54 | * sending SMS. | |
| 55 | * | |
| 56 | * The builder is a helper to instantiate and configure a | |
| 57 | * {@link MessagingService}. The {@link MessagingService} is used to send: | |
| 58 | *
 | |
| 59 | *
{@link Email} messages
 | |
| 60 | *
{@link Sms} messages
 | |
| 61 | *
 | |
| 62 | * | |
| 63 | * Content of the messages can be provided by templates. Templates are parsed by | |
| 64 | * template engines. Several template engines are supported: | |
| 65 | *
 | |
| 66 | *
Thymeleaf
 | |
| 67 | *
Freemaker
 | |
| 68 | *
 | |
| 69 | * | |
| 70 | * Ogham allows to send {@link Email} and {@link Sms} using several | |
| 71 | * implementations: | |
| 72 | *
 | |
| 73 | *
JavaMail (STMP) or SendGrid (HTTP) for sending {@link Email}
 | |
| 74 | *
Cloudhopper (SMPP) or OVH (HTTP) for sending {@link Sms}
 | |
| 75 | *
 | |
| 76 | * The aim is to provide an abstraction to construct a portable message ( | |
| 77 | * {@link Email} or {@link Sms}) and to be able to change infrastructure (SMTP | |
| 78 | * server to online HTTP service for example) without changing your code. | |
| 79 | * | |
| 80 | *
 | |
| 81 | * Here is an example of standard configuration that provides a default behavior | |
| 82 | * that fits 95% of usages: | |
| 83 | * | |
| 84 | *
 | |
| 85 | *  | |
| 86 | * // Instantiate the messaging service | |
| 87 | * MessagingService service = MessagingBuilder.standard() | |
| 88 | * .build(); | |
| 89 | * // send the email | |
| 90 | * service.send(new Email() | |
| 91 | * .body().template("email/sample", new SampleBean("foo", 42)) | |
| 92 | * .to("Foo Bar <foo.bar@sii.fr>")) | |
| 93 | * .attach().file("file:/data/reports/report1.pdf"); | |
| 94 | *  | |
| 95 | *
 | |
| 96 | * | |
| 97 | * This sample shows that: | |
| 98 | *
 | |
| 99 | *
System properties are used to configure "mail.host" and "mail.port"
 | |
| 100 | *
As properties "mail.host" and "mail.port" are defined and | |
| 101 | * "ogham-email-javamail" is used, the email is sent using JavaMail | |
| 102 | * implementation
 | |
| 103 | *
An email is sent to<EMAIL_ADDRESS>| |
| 104 | *
The email provides a main content (HTML) and a fallback content (text) | |
| 105 | *
 | |
| 106 | *
The HTML content comes from a template located in the classpath | |
| 107 | * (email/sample.html) and variables that are present in the template are | |
| 108 | * replaced by values provided by a simple bean object (no conversion is | |
| 109 | * needed). As "ogham-template-thymeleaf" is used and the template is a | |
| 110 | * Thymeleaf template (Thymeleaf directive on  tag), this template | |
| 111 | * is parsed by Thymeleaf
 | |
| 112 | *
The text content comes from a template located in the classpath | |
| 113 | * (email/sample.txt.ftl) and variables that are present in the template are | |
| 114 | * replaced by values provided by a simple bean object (no conversion is | |
| 115 | * needed). As "ogham-template-freemarker" is used and the template is a | |
| 116 | * Freemarker template (".ftl" extension), this template is parsed by | |
| 117 | * Freemarker
 | |
| 118 | *
 | |
| 119 | *
 | |
| 120 | *
The HTML template has CSS styles that are inlined (CSS are forbidden by | |
| 121 | * many email clients but inlined styles attributes are allowed)
 | |
| 122 | *
The HTML template references images (using ) that are | |
| 123 | * automatically attached to the sent email (mimetype of each image has been | |
| 124 | * detected and indicated to the sent message)
 | |
| 125 | *
A file located on the filesystem is attached to the email, its mimetype | |
| 126 | * has been automatically detected and indicated to the sent message
 | |
| 127 | *
The subject is provided by the <title> tag of the HTML
 | |
| 128 | *
The sender email address is provided by the system property | |
| 129 | * "ogham.email.from.default-value"
 | |
| 130 | *
 | |
| 131 | * | |
| 132 | *
 | |
| 133 | * Here is an example of minimal configuration that provides same default | |
| 134 | * behavior as previous exemple but no sender implementation is registered. You | |
| 135 | * then have to enable implementation(s) and configure them: | |
| 136 | * | |
| 137 | *
 | |
| 138 | *  | |
| 139 | * // Instantiate the messaging service | |
| 140 | * MessagingService service = MessagingBuilder.minimal() | |
| 141 | * .email() | |
| 142 | * .sender(JavaMailBuilder.class) | |
| 143 | * .host().properties("${mail.host}").and() | |
| 144 | * .port().properties("${mail.port}").and() | |
| 145 | * .charset().properties("${ogham.email.javamail.body.charset}").defaultValue("UTF-8").and() | |
| 146 | * .mimetype() | |
| 147 | * .tika() | |
| 148 | * .failIfOctetStream(false) | |
| 149 | * .and() | |
| 150 | * .and() | |
| 151 | * .and() | |
| 152 | * .and() | |
| 153 | * .build(); | |
| 154 | * // send the email | |
| 155 | * service.send(new Email() | |
| 156 | * .body().template("email/sample", new SampleBean("foo", 42)) | |
| 157 | * .to("Foo Bar <foo.bar@sii.fr>")) | |
| 158 | * .attach().file("file:/data/reports/report1.pdf"); | |
| 159 | *  | |
| 160 | *
 | |
| 161 | * | |
| 162 | * This sample has the same effect as the previous one (for this case, some | |
| 163 | * options of JavaMail implementation are not enabled). Moreover, if you want to | |
| 164 | * send a {@link Sms}, you will also need to register and configure at least one | |
| 165 | * SMS sender implementation. | |
| 166 | * | |
| 167 | * To benefit of all advantages but keeping control on which implementations are | |
| 168 | * use, you can register implementation configurers: | |
| 169 | * | |
| 170 | *
 | |
| 171 | *  | |
| 172 | * // Instantiate the messaging service | |
| 173 | * MessagingService service = MessagingBuilder.minimal() | |
| 174 | * .register(new DefaultJavaMailConfigurer(), 50000) // enable sending Email through SMTP | |
| 175 | * .register(new DefaultSendGridConfigurer(), 30000) // enable sending Email through HTTP (using an online service) | |
| 176 | * .register(new DefaultCloudHopperConfigurer(), 40000) // enable sending SMS through SMPP | |
| 177 | * .register(new DefaultOvhSmsConfigurer(), 20000) // enable sending SMS through HTTP (using an online service) | |
| 178 | * .build(); | |
| 179 | * // send the email | |
| 180 | * service.send(new Email() | |
| 181 | * .body().template("email/sample", new SampleBean("foo", 42)) | |
| 182 | * .to("Foo Bar <foo.bar@sii.fr>")) | |
| 183 | * .attach().file("file:/data/reports/report1.pdf"); | |
| 184 | *  | |
| 185 | *
 | |
| 186 | * | |
| 187 | * This sample has the same effect as using {@link #standard()}. | |
| 188 | * | |
| 189 | * You can create your own configurer for any sender implementation and register | |
| 190 | * it too. You can then mutualize and externalize reusable configuration. | |
| 191 | * | |
| 192 | *
 | |
| 193 | * The predefined behaviors are brought by static factory methods | |
| 194 | * {@link #standard()} and {@link #minimal()}. If you don't want to use | |
| 195 | * predefined behaviors, you can use directly {@code new MessagingBuilder()} or | |
| 196 | * {@link #empty()} static factory. | |
| 197 | * | |
| 198 | * Those factory methods rely on {@link MessagingConfigurer}s to provide | |
| 199 | * predefined behaviors. | |
| 200 | * | |
| 201 | *
 | |
| 202 | * The default behaviors can be used and customized: | |
| 203 | * | |
| 204 | *
 | |
| 205 | *  | |
| 206 | * // Instantiate the messaging service | |
| 207 | * MessagingService service = MessagingBuilder.standard() | |
| 208 | * .environment() | |
| 209 | * .properties() | |
| 210 | * .set("mail.host", "localhost") | |
| 211 | * .set("mail.port", "25") | |
| 212 | * .and() | |
| 213 | * .and() | |
| 214 | * .mimetype() | |
| 215 | * .defaultMimetype("application/octet-stream") | |
| 216 | * .and() | |
| 217 | * .build(); | |
| 218 | * // send the email | |
| 219 | * service.send(new Email() | |
| 220 | * .body().template("email/sample", new SampleBean("foo", 42)) | |
| 221 | * .to("Foo Bar <foo.bar@sii.fr>")) | |
| 222 | * .attach().file("file:/data/reports/report1.pdf"); | |
| 223 | *  | |
| 224 | *
 | |
| 225 | * | |
| 226 | * The previous sample shows how to change default behaviors to fit your needs: | |
| 227 | *
 | |
| 228 | *
It set the SMTP host and port in the code not by using system | |
| 229 | * properties
 | |
| 230 | *
It overrides default mimetype to provide a mimetype that fit your needs | |
| 231 | * when mimetype detection is not enough accurate
 | |
| 232 | *
 | |
| 233 | * | |
| 234 | * | |
| 235 | *
 | |
| 236 | * The {@link MessagingService} may open some resources (files, sockets, ...). | |
| 237 | * The built {@link MessagingService} is wrapped by | |
| 238 | * {@link CleanableMessagingService}. This way the instantiated service can | |
| 239 | * clean opened resources either manually (if developer explicitly calls | |
| 240 | * {@link CleanableMessagingService#clean()}) or automatically (see | |
| 241 | * {@link CleanableMessagingService} for more information). | |
| 242 | * | |
| 243 | * | |
| 244 | * @author Aurélien Baudet | |
| 245 | * | |
| 246 | */ | |
| 247 | public class MessagingBuilder implements Builder<MessagingService> { | |
| 248 | private static final Logger LOG = LoggerFactory.getLogger(MessagingBuilder.class); | |
| 249 | public static final String BASE_PACKAGE = "fr.sii.ogham"; | |
| 250 | ||
| 251 | protected final boolean autoconfigure; | |
| 252 | protected final Map<ConfigurationPhase, Boolean> alreadyConfigured; | |
| 253 | protected final PriorizedList<ConfigurerWithPhase> configurers; | |
| 254 | protected final EnvironmentBuilder<MessagingBuilder> environmentBuilder; | |
| 255 | protected final BuildContext buildContext; | |
| 256 | protected final Registry<Object> registry; | |
| 257 | protected final Cleanable cleaner; | |
| 258 | protected CleanableRegistry cleanableRegistry; | |
| 259 | protected MimetypeDetectionBuilder<MessagingBuilder> mimetypeBuilder; | |
| 260 | protected StandaloneResourceResolutionBuilder<MessagingBuilder> resourceBuilder; | |
| 261 | protected EmailBuilder emailBuilder; | |
| 262 | protected SmsBuilder smsBuilder; | |
| 263 | protected final ConfigurationValueBuilderHelper<MessagingBuilder, Boolean> wrapUncaughtValueBuilder; | |
| 264 | ||
| 265 | /** | |
| 266 | * Initializes the builder with minimal requirements: | |
| 267 | *
 | |
| 268 | *
an empty {@link EnvironmentBuilder}
 | |
| 269 | *
an empty {@link MimetypeDetectionBuilder}
 | |
| 270 | *
an empty {@link ResourceResolutionBuilder}
 | |
| 271 | *
 | |
| 272 | * | |
| 273 | * | |
| 274 | *
 | |
| 275 | * If {@code autoconfigure} parameter is true, it applies all registered | |
| 276 | * configurers on this builder instance. | |
| 277 | * | |
| 278 | * When using {@link #standard()} and {@link #minimal()} factory methods, | |
| 279 | * {@code autoconfigure} parameter is set to true. | |
| 280 | * | |
| 281 | * | |
| 282 | * @param autoconfigure | |
| 283 | * Trigger configuration automatically if true (for all phases). | |
| 284 | * If false, you have to call | |
| 285 | * {@link #configure(ConfigurationPhase)} manually. | |
| 286 | */ | |
| 287 | public MessagingBuilder(boolean autoconfigure) { | |
| 288 | super(); | |
| 289 | this.autoconfigure = autoconfigure; | |
| 290 | alreadyConfigured = new EnumMap<>(ConfigurationPhase.class); | |
| 291 | configurers = new PriorizedList<>(); | |
| 292 | environmentBuilder = createEnvironmentBuilder(); | |
| 293 | registry = createRegistry(); | |
| 294 | cleaner = createCleanable(); | |
| 295 | buildContext = createBuildContext(); | |
| 296 | mimetypeBuilder = createMimetypeBuilder(); | |
| 297 | resourceBuilder = createResourceResolutionBuilder(); | |
| 298 | wrapUncaughtValueBuilder = buildContext.newConfigurationValueBuilder(this, Boolean.class); | |
| 299 | } | |
| 300 | ||
| 301 | /** | |
| 302 | * Registers a configurer with a priority. Configuration order may be | |
| 303 | * important. The priority is used to apply configurers in order. The | |
| 304 | * configurer with highest priority (applied first) has the greatest value. | |
| 305 | * | |
| 306 | * The configurer is applied on a this builder instance to configure it | |
| 307 | * (when {@link #configure(ConfigurationPhase)} is called). | |
| 308 | * | |
| 309 | *
 | |
| 310 | * When using {@link #standard()} and {@link #minimal()} factory methods, | |
| 311 | * the list of configurers are automatically loaded from the classpath and | |
| 312 | * registered. The priority is indicated through the {@link ConfigurerFor} | |
| 313 | * annotation. | |
| 314 | * | |
| 315 | *
 | |
| 316 | * The registered configurer will be executed at | |
| 317 | * {@link ConfigurationPhase#BEFORE_BUILD} phase. | |
| 318 | * | |
| 319 | * | |
| 320 | * @param configurer | |
| 321 | * the configurer to register | |
| 322 | * @param priority | |
| 323 | * the configurer priority | |
| 324 | * @return this instance for fluent chaining | |
| 325 | */ | |
| 326 | public MessagingBuilder register(MessagingConfigurer configurer, int priority) { | |
| 327 |
1
1. register : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::register → NO_COVERAGE |
return register(configurer, priority, ConfigurationPhase.BEFORE_BUILD); |
| 328 | } | |
| 329 | ||
| 330 | /** | |
| 331 | * Registers a configurer with a priority. Configuration order may be | |
| 332 | * important. The priority is used to apply configurers in order. The | |
| 333 | * configurer with highest priority (applied first) has the greatest value. | |
| 334 | * | |
| 335 | * The configurer is applied on a this builder instance to configure it | |
| 336 | * (when {@link #configure(ConfigurationPhase)} is called). | |
| 337 | * | |
| 338 | *
 | |
| 339 | * When using {@link #standard()} and {@link #minimal()} factory methods, | |
| 340 | * the list of configurers are automatically loaded from the classpath and | |
| 341 | * registered. The priority is indicated through the {@link ConfigurerFor} | |
| 342 | * annotation. | |
| 343 | * | |
| 344 | * | |
| 345 | * @param configurer | |
| 346 | * the configurer to register | |
| 347 | * @param priority | |
| 348 | * the configurer priority | |
| 349 | * @param phase | |
| 350 | * register the configurer to be executed at the defined the | |
| 351 | * configuration phase | |
| 352 | * @return this instance for fluent chaining | |
| 353 | */ | |
| 354 | public MessagingBuilder register(MessagingConfigurer configurer, int priority, ConfigurationPhase phase) { | |
| 355 | LOG.debug("[{}] registered for phase {} with priority={}", configurer, phase, priority); | |
| 356 | configurers.register(new ConfigurerWithPhase(configurer, phase), priority); | |
| 357 |
1
1. register : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::register → RUN_ERROR |
return this; |
| 358 | } | |
| 359 | ||
| 360 | /** | |
| 361 | * Apply all registered configurers on this builder instance for the | |
| 362 | * {@link ConfigurationPhase}. | |
| 363 | * | |
| 364 | *
 | |
| 365 | * When using {@link #standard()} and {@link #minimal()} factory methods, | |
| 366 | * this method is automatically called. | |
| 367 | * | |
| 368 | * @param phase | |
| 369 | * the configuration phase | |
| 370 | */ | |
| 371 | public void configure(ConfigurationPhase phase) { | |
| 372 |
1
1. configure : negated conditional → RUN_ERROR |
if (alreadyConfigured(phase)) { |
| 373 | return; | |
| 374 | } | |
| 375 | for (ConfigurerWithPhase configurerWithPhase : configurers.getOrdered()) { | |
| 376 |
1
1. configure : negated conditional → RUN_ERROR |
if (phase == configurerWithPhase.getPhase()) { |
| 377 | MessagingConfigurer configurer = configurerWithPhase.getConfigurer(); | |
| 378 | LOG.debug("[{}] configuring for phase {}...", configurer, phase); | |
| 379 | try { | |
| 380 |
1
1. configure : removed call to fr/sii/ogham/core/builder/configurer/MessagingConfigurer::configure → RUN_ERROR |
configurer.configure(this); |
| 381 | LOG.info("[{}] configuration applied", configurer.getClass()); | |
| 382 | } catch (ConfigureException e) { | |
| 383 | LOG.info("[{}] configuration skipped: "+e.getMessage(), configurer.getClass()); | |
| 384 | LOG.trace("[{}] Details:", e); | |
| 385 | } | |
| 386 | } | |
| 387 | } | |
| 388 | alreadyConfigured.put(phase, true); | |
| 389 | } | |
| 390 | ||
| 391 | /** | |
| 392 | * Configures environment for the builder (and sub-builders if inherited). | |
| 393 | * Environment consists of configuration properties/values that are used to | |
| 394 | * configure the system (see {@link EnvironmentBuilder} for more | |
| 395 | * information). | |
| 396 | * | |
| 397 | * You can use system properties: | |
| 398 | * | |
| 399 | *
 | |
| 400 | * .environment() | |
| 401 | * .systemProperties(); | |
| 402 | *
 | |
| 403 | * | |
| 404 | * Or, you can load properties from a file: | |
| 405 | * | |
| 406 | *
 | |
| 407 | * .environment() | |
| 408 | * .properties("/path/to/file.properties") | |
| 409 | *
 | |
| 410 | * | |
| 411 | * Or using directly a {@link Properties} object: | |
| 412 | * | |
| 413 | *
 | |
| 414 | * Properties myprops = new Properties(); | |
| 415 | * myprops.setProperty("foo", "bar"); | |
| 416 | * .environment() | |
| 417 | * .properties(myprops) | |
| 418 | *
 | |
| 419 | * | |
| 420 | * Or defining directly properties: | |
| 421 | * | |
| 422 | *
 | |
| 423 | * .environment() | |
| 424 | * .properties() | |
| 425 | * .set("foo", "bar") | |
| 426 | *
 | |
| 427 | * | |
| 428 | * | |
| 429 | *
 | |
| 430 | * Every time you are configuring {@link #environment()}, you update the | |
| 431 | * same instance. | |
| 432 | *
 | |
| 433 | * | |
| 434 | * @return the builder to configure properties handling | |
| 435 | */ | |
| 436 | public EnvironmentBuilder<MessagingBuilder> environment() { | |
| 437 |
1
1. environment : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::environment → RUN_ERROR |
return environmentBuilder; |
| 438 | } | |
| 439 | ||
| 440 | /** | |
| 441 | * Cconfigures resource resolution. | |
| 442 | * | |
| 443 | *
 | |
| 444 | * Resource resolution consists of finding a file: | |
| 445 | *
 | |
| 446 | *
either on filesystem
 | |
| 447 | *
or in the classpath
 | |
| 448 | *
or anywhere else
 | |
| 449 | *
 | |
| 450 | * | |
| 451 | *
 | |
| 452 | * To identify which resolution to use, each resolution is configured to | |
| 453 | * handle one or several lookups prefixes. For example, if resolution is | |
| 454 | * configured like this: | |
| 455 | * | |
| 456 | *
 | |
| 457 | *  | |
| 458 | * .string() | |
| 459 | * .lookup("string:", "s:") | |
| 460 | * .and() | |
| 461 | * .file() | |
| 462 | * .lookup("file:") | |
| 463 | * .and() | |
| 464 | * .classpath() | |
| 465 | * .lookup("classpath:", ""); | |
| 466 | *  | |
| 467 | *
 | |
| 468 | * | |
| 469 | * Then you can reference a file that is in the classpath like this: | |
| 470 | * | |
| 471 | *
 | |
| 472 | * "classpath:foo/bar.html" | |
| 473 | *
 | |
| 474 | * | |
| 475 | * | |
| 476 | *
 | |
| 477 | * Resource resolution is also able to handle path prefix and suffix. The | |
| 478 | * aim is for example to have a folder that contains all templates. The | |
| 479 | * developer then configures a path prefix for the folder. He can also | |
| 480 | * configure a suffix to fix extension for templates. Thanks to those | |
| 481 | * prefix/suffix, templates can now be referenced by the name of the file | |
| 482 | * (without extension). It is useful to reference a template independently | |
| 483 | * from where it is in reality (classpath, file or anywhere else) . | |
| 484 | * Switching from classpath to file and conversely can be done easily (by | |
| 485 | * updating the lookup). | |
| 486 | * | |
| 487 | * For example: | |
| 488 | * | |
| 489 | *
 | |
| 490 | * .classpath().lookup("classpath:").pathPrefix("foo/").pathSuffix(".html"); | |
| 491 | * | |
| 492 | * resourceResolver.getResource("classpath:bar"); | |
| 493 | *
 | |
| 494 | * | |
| 495 | * The real path is then {@code foo/bar.html}. | |
| 496 | * | |
| 497 | *
 | |
| 498 | * This implementation is used by {@link MessagingBuilder} for general | |
| 499 | * configuration. That configuration may be inherited (applied to other | |
| 500 | * resource resolution builders). | |
| 501 | * | |
| 502 | * @return the builder to configure resource resolution | |
| 503 | */ | |
| 504 | public StandaloneResourceResolutionBuilder<MessagingBuilder> resource() { | |
| 505 |
1
1. resource : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::resource → RUN_ERROR |
return resourceBuilder; |
| 506 | } | |
| 507 | ||
| 508 | /** | |
| 509 | * Builder that configures mimetype detection. | |
| 510 | * | |
| 511 | * There exists several implementations to provide the mimetype: | |
| 512 | *
 | |
| 513 | *
Using Java activation
 | |
| 514 | *
Using Java 7 {@link Files#probeContentType(java.nio.file.Path)}
 | |
| 515 | *
Using Apache Tika
 | |
| 516 | *
Using | |
| 517 | * JMimeMagic
 | |
| 518 | *
 | |
| 519 | * | |
| 520 | *
 | |
| 521 | * Both implementations provided by Java are based on file extensions. This | |
| 522 | * can't be used in most cases as we often handle {@link InputStream}s. | |
| 523 | *
 | |
| 524 | * | |
| 525 | *
 | |
| 526 | * In previous version of Ogham, JMimeMagic was used and was working quite | |
| 527 | * well. Unfortunately, the library is no more maintained. | |
| 528 | *
 | |
| 529 | * | |
| 530 | *
 | |
| 531 | * You can configure how Tika will detect mimetype: | |
| 532 | * | |
| 533 | *
 | |
| 534 | * .mimetype() | |
| 535 | * .tika() | |
| 536 | * ... | |
| 537 | *
 | |
| 538 | * | |
| 539 | *
 | |
| 540 | * This builder allows to use several providers. It will chain them until | |
| 541 | * one can find a valid mimetype. If none is found, you can explicitly | |
| 542 | * provide the default one: | |
| 543 | * | |
| 544 | *
 | |
| 545 | * .mimetype() | |
| 546 | * .defaultMimetype("text/html") | |
| 547 | *
 | |
| 548 | * | |
| 549 | *
 | |
| 550 | * Every time you are configuring {@link #mimetype()}, the same instance is | |
| 551 | * used. | |
| 552 | *
 | |
| 553 | * | |
| 554 | * @return the builder to configure mimetype detection | |
| 555 | */ | |
| 556 | public MimetypeDetectionBuilder<MessagingBuilder> mimetype() { | |
| 557 |
1
1. mimetype : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::mimetype → RUN_ERROR |
return mimetypeBuilder; |
| 558 | } | |
| 559 | ||
| 560 | /** | |
| 561 | * There are technical exceptions that are thrown by libraries used by | |
| 562 | * Ogham. Those exceptions are often {@link RuntimeException}s. It can be | |
| 563 | * difficult for developers of a big application to quickly identify what | |
| 564 | * caused this {@link RuntimeException}. The stack trace doesn't always help | |
| 565 | * to find the real source of the error. If enables, this option ensures | |
| 566 | * that work done by Ogham will always throw a {@link MessagingException} | |
| 567 | * even if it was a {@link RuntimeException} thrown by any component. It | |
| 568 | * then helps the developer to know that the error comes from Ogham or a any | |
| 569 | * used library and not something else in its application. The other benefit | |
| 570 | * is that in your code you only catch a {@link MessagingException} and you | |
| 571 | * are sure that it will handle all cases, no surprise with an unchecked | |
| 572 | * exception that could make a big failure in your system because you didn't | |
| 573 | * know this could happen. Sending a message is often not critical (if | |
| 574 | * message can't be sent now, it can be sent later or manually). It it fails | |
| 575 | * the whole system must keep on working. With this option enabled, your | |
| 576 | * system will never fail due to an unchecked exception and you can handle | |
| 577 | * the failure the same way as with checked exceptions. | |
| 578 | * | |
| 579 | * Concretely, call of | |
| 580 | * {@link MessagingService#send(fr.sii.ogham.core.message.Message)} catches | |
| 581 | * all exceptions including {@link RuntimeException}. It wraps any | |
| 582 | * exceptions into a {@link MessagingException}. | |
| 583 | * | |
| 584 | * | |
| 585 | *
 | |
| 586 | * The value set using this method takes precedence over any property and | |
| 587 | * default value configured using {@link #wrapUncaught()}. | |
| 588 | * | |
| 589 | *
 | |
| 590 | * .wrapUncaught(false) | |
| 591 | * .wrapUncaught() | |
| 592 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 593 | * .defaultValue(true) | |
| 594 | *
 | |
| 595 | * | |
| 596 | *
 | |
| 597 | * .wrapUncaught(false) | |
| 598 | * .wrapUncaught() | |
| 599 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 600 | * .defaultValue(true) | |
| 601 | *
 | |
| 602 | * | |
| 603 | * In both cases, {@code wrapUncaught(false)} is used. | |
| 604 | * | |
| 605 | *
 | |
| 606 | * If this method is called several times, only the last value is used. | |
| 607 | * | |
| 608 | *
 | |
| 609 | * If {@code null} value is set, it is like not setting a value at all. The | |
| 610 | * property/default value configuration is applied. | |
| 611 | * | |
| 612 | * @param enable | |
| 613 | * enable or disable catching of unchecked exceptions | |
| 614 | * @return this instance for fluent chaining | |
| 615 | */ | |
| 616 | public MessagingBuilder wrapUncaught(Boolean enable) { | |
| 617 |
1
1. wrapUncaught : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE |
wrapUncaughtValueBuilder.setValue(enable); |
| 618 |
1
1. wrapUncaught : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::wrapUncaught → NO_COVERAGE |
return this; |
| 619 | } | |
| 620 | ||
| 621 | /** | |
| 622 | * There are technical exceptions that are thrown by libraries used by | |
| 623 | * Ogham. Those exceptions are often {@link RuntimeException}s. It can be | |
| 624 | * difficult for developers of a big application to quickly identify what | |
| 625 | * caused this {@link RuntimeException}. The stack trace doesn't always help | |
| 626 | * to find the real source of the error. If enables, this option ensures | |
| 627 | * that work done by Ogham will always throw a {@link MessagingException} | |
| 628 | * even if it was a {@link RuntimeException} thrown by any component. It | |
| 629 | * then helps the developer to know that the error comes from Ogham or a any | |
| 630 | * used library and not something else in its application. The other benefit | |
| 631 | * is that in your code you only catch a {@link MessagingException} and you | |
| 632 | * are sure that it will handle all cases, no surprise with an unchecked | |
| 633 | * exception that could make a big failure in your system because you didn't | |
| 634 | * know this could happen. Sending a message is often not critical (if | |
| 635 | * message can't be sent now, it can be sent later or manually). It it fails | |
| 636 | * the whole system must keep on working. With this option enabled, your | |
| 637 | * system will never fail due to an unchecked exception and you can handle | |
| 638 | * the failure the same way as with checked exceptions. | |
| 639 | * | |
| 640 | * Concretely, call of | |
| 641 | * {@link MessagingService#send(fr.sii.ogham.core.message.Message)} catches | |
| 642 | * all exceptions including {@link RuntimeException}. It wraps any | |
| 643 | * exceptions into a {@link MessagingException}. | |
| 644 | * | |
| 645 | * | |
| 646 | *
 | |
| 647 | * This method is mainly used by {@link Configurer}s to register some | |
| 648 | * property keys and/or a default value. The aim is to let developer be able | |
| 649 | * to externalize its configuration (using system properties, configuration | |
| 650 | * file or anything else). If the developer doesn't configure any value for | |
| 651 | * the registered properties, the default value is used (if set). | |
| 652 | * | |
| 653 | *
 | |
| 654 | * .wrapUncaught() | |
| 655 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 656 | * .defaultValue(true) | |
| 657 | *
 | |
| 658 | * | |
| 659 | *
 | |
| 660 | * Non-null value set using {@link #wrapUncaught(Boolean)} takes precedence | |
| 661 | * over property values and default value. | |
| 662 | * | |
| 663 | *
 | |
| 664 | * .wrapUncaught(false) | |
| 665 | * .wrapUncaught() | |
| 666 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 667 | * .defaultValue(true) | |
| 668 | *
 | |
| 669 | * | |
| 670 | * The value {@code false} is used regardless of the value of the properties | |
| 671 | * and default value. | |
| 672 | * | |
| 673 | *
 | |
| 674 | * See {@link ConfigurationValueBuilder} for more information. | |
| 675 | * | |
| 676 | * | |
| 677 | * @return the builder to configure property keys/default value | |
| 678 | */ | |
| 679 | public ConfigurationValueBuilder<MessagingBuilder, Boolean> wrapUncaught() { | |
| 680 |
1
1. wrapUncaught : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::wrapUncaught → RUN_ERROR |
return wrapUncaughtValueBuilder; |
| 681 | } | |
| 682 | ||
| 683 | /** | |
| 684 | * Configures how to send {@link Email} messages. It allows to: | |
| 685 | *
 | |
| 686 | *
register and configure several sender implementations
 | |
| 687 | *
register and configure several template engines for parsing templates | |
| 688 | * as message content
 | |
| 689 | *
configure handling of missing {@link Email} information
 | |
| 690 | *
configure handling of file attachments
 | |
| 691 | *
configure CSS and image handling for {@link Email}s with an HTML | |
| 692 | * body
 | |
| 693 | *
 | |
| 694 | * | |
| 695 | * You can send an {@link Email} using the minimal behavior and using | |
| 696 | * JavaMail implementation: | |
| 697 | * | |
| 698 | *
 | |
| 699 | *  | |
| 700 | * // Instantiate the messaging service | |
| 701 | * MessagingService service = new MessagingBuilder() | |
| 702 | * .email() | |
| 703 | * .sender(JavaMailBuilder.class) // enable Email sending using JavaMail | |
| 704 | * .host("your SMTP server host") | |
| 705 | * .port("your SMTP server port") | |
| 706 | * .and() | |
| 707 | * .and() | |
| 708 | * .build(); | |
| 709 | * // send the email | |
| 710 | * service.send(new Email() | |
| 711 | * .from("sender email address") | |
| 712 | * .subject("email subject") | |
| 713 | * .content("email body") | |
| 714 | * .to("recipient email address")); | |
| 715 | *  | |
| 716 | *
 | |
| 717 | * | |
| 718 | * You can also send an {@link Email} using a template (using Freemarker for | |
| 719 | * example): | |
| 720 | * | |
| 721 | * The Freemarker template ("email/sample.html.ftl"): | |
| 722 | * | |
| 723 | *
 | |
| 724 | *  | |
| 725 | *  | |
| 726 | *  | |
| 727 | *  | |
| 728 | * Email content with variables: ${name} ${value} | |
| 729 | *  | |
| 730 | *  | |
| 731 | *
 | |
| 732 | * | |
| 733 | * Then you can send the {@link Email} like this: | |
| 734 | * | |
| 735 | *
 | |
| 736 | *  | |
| 737 | * // Instantiate the messaging service | |
| 738 | * MessagingService service = new MessagingBuilder() | |
| 739 | * .email() | |
| 740 | * .sender(JavaMailBuilder.class) // enable Email sending using JavaMail | |
| 741 | * .host("your SMTP server host") | |
| 742 | * .port("your SMTP server port") | |
| 743 | * .and() | |
| 744 | * .and() | |
| 745 | * .template(FreemarkerEmailBuilder.class) // enable templating using Freemarker | |
| 746 | * .classpath() | |
| 747 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
| 748 | * .and() | |
| 749 | * .and() | |
| 750 | * .build(); | |
| 751 | * // send the email | |
| 752 | * service.send(new Email() | |
| 753 | * .from("sender email address") | |
| 754 | * .subject("email subject") | |
| 755 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
| 756 | * .to("recipient email address")); | |
| 757 | *  | |
| 758 | *
 | |
| 759 | * | |
| 760 | *
 | |
| 761 | * Instead of explicitly configures SMTP host and port in your code, it | |
| 762 | * could be better to externalize the configuration in a properties file for | |
| 763 | * example (for example a file named "email.properties" in the classpath). | |
| 764 | * The previous example becomes: | |
| 765 | * | |
| 766 | *
 | |
| 767 | *  | |
| 768 | * // Instantiate the messaging service | |
| 769 | * MessagingService service = new MessagingBuilder() | |
| 770 | * .environment() | |
| 771 | * .properties("email.properties") | |
| 772 | * .and() | |
| 773 | * .email() | |
| 774 | * .sender(JavaMailBuilder.class) // enable Email sending using JavaMail | |
| 775 | * .host().properties("${mail.host}").and() | |
| 776 | * .port().properties("${mail.port}").and() | |
| 777 | * .and() | |
| 778 | * .and() | |
| 779 | * .template(FreemarkerEmailBuilder.class) // enable templating using Freemarker | |
| 780 | * .classpath() | |
| 781 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
| 782 | * .and() | |
| 783 | * .and() | |
| 784 | * .build(); | |
| 785 | * // send the email | |
| 786 | * service.send(new Email() | |
| 787 | * .from("sender email address") | |
| 788 | * .subject("email subject") | |
| 789 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
| 790 | * .to("recipient email address")); | |
| 791 | *  | |
| 792 | *
 | |
| 793 | * | |
| 794 | * The content of the file "email.properties": | |
| 795 | * | |
| 796 | *
 | |
| 797 | * mail.host=your STMP server host | |
| 798 | * mail.port=your STMP server port | |
| 799 | *
 | |
| 800 | * | |
| 801 | * | |
| 802 | * Some fields of the Email may be automatically filled by a default value | |
| 803 | * if they are not defined. For example, the sender address could be | |
| 804 | * configured only once for your application: | |
| 805 | * | |
| 806 | *
 | |
| 807 | *  | |
| 808 | * // Instantiate the messaging service | |
| 809 | * MessagingService service = new MessagingBuilder() | |
| 810 | * .environment() | |
| 811 | * .properties("email.properties") | |
| 812 | * .and() | |
| 813 | * .email() | |
| 814 | * .sender(JavaMailBuilder.class) // enable Email sending using JavaMail | |
| 815 | * .host().properties("${mail.host}").and() | |
| 816 | * .port().properties("${mail.port}").and() | |
| 817 | * .and() | |
| 818 | * .autofill() // enables and configures autofilling | |
| 819 | * .from() | |
| 820 | * .defaultValue().properties("${email.sender.address}").and() | |
| 821 | * .and() | |
| 822 | * .and() | |
| 823 | * .template(FreemarkerEmailBuilder.class) // enable templating using Freemarker | |
| 824 | * .classpath() | |
| 825 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
| 826 | * .and() | |
| 827 | * .and() | |
| 828 | * .build(); | |
| 829 | * // send the email (now the sender address can be omitted) | |
| 830 | * service.send(new Email() | |
| 831 | * .subject("email subject") | |
| 832 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
| 833 | * .to("recipient email address")); | |
| 834 | *  | |
| 835 | *
 | |
| 836 | * | |
| 837 | * The content of the file "email.properties": | |
| 838 | * | |
| 839 | *
 | |
| 840 | * mail.host=your STMP server host | |
| 841 | * mail.port=your STMP server port | |
| 842 | * email.sender.address=sender email address | |
| 843 | *
 | |
| 844 | * | |
| 845 | * | |
| 846 | * | |
| 847 | * Another very useful automatic filling is for providing the email subject: | |
| 848 | * | |
| 849 | *
 | |
| 850 | *  | |
| 851 | * // Instantiate the messaging service | |
| 852 | * MessagingService service = new MessagingBuilder() | |
| 853 | * .environment() | |
| 854 | * .properties("email.properties") | |
| 855 | * .and() | |
| 856 | * .email() | |
| 857 | * .sender(JavaMailBuilder.class) // enable Email sending using JavaMail | |
| 858 | * .host().properties("${mail.host}").and() | |
| 859 | * .port().properties("${mail.port}").and() | |
| 860 | * .and() | |
| 861 | * .autofill() // enables and configures autofilling | |
| 862 | * .from() | |
| 863 | * .defaultValue().properties("${email.sender.address}").and() | |
| 864 | * .and() | |
| 865 | * .subject() | |
| 866 | * .htmlTitle(true) // enables use of html title tag as subject | |
| 867 | * .and() | |
| 868 | * .template(FreemarkerEmailBuilder.class) // enable templating using Freemarker | |
| 869 | * .classpath() | |
| 870 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
| 871 | * .and() | |
| 872 | * .and() | |
| 873 | * .build(); | |
| 874 | * // send the email (now the subject can be omitted) | |
| 875 | * service.send(new Email() | |
| 876 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
| 877 | * .to("recipient email address")); | |
| 878 | *  | |
| 879 | *
 | |
| 880 | * | |
| 881 | * Change your template: | |
| 882 | * | |
| 883 | *
 | |
| 884 | *  | |
| 885 | *  | |
| 886 | * <title>email subject - ${name}</title> | |
| 887 | *  | |
| 888 | *  | |
| 889 | * Email content with variables: ${name} ${value} | |
| 890 | *  | |
| 891 | *  | |
| 892 | *
 | |
| 893 | * | |
| 894 | * The obvious advantage is that you have a single place to handle email | |
| 895 | * content (body + subject). There is another benefit: you can also use | |
| 896 | * variables in the subject. | |
| 897 | * | |
| 898 | * | |
| 899 | * There many other configuration possibilities: | |
| 900 | *
 | |
| 901 | *
for configuring {@link Email}s with HTML content with a text fallback | |
| 902 | * (useful for smartphones preview of your email for example)
 | |
| 903 | *
for configuring attachments handling
 | |
| 904 | *
for configuring image and css handling
 | |
| 905 | *
 | |
| 906 | * | |
| 907 | *
 | |
| 908 | * All the previous examples are provided to understand what can be | |
| 909 | * configured. Hopefully, Ogham provides auto-configuration with a default | |
| 910 | * behavior that fits 95% of usages. This auto-configuration is provided by | |
| 911 | * {@link MessagingConfigurer}s. Those configurers are automatically applied | |
| 912 | * when using predefined {@link MessagingBuilder}s like | |
| 913 | * {@link MessagingBuilder#minimal()} and | |
| 914 | * {@link MessagingBuilder#standard()}. | |
| 915 | * | |
| 916 | * The previous sample using standard configuration becomes: | |
| 917 | * | |
| 918 | *
 | |
| 919 | *  | |
| 920 | * // Instantiate the messaging service | |
| 921 | * MessagingService service = new MessagingBuilder() | |
| 922 | * .environment() | |
| 923 | * .properties("email.properties") | |
| 924 | * .and() | |
| 925 | * .build(); | |
| 926 | * // send the email | |
| 927 | * service.send(new Email() | |
| 928 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
| 929 | * .to("recipient email address")); | |
| 930 | *  | |
| 931 | *
 | |
| 932 | * | |
| 933 | * The new content of the file "email.properties": | |
| 934 | * | |
| 935 | *
 | |
| 936 | * mail.host=your STMP server host | |
| 937 | * mail.port=your STMP server port | |
| 938 | * ogham.email.from.default-value=sender email address | |
| 939 | *
 | |
| 940 | * | |
| 941 | *
 | |
| 942 | * You can also use the auto-configuration for benefit from default | |
| 943 | * behaviors and override some behaviors for your needs: | |
| 944 | * | |
| 945 | *
 | |
| 946 | *  | |
| 947 | * // Instantiate the messaging service | |
| 948 | * MessagingService service = new MessagingBuilder() | |
| 949 | * .environment() | |
| 950 | * .properties("email.properties") | |
| 951 | * .and() | |
| 952 | * .email() | |
| 953 | * .autofill() | |
| 954 | * .from() | |
| 955 | * .defaultValue().properties("${email.sender.address}").and() // overrides default sender email address property | |
| 956 | * .and() | |
| 957 | * .and() | |
| 958 | * .and() | |
| 959 | * .build(); | |
| 960 | * // send the email | |
| 961 | * service.send(new Email() | |
| 962 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
| 963 | * .to("recipient email address")); | |
| 964 | *  | |
| 965 | *
 | |
| 966 | * | |
| 967 | * The new content of the file "email.properties": | |
| 968 | * | |
| 969 | *
 | |
| 970 | * mail.host=your STMP server host | |
| 971 | * mail.port=your STMP server port | |
| 972 | * email.sender.address=sender email address | |
| 973 | *
 | |
| 974 | * | |
| 975 | * | |
| 976 | * @return the builder to configure how Email are handled | |
| 977 | */ | |
| 978 | public EmailBuilder email() { | |
| 979 |
1
1. email : negated conditional → RUN_ERROR |
if (emailBuilder == null) { |
| 980 | emailBuilder = new EmailBuilder(this, buildContext); | |
| 981 | } | |
| 982 |
1
1. email : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::email → RUN_ERROR |
return emailBuilder; |
| 983 | } | |
| 984 | ||
| 985 | /** | |
| 986 | * Configures how to send {@link Sms} messages. It allows to: | |
| 987 | *
 | |
| 988 | *
register and configure several sender implementations
 | |
| 989 | *
register and configure several template engines for parsing templates | |
| 990 | * as message content
 | |
| 991 | *
configure handling of missing {@link Sms} information
 | |
| 992 | *
configure number format handling
 | |
| 993 | *
 | |
| 994 | * | |
| 995 | * You can send a {@link Sms} using the minimal behavior and using | |
| 996 | * Cloudhopper implementation: | |
| 997 | * | |
| 998 | *
 | |
| 999 | *  | |
| 1000 | * // Instantiate the messaging service | |
| 1001 | * MessagingService service = new MessagingBuilder() | |
| 1002 | * .sms() | |
| 1003 | * .sender(CloudhopperBuilder.class) // enable SMS sending using Cloudhopper | |
| 1004 | * .host("your SMPP server host") | |
| 1005 | * .port("your SMPP server port") | |
| 1006 | * .systemId("your SMPP system_id") | |
| 1007 | * .password("an optional password") | |
| 1008 | * .and() | |
| 1009 | * .and() | |
| 1010 | * .build(); | |
| 1011 | * // send the sms | |
| 1012 | * service.send(new Sms() | |
| 1013 | * .from("sender phone number") | |
| 1014 | * .content("sms content") | |
| 1015 | * .to("recipient phone number")); | |
| 1016 | *  | |
| 1017 | *
 | |
| 1018 | * | |
| 1019 | * You can also send a {@link Sms} using a template (using Freemarker for | |
| 1020 | * example): | |
| 1021 | * | |
| 1022 | * The Freemarker template ("sms/sample.txt.ftl"): | |
| 1023 | * | |
| 1024 | *
 | |
| 1025 | * Sms content with variables: ${name} ${value} | |
| 1026 | *
 | |
| 1027 | * | |
| 1028 | * Then you can send the {@link Sms} like this: | |
| 1029 | * | |
| 1030 | *
 | |
| 1031 | *  | |
| 1032 | * // Instantiate the messaging service | |
| 1033 | * MessagingService service = new MessagingBuilder() | |
| 1034 | * .sms() | |
| 1035 | * .sender(CloudhopperBuilder.class) // enable SMS sending using Cloudhopper | |
| 1036 | * .host("your SMPP server host") | |
| 1037 | * .port("your SMPP server port") | |
| 1038 | * .systemId("your SMPP system_id") | |
| 1039 | * .password("an optional password") | |
| 1040 | * .and() | |
| 1041 | * .and() | |
| 1042 | * .template(FreemarkerSmsBuilder.class) // enable templating using Freemarker | |
| 1043 | * .classpath() | |
| 1044 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
| 1045 | * .and() | |
| 1046 | * .and() | |
| 1047 | * .build(); | |
| 1048 | * // send the sms | |
| 1049 | * service.send(new Sms() | |
| 1050 | * .from("sender phone number") | |
| 1051 | * .content(new TemplateContent("classpath:sms/sample.txt.ftl", new SampleBean("foo", 42))) | |
| 1052 | * .to("recipient phone number")); | |
| 1053 | *  | |
| 1054 | *
 | |
| 1055 | * | |
| 1056 | *
 | |
| 1057 | * Instead of explicitly configures SMPP host/port/system_id/password in | |
| 1058 | * your code, it could be better to externalize the configuration in a | |
| 1059 | * properties file for example (for example a file named "sms.properties" in | |
| 1060 | * the classpath). The previous example becomes: | |
| 1061 | * | |
| 1062 | *
 | |
| 1063 | *  | |
| 1064 | * // Instantiate the messaging service | |
| 1065 | * MessagingService service = new MessagingBuilder() | |
| 1066 | * .environment() | |
| 1067 | * .properties("sms.properties") | |
| 1068 | * .and() | |
| 1069 | * .sms() | |
| 1070 | * .sender(CloudhopperBuilder.class) // enable SMS sending using Cloudhopper | |
| 1071 | * .host().properties("${smpp.host}").and() | |
| 1072 | * .port().properties("${smpp.port}").and() | |
| 1073 | * .systemId().properties("${smpp.system-id}").and() | |
| 1074 | * .password().properties("${smpp.password}").and() | |
| 1075 | * .and() | |
| 1076 | * .and() | |
| 1077 | * .template(FreemarkerSmsBuilder.class) // enable templating using Freemarker | |
| 1078 | * .classpath() | |
| 1079 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
| 1080 | * .and() | |
| 1081 | * .and() | |
| 1082 | * .build(); | |
| 1083 | * // send the sms | |
| 1084 | * service.send(new Sms() | |
| 1085 | * .from("sender phone number") | |
| 1086 | * .content(new TemplateContent("classpath:sms/sample.txt.ftl", new SampleBean("foo", 42))) | |
| 1087 | * .to("recipient phone number")); | |
| 1088 | *  | |
| 1089 | *
 | |
| 1090 | * | |
| 1091 | * The content of the file "sms.properties": | |
| 1092 | * | |
| 1093 | *
 | |
| 1094 | * smpp.host=your SMPP server host | |
| 1095 | * smpp.port=your SMPP server port | |
| 1096 | * smpp.system-id=your SMPP system_id | |
| 1097 | * smpp.password=an optional password | |
| 1098 | *
 | |
| 1099 | * | |
| 1100 | * | |
| 1101 | * Some fields of the SMS may be automatically filled by a default value if | |
| 1102 | * they are not defined. For example, the sender phone number could be | |
| 1103 | * configured only once for your application: | |
| 1104 | * | |
| 1105 | *
 | |
| 1106 | *  | |
| 1107 | * // Instantiate the messaging service | |
| 1108 | * MessagingService service = new MessagingBuilder() | |
| 1109 | * .environment() | |
| 1110 | * .properties("sms.properties") | |
| 1111 | * .and() | |
| 1112 | * .sms() | |
| 1113 | * .sender(CloudhopperBuilder.class) // enable SMS sending using Cloudhopper | |
| 1114 | * .host().properties("${smpp.host}").and() | |
| 1115 | * .port().properties("${smpp.port}").and() | |
| 1116 | * .systemId().properties("${smpp.system-id}").and() | |
| 1117 | * .password().properties("${smpp.password}").and() | |
| 1118 | * .and() | |
| 1119 | * .autofill() // enables and configures autofilling | |
| 1120 | * .from() | |
| 1121 | * .defaultValue().properties("${sms.sender.number}").and() | |
| 1122 | * .and() | |
| 1123 | * .and() | |
| 1124 | * .and() | |
| 1125 | * .template(FreemarkerSmsBuilder.class) // enable templating using Freemarker | |
| 1126 | * .classpath() | |
| 1127 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
| 1128 | * .and() | |
| 1129 | * .and() | |
| 1130 | * .build(); | |
| 1131 | * // send the sms (now the sender phone number can be omitted) | |
| 1132 | * service.send(new Sms() | |
| 1133 | * .content(new TemplateContent("classpath:sms/sample.txt.ftl", new SampleBean("foo", 42))) | |
| 1134 | * .to("recipient phone number")); | |
| 1135 | *  | |
| 1136 | *
 | |
| 1137 | * | |
| 1138 | * The new content of the file "sms.properties": | |
| 1139 | * | |
| 1140 | *
 | |
| 1141 | * smpp.host=your SMPP server host | |
| 1142 | * smpp.port=your SMPP server port | |
| 1143 | * smpp.system-id=your SMPP system_id | |
| 1144 | * smpp.password=an optional password | |
| 1145 | * sms.sender.number=the sender phone number | |
| 1146 | *
 | |
| 1147 | * | |
| 1148 | *
 | |
| 1149 | * All the previous examples are provided to understand what can be | |
| 1150 | * configured. Hopefully, Ogham provides auto-configuration with a default | |
| 1151 | * behavior that fits 95% of usages. This auto-configuration is provided by | |
| 1152 | * {@link MessagingConfigurer}s. Those configurers are automatically applied | |
| 1153 | * when using predefined {@link MessagingBuilder}s like | |
| 1154 | * {@link MessagingBuilder#minimal()} and | |
| 1155 | * {@link MessagingBuilder#standard()}. | |
| 1156 | * | |
| 1157 | * The previous sample using standard configuration becomes: | |
| 1158 | * | |
| 1159 | *
 | |
| 1160 | *  | |
| 1161 | * // Instantiate the messaging service | |
| 1162 | * MessagingService service = MessagingBuilder.standard() | |
| 1163 | * .environment() | |
| 1164 | * .properties("sms.properties") | |
| 1165 | * .and() | |
| 1166 | * .build(); | |
| 1167 | * // send the sms | |
| 1168 | * service.send(new Sms() | |
| 1169 | * .content(new TemplateContent("classpath:sms/sample.txt.ftl", new SampleBean("foo", 42))) | |
| 1170 | * .to("recipient phone number")); | |
| 1171 | *  | |
| 1172 | *
 | |
| 1173 | * | |
| 1174 | * The new content of the file "sms.properties": | |
| 1175 | * | |
| 1176 | *
 | |
| 1177 | * ogham.sms.smpp.host=your SMPP server host | |
| 1178 | * ogham.sms.smpp.port=your SMPP server port | |
| 1179 | * ogham.sms.smpp.system-id=your SMPP system_id | |
| 1180 | * ogham.sms.smpp.password=an optional password | |
| 1181 | * ogham.sms.from.default-value=the sender phone number | |
| 1182 | *
 | |
| 1183 | * | |
| 1184 | *
 | |
| 1185 | * You can also use the auto-configuration for benefit from default | |
| 1186 | * behaviors and override some behaviors for your needs: | |
| 1187 | * | |
| 1188 | *
 | |
| 1189 | *  | |
| 1190 | * // Instantiate the messaging service | |
| 1191 | * MessagingService service = MessagingBuilder.standard() | |
| 1192 | * .environment() | |
| 1193 | * .properties("sms.properties") | |
| 1194 | * .and() | |
| 1195 | * .sms() | |
| 1196 | * .autofill() | |
| 1197 | * .from() | |
| 1198 | * .defaultValue().properties("${sms.sender.number}").and() // overrides default sender phone number property | |
| 1199 | * .and() | |
| 1200 | * .and() | |
| 1201 | * .and() | |
| 1202 | * .build(); | |
| 1203 | * // send the sms | |
| 1204 | * service.send(new Sms() | |
| 1205 | * .content(new TemplateContent("classpath:sms/sample.txt.ftl", new SampleBean("foo", 42))) | |
| 1206 | * .to("recipient phone number")); | |
| 1207 | *  | |
| 1208 | *
 | |
| 1209 | * | |
| 1210 | * The new content of the file "sms.properties": | |
| 1211 | * | |
| 1212 | *
 | |
| 1213 | * ogham.sms.smpp.host=your SMPP server host | |
| 1214 | * ogham.sms.smpp.port=your SMPP server port | |
| 1215 | * ogham.sms.smpp.system-id=your SMPP system_id | |
| 1216 | * ogham.sms.smpp.password=an optional password | |
| 1217 | * sms.sender.number=the sender phone number | |
| 1218 | *
 | |
| 1219 | * | |
| 1220 | * @return the builder to configure how SMS are handled | |
| 1221 | */ | |
| 1222 | public SmsBuilder sms() { | |
| 1223 |
1
1. sms : negated conditional → RUN_ERROR |
if (smsBuilder == null) { |
| 1224 | smsBuilder = new SmsBuilder(this, buildContext); | |
| 1225 | } | |
| 1226 |
1
1. sms : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::sms → RUN_ERROR |
return smsBuilder; |
| 1227 | } | |
| 1228 | ||
| 1229 | /** | |
| 1230 | * Builds the messaging service. The messaging service relies on the | |
| 1231 | * generated senders. Each sender is able to manage one or multiple | |
| 1232 | * messages. The default implementation of the messaging service is to ask | |
| 1233 | * each sender if it is able to handle the message and if it the case, then | |
| 1234 | * use this sender to really send the message. This implementation doesn't | |
| 1235 | * stop when the message is handled by a sender to possibly let another send | |
| 1236 | * the message through another channel. | |
| 1237 | * | |
| 1238 | *
 | |
| 1239 | * If a {@link RuntimeException} is thrown while trying to send a message, | |
| 1240 | * the service will catch it and wrap it into a {@link MessagingException} | |
| 1241 | * in order to indicate that the exception was caused while trying to send a | |
| 1242 | * message. | |
| 1243 | *
 | |
| 1244 | * | |
| 1245 | * @return the messaging service instance | |
| 1246 | * @throws BuildException | |
| 1247 | * when service couldn't be instantiated and configured | |
| 1248 | */ | |
| 1249 | @Override | |
| 1250 | @SuppressWarnings("squid:S5411") | |
| 1251 | public MessagingService build() { | |
| 1252 |
1
1. build : negated conditional → RUN_ERROR |
if (autoconfigure) { |
| 1253 |
1
1. build : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → RUN_ERROR |
configure(ConfigurationPhase.BEFORE_BUILD); |
| 1254 | } | |
| 1255 | LOG.info("Using service that calls all registered senders"); | |
| 1256 | List<ConditionalSender> senders = buildSenders(); | |
| 1257 | LOG.debug("Registered senders: {}", senders); | |
| 1258 | MessagingService service = new EverySupportingMessagingService(senders); | |
| 1259 |
1
1. build : negated conditional → RUN_ERROR |
if (wrapUncaughtValueBuilder.getValue(false)) { |
| 1260 | service = new WrapExceptionMessagingService(service); | |
| 1261 | } | |
| 1262 | service = new CleanableMessagingService(service, cleaner); | |
| 1263 |
1
1. build : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::build → RUN_ERROR |
return service; |
| 1264 | } | |
| 1265 | | |
| 1266 | protected StandaloneResourceResolutionBuilder<MessagingBuilder> createResourceResolutionBuilder() { | |
| 1267 |
1
1. createResourceResolutionBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createResourceResolutionBuilder → RUN_ERROR |
return new StandaloneResourceResolutionBuilder<>(this, buildContext); |
| 1268 | } | |
| 1269 | | |
| 1270 | protected MimetypeDetectionBuilder<MessagingBuilder> createMimetypeBuilder() { | |
| 1271 |
1
1. createMimetypeBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createMimetypeBuilder → RUN_ERROR |
return new SimpleMimetypeDetectionBuilder<>(this, buildContext); |
| 1272 | } | |
| 1273 | | |
| 1274 | protected Cleanable createCleanable() { | |
| 1275 |
1
1. createCleanable : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createCleanable → RUN_ERROR |
return getOrCreateCleanableRegistry(); |
| 1276 | } | |
| 1277 | | |
| 1278 | protected Registry<Object> createRegistry() { | |
| 1279 |
1
1. createRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createRegistry → RUN_ERROR |
return getOrCreateCleanableRegistry(); |
| 1280 | } | |
| 1281 | | |
| 1282 | protected CleanableRegistry getOrCreateCleanableRegistry() { | |
| 1283 |
1
1. getOrCreateCleanableRegistry : negated conditional → RUN_ERROR |
if (cleanableRegistry == null) { |
| 1284 | cleanableRegistry = new CleanableRegistry(); | |
| 1285 | } | |
| 1286 |
1
1. getOrCreateCleanableRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::getOrCreateCleanableRegistry → RUN_ERROR |
return cleanableRegistry; |
| 1287 | } | |
| 1288 | | |
| 1289 | protected EnvironmentBuilder<MessagingBuilder> createEnvironmentBuilder() { | |
| 1290 |
1
1. createEnvironmentBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createEnvironmentBuilder → RUN_ERROR |
return new SimpleEnvironmentBuilder<>(this); |
| 1291 | } | |
| 1292 | | |
| 1293 | protected BuildContext createBuildContext() { | |
| 1294 |
1
1. createBuildContext : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createBuildContext → RUN_ERROR |
return new EnvBuilderBasedContext(environmentBuilder, registry); |
| 1295 | } | |
| 1296 | ||
| 1297 | ||
| 1298 | /** | |
| 1299 | * Static factory method that initializes a {@link MessagingBuilder} | |
| 1300 | * instance with no auto-configuration at all. | |
| 1301 | * | |
| 1302 | * @return the empty builder that provides no behavior at all that needs to | |
| 1303 | * be configured | |
| 1304 | */ | |
| 1305 | public static MessagingBuilder empty() { | |
| 1306 |
1
1. empty : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::empty → RUN_ERROR |
return new MessagingBuilder(false); |
| 1307 | } | |
| 1308 | ||
| 1309 | /** | |
| 1310 | * Static factory method that initializes a {@link MessagingBuilder} | |
| 1311 | * instance and auto-configures it with a predefined behavior named | |
| 1312 | * "standard". | |
| 1313 | * | |
| 1314 | * Usage example: | |
| 1315 | * | |
| 1316 | *
 | |
| 1317 | *  | |
| 1318 | * MessagingService service = MessagingBuilder.standard() | |
| 1319 | * .environment() | |
| 1320 | * .properties("application.properties") | |
| 1321 | * .and() | |
| 1322 | * .build(); | |
| 1323 | *  | |
| 1324 | *
 | |
| 1325 | * | |
| 1326 | *
 | |
| 1327 | * Basically, the standard behavior: | |
| 1328 | *
 | |
| 1329 | *
Enables all template engines that are present in the classpath and | |
| 1330 | * configures them
 | |
| 1331 | *
Enables all {@link Email} sender implementations that are present in | |
| 1332 | * the classpath and configures them
 | |
| 1333 | *
Enables all {@link Sms} sender implementations that are present in | |
| 1334 | * the classpath and configures them
 | |
| 1335 | *
Catches all uncaught exception to wrap them in order to avoid | |
| 1336 | * unwanted unchecked exception
 | |
| 1337 | *
Uses system properties
 | |
| 1338 | *
Enables and configures useful auto-filling mechanisms (using property | |
| 1339 | * values and providing email subject from templates)
 | |
| 1340 | *
Enables mimetype detection
 | |
| 1341 | *
Enables locating templates, css, images and all other resources using | |
| 1342 | * lookup prefix ("file:" for files that are present on the filesystem, | |
| 1343 | * "classpath:" and "" for files that are present in the classpath)
 | |
| 1344 | *
Enables use of some properties to provide path prefix/suffix for | |
| 1345 | * locating resources
 | |
| 1346 | *
Enables images and css inlining used by HTML {@link Email}s
 | |
| 1347 | *
 | |
| 1348 | * | |
| 1349 | *
 | |
| 1350 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
| 1351 | * loaded from the classpath. Only configurers that are in "fr.sii.ogham" | |
| 1352 | * package and sub-packages are loaded. If you want to load from other | |
| 1353 | * packages, use {@link #standard(String...)}. Some Ogham modules are | |
| 1354 | * optional meaning that according to used modules, the behavior will vary. | |
| 1355 | * | |
| 1356 | * Loaded {@link MessagingConfigurer}s are applied to the | |
| 1357 | * {@link MessagingBuilder} only if they are for the "standard" builder. It | |
| 1358 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
| 1359 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
| 1360 | * set to "standard"). | |
| 1361 | * | |
| 1362 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
| 1363 | *
 | |
| 1364 | *
DefaultMessagingConfigurer: 100000
 | |
| 1365 | *
DefaultThymeleafEmailConfigurer: 90000
 | |
| 1366 | *
DefaultFreemarkerEmailConfigurer: 80000
 | |
| 1367 | *
DefaultThymeleafSmsConfigurer: 70000
 | |
| 1368 | *
DefaultFreemarkerSmsConfigurer: 60000
 | |
| 1369 | *
DefaultJavaMailConfigurer: 50000
 | |
| 1370 | *
DefaultCloudhopperConfigurer: 40000
 | |
| 1371 | *
DefaultSendGridConfigurer: 30000
 | |
| 1372 | *
DefaultOvhSmsConfigurer: 20000
 | |
| 1373 | *
 | |
| 1374 | * | |
| 1375 | * TODO: link to whole configuration that is applied by standard | |
| 1376 | * | |
| 1377 | *
 | |
| 1378 | * The auto-configured {@link MessagingBuilder} will provide a default | |
| 1379 | * behavior that fits 95% of usages. You can still override some behaviors | |
| 1380 | * for your needs. | |
| 1381 | * | |
| 1382 | * For example: | |
| 1383 | * | |
| 1384 | *
 | |
| 1385 | *  | |
| 1386 | * MessagingService service = MessagingBuilder.standard() | |
| 1387 | * .environment() | |
| 1388 | * .properties("application.properties") | |
| 1389 | * .and() | |
| 1390 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
| 1391 | * .build(); | |
| 1392 | *  | |
| 1393 | *
 | |
| 1394 | * | |
| 1395 | * @return the messaging builder that can be customized | |
| 1396 | */ | |
| 1397 | public static MessagingBuilder standard() { | |
| 1398 |
1
1. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → RUN_ERROR |
return standard(BASE_PACKAGE); |
| 1399 | } | |
| 1400 | ||
| 1401 | /** | |
| 1402 | * Static factory method that initializes a {@link MessagingBuilder} | |
| 1403 | * instance and auto-configures it with a predefined behavior named | |
| 1404 | * "standard". | |
| 1405 | * | |
| 1406 | * Usage example: | |
| 1407 | * | |
| 1408 | *
 | |
| 1409 | *  | |
| 1410 | * MessagingService service = MessagingBuilder.standard() | |
| 1411 | * .environment() | |
| 1412 | * .properties("application.properties") | |
| 1413 | * .and() | |
| 1414 | * .build(); | |
| 1415 | *  | |
| 1416 | *
 | |
| 1417 | * | |
| 1418 | *
 | |
| 1419 | * Basically, the standard behavior: | |
| 1420 | *
 | |
| 1421 | *
Enables all template engines that are present in the classpath and | |
| 1422 | * configures them
 | |
| 1423 | *
Enables all {@link Email} sender implementations that are present in | |
| 1424 | * the classpath and configures them
 | |
| 1425 | *
Enables all {@link Sms} sender implementations that are present in | |
| 1426 | * the classpath and configures them
 | |
| 1427 | *
Catches all uncaught exception to wrap them in order to avoid | |
| 1428 | * unwanted unchecked exception
 | |
| 1429 | *
Uses system properties
 | |
| 1430 | *
Enables and configures useful auto-filling mechanisms (using property | |
| 1431 | * values and providing email subject from templates)
 | |
| 1432 | *
Enables mimetype detection
 | |
| 1433 | *
Enables locating templates, css, images and all other resources using | |
| 1434 | * lookup prefix ("file:" for files that are present on the filesystem, | |
| 1435 | * "classpath:" and "" for files that are present in the classpath)
 | |
| 1436 | *
Enables use of some properties to provide path prefix/suffix for | |
| 1437 | * locating resources
 | |
| 1438 | *
Enables images and css inlining used by HTML {@link Email}s
 | |
| 1439 | *
 | |
| 1440 | * | |
| 1441 | *
 | |
| 1442 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
| 1443 | * loaded from the classpath. Only configurers that are in the provided | |
| 1444 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
| 1445 | * meaning that according to used modules, the behavior will vary. | |
| 1446 | * | |
| 1447 | * Loaded {@link MessagingConfigurer}s are applied to the | |
| 1448 | * {@link MessagingBuilder} only if they are for the "standard" builder. It | |
| 1449 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
| 1450 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
| 1451 | * set to "standard"). | |
| 1452 | * | |
| 1453 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
| 1454 | *
 | |
| 1455 | *
DefaultMessagingConfigurer: 100000
 | |
| 1456 | *
DefaultThymeleafEmailConfigurer: 90000
 | |
| 1457 | *
DefaultFreemarkerEmailConfigurer: 80000
 | |
| 1458 | *
DefaultThymeleafSmsConfigurer: 70000
 | |
| 1459 | *
DefaultFreemarkerSmsConfigurer: 60000
 | |
| 1460 | *
DefaultJavaMailConfigurer: 50000
 | |
| 1461 | *
DefaultCloudhopperConfigurer: 40000
 | |
| 1462 | *
DefaultSendGridConfigurer: 30000
 | |
| 1463 | *
DefaultOvhSmsConfigurer: 20000
 | |
| 1464 | *
 | |
| 1465 | * | |
| 1466 | * TODO: link to whole configuration that is applied by standard | |
| 1467 | * | |
| 1468 | *
 | |
| 1469 | * The auto-configured {@link MessagingBuilder} will provide a default | |
| 1470 | * behavior that fits 95% of usages. You can still override some behaviors | |
| 1471 | * for your needs. | |
| 1472 | * | |
| 1473 | * For example: | |
| 1474 | * | |
| 1475 | *
 | |
| 1476 | *  | |
| 1477 | * MessagingService service = MessagingBuilder.standard() | |
| 1478 | * .environment() | |
| 1479 | * .properties("application.properties") | |
| 1480 | * .and() | |
| 1481 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
| 1482 | * .build(); | |
| 1483 | *  | |
| 1484 | *
 | |
| 1485 | * | |
| 1486 | * @param basePackages | |
| 1487 | * the base packages that are scanned to find | |
| 1488 | * {@link MessagingConfigurer} implementations | |
| 1489 | * @return the messaging builder that can be customized | |
| 1490 | */ | |
| 1491 | public static MessagingBuilder standard(String... basePackages) { | |
| 1492 |
1
1. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → RUN_ERROR |
return standard(true, basePackages); |
| 1493 | } | |
| 1494 | ||
| 1495 | /** | |
| 1496 | * Static factory method that initializes a {@link MessagingBuilder} | |
| 1497 | * instance and registers auto-configures but doesn't apply them if | |
| 1498 | * autoconfigure parameter is false. The | |
| 1499 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
| 1500 | * | |
| 1501 | * Usage example: | |
| 1502 | * | |
| 1503 | *
 | |
| 1504 | *  | |
| 1505 | * MessagingService service = MessagingBuilder.standard() | |
| 1506 | * .environment() | |
| 1507 | * .properties("application.properties") | |
| 1508 | * .and() | |
| 1509 | * .build(); | |
| 1510 | *  | |
| 1511 | *
 | |
| 1512 | * | |
| 1513 | *
 | |
| 1514 | * Basically, the standard behavior: | |
| 1515 | *
 | |
| 1516 | *
Enables all template engines that are present in the classpath and | |
| 1517 | * configures them
 | |
| 1518 | *
Enables all {@link Email} sender implementations that are present in | |
| 1519 | * the classpath and configures them
 | |
| 1520 | *
Enables all {@link Sms} sender implementations that are present in | |
| 1521 | * the classpath and configures them
 | |
| 1522 | *
Catches all uncaught exception to wrap them in order to avoid | |
| 1523 | * unwanted unchecked exception
 | |
| 1524 | *
Uses system properties
 | |
| 1525 | *
Enables and configures useful auto-filling mechanisms (using property | |
| 1526 | * values and providing email subject from templates)
 | |
| 1527 | *
Enables mimetype detection
 | |
| 1528 | *
Enables locating templates, css, images and all other resources using | |
| 1529 | * lookup prefix ("file:" for files that are present on the filesystem, | |
| 1530 | * "classpath:" and "" for files that are present in the classpath)
 | |
| 1531 | *
Enables use of some properties to provide path prefix/suffix for | |
| 1532 | * locating resources
 | |
| 1533 | *
Enables images and css inlining used by HTML {@link Email}s
 | |
| 1534 | *
 | |
| 1535 | * | |
| 1536 | *
 | |
| 1537 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
| 1538 | * loaded from the classpath. Only configurers that are in "fr.sii.ogham" | |
| 1539 | * package and sub-packages are loaded. If you want to load from other | |
| 1540 | * packages, use {@link #standard(String...)}. Some Ogham modules are | |
| 1541 | * optional meaning that according to used modules, the behavior will vary. | |
| 1542 | * | |
| 1543 | * Loaded {@link MessagingConfigurer}s are applied to the | |
| 1544 | * {@link MessagingBuilder} only if they are for the "standard" builder. It | |
| 1545 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
| 1546 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
| 1547 | * set to "standard"). | |
| 1548 | * | |
| 1549 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
| 1550 | *
 | |
| 1551 | *
DefaultMessagingConfigurer: 100000
 | |
| 1552 | *
DefaultThymeleafEmailConfigurer: 90000
 | |
| 1553 | *
DefaultFreemarkerEmailConfigurer: 80000
 | |
| 1554 | *
DefaultThymeleafSmsConfigurer: 70000
 | |
| 1555 | *
DefaultFreemarkerSmsConfigurer: 60000
 | |
| 1556 | *
DefaultJavaMailConfigurer: 50000
 | |
| 1557 | *
DefaultCloudhopperConfigurer: 40000
 | |
| 1558 | *
DefaultSendGridConfigurer: 30000
 | |
| 1559 | *
DefaultOvhSmsConfigurer: 20000
 | |
| 1560 | *
 | |
| 1561 | * | |
| 1562 | * TODO: link to whole configuration that is applied by standard | |
| 1563 | * | |
| 1564 | *
 | |
| 1565 | * The auto-configured {@link MessagingBuilder} will provide a default | |
| 1566 | * behavior that fits 95% of usages. You can still override some behaviors | |
| 1567 | * for your needs. | |
| 1568 | * | |
| 1569 | * For example: | |
| 1570 | * | |
| 1571 | *
 | |
| 1572 | *  | |
| 1573 | * MessagingService service = MessagingBuilder.standard() | |
| 1574 | * .environment() | |
| 1575 | * .properties("application.properties") | |
| 1576 | * .and() | |
| 1577 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
| 1578 | * .build(); | |
| 1579 | *  | |
| 1580 | *
 | |
| 1581 | * | |
| 1582 | * @param autoconfigure | |
| 1583 | * true to automatically apply found configurers, false to | |
| 1584 | * configure manually later by calling | |
| 1585 | * {@link #configure(ConfigurationPhase)} | |
| 1586 | * @return the messaging builder that can be customized | |
| 1587 | */ | |
| 1588 | public static MessagingBuilder standard(boolean autoconfigure) { | |
| 1589 |
1
1. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → NO_COVERAGE |
return standard(autoconfigure, BASE_PACKAGE); |
| 1590 | } | |
| 1591 | ||
| 1592 | /** | |
| 1593 | * Static factory method that initializes a {@link MessagingBuilder} | |
| 1594 | * instance and registers auto-configures but doesn't apply them if | |
| 1595 | * autoconfigure parameter is false. The | |
| 1596 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
| 1597 | * | |
| 1598 | * Usage example: | |
| 1599 | * | |
| 1600 | *
 | |
| 1601 | *  | |
| 1602 | * MessagingService service = MessagingBuilder.standard() | |
| 1603 | * .environment() | |
| 1604 | * .properties("application.properties") | |
| 1605 | * .and() | |
| 1606 | * .build(); | |
| 1607 | *  | |
| 1608 | *
 | |
| 1609 | * | |
| 1610 | *
 | |
| 1611 | * Basically, the standard behavior: | |
| 1612 | *
 | |
| 1613 | *
Enables all template engines that are present in the classpath and | |
| 1614 | * configures them
 | |
| 1615 | *
Enables all {@link Email} sender implementations that are present in | |
| 1616 | * the classpath and configures them
 | |
| 1617 | *
Enables all {@link Sms} sender implementations that are present in | |
| 1618 | * the classpath and configures them
 | |
| 1619 | *
Catches all uncaught exception to wrap them in order to avoid | |
| 1620 | * unwanted unchecked exception
 | |
| 1621 | *
Uses system properties
 | |
| 1622 | *
Enables and configures useful auto-filling mechanisms (using property | |
| 1623 | * values and providing email subject from templates)
 | |
| 1624 | *
Enables mimetype detection
 | |
| 1625 | *
Enables locating templates, css, images and all other resources using | |
| 1626 | * lookup prefix ("file:" for files that are present on the filesystem, | |
| 1627 | * "classpath:" and "" for files that are present in the classpath)
 | |
| 1628 | *
Enables use of some properties to provide path prefix/suffix for | |
| 1629 | * locating resources
 | |
| 1630 | *
Enables images and css inlining used by HTML {@link Email}s
 | |
| 1631 | *
 | |
| 1632 | * | |
| 1633 | *
 | |
| 1634 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
| 1635 | * loaded from the classpath. Only configurers that are in the provided | |
| 1636 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
| 1637 | * meaning that according to used modules, the behavior will vary. | |
| 1638 | * | |
| 1639 | * Loaded {@link MessagingConfigurer}s are applied to the | |
| 1640 | * {@link MessagingBuilder} only if they are for the "standard" builder. It | |
| 1641 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
| 1642 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
| 1643 | * set to "standard"). | |
| 1644 | * | |
| 1645 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
| 1646 | *
 | |
| 1647 | *
DefaultMessagingConfigurer: 100000
 | |
| 1648 | *
DefaultThymeleafEmailConfigurer: 90000
 | |
| 1649 | *
DefaultFreemarkerEmailConfigurer: 80000
 | |
| 1650 | *
DefaultThymeleafSmsConfigurer: 70000
 | |
| 1651 | *
DefaultFreemarkerSmsConfigurer: 60000
 | |
| 1652 | *
DefaultJavaMailConfigurer: 50000
 | |
| 1653 | *
DefaultCloudhopperConfigurer: 40000
 | |
| 1654 | *
DefaultSendGridConfigurer: 30000
 | |
| 1655 | *
DefaultOvhSmsConfigurer: 20000
 | |
| 1656 | *
 | |
| 1657 | * | |
| 1658 | * TODO: link to whole configuration that is applied by standard | |
| 1659 | * | |
| 1660 | *
 | |
| 1661 | * The auto-configured {@link MessagingBuilder} will provide a default | |
| 1662 | * behavior that fits 95% of usages. You can still override some behaviors | |
| 1663 | * for your needs. | |
| 1664 | * | |
| 1665 | * For example: | |
| 1666 | * | |
| 1667 | *
 | |
| 1668 | *  | |
| 1669 | * MessagingService service = MessagingBuilder.standard() | |
| 1670 | * .environment() | |
| 1671 | * .properties("application.properties") | |
| 1672 | * .and() | |
| 1673 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
| 1674 | * .build(); | |
| 1675 | *  | |
| 1676 | *
 | |
| 1677 | * | |
| 1678 | * @param autoconfigure | |
| 1679 | * true to automatically apply found configurers, false to | |
| 1680 | * configure manually later by calling | |
| 1681 | * {@link #configure(ConfigurationPhase)} | |
| 1682 | * @param basePackages | |
| 1683 | * the base packages that are scanned to find | |
| 1684 | * {@link MessagingConfigurer} implementations | |
| 1685 | * @return the messaging builder that can be customized | |
| 1686 | */ | |
| 1687 | public static MessagingBuilder standard(boolean autoconfigure, String... basePackages) { | |
| 1688 |
2
1. lambda$standard$0 : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::lambda$standard$0 → RUN_ERROR 2. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → RUN_ERROR |
return standard(() -> new MessagingBuilder(autoconfigure), autoconfigure, basePackages); |
| 1689 | } | |
| 1690 | ||
| 1691 | /** | |
| 1692 | * Static factory method that initializes a {@link MessagingBuilder} | |
| 1693 | * instance and registers auto-configures but doesn't apply them if | |
| 1694 | * autoconfigure parameter is false. The | |
| 1695 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
| 1696 | * | |
| 1697 | *
 | |
| 1698 | * This method allows to use a custom {@link MessagingBuilder} | |
| 1699 | * implementation. | |
| 1700 | * | |
| 1701 | *
 | |
| 1702 | * NOTE: This is for advanced usage only. | |
| 1703 | * | |
| 1704 | * Usage example: | |
| 1705 | * | |
| 1706 | *
 | |
| 1707 | *  | |
| 1708 | * MessagingService service = MessagingBuilder.standard() | |
| 1709 | * .environment() | |
| 1710 | * .properties("application.properties") | |
| 1711 | * .and() | |
| 1712 | * .build(); | |
| 1713 | *  | |
| 1714 | *
 | |
| 1715 | * | |
| 1716 | *
 | |
| 1717 | * Basically, the standard behavior: | |
| 1718 | *
 | |
| 1719 | *
Enables all template engines that are present in the classpath and | |
| 1720 | * configures them
 | |
| 1721 | *
Enables all {@link Email} sender implementations that are present in | |
| 1722 | * the classpath and configures them
 | |
| 1723 | *
Enables all {@link Sms} sender implementations that are present in | |
| 1724 | * the classpath and configures them
 | |
| 1725 | *
Catches all uncaught exception to wrap them in order to avoid | |
| 1726 | * unwanted unchecked exception
 | |
| 1727 | *
Uses system properties
 | |
| 1728 | *
Enables and configures useful auto-filling mechanisms (using property | |
| 1729 | * values and providing email subject from templates)
 | |
| 1730 | *
Enables mimetype detection
 | |
| 1731 | *
Enables locating templates, css, images and all other resources using | |
| 1732 | * lookup prefix ("file:" for files that are present on the filesystem, | |
| 1733 | * "classpath:" and "" for files that are present in the classpath)
 | |
| 1734 | *
Enables use of some properties to provide path prefix/suffix for | |
| 1735 | * locating resources
 | |
| 1736 | *
Enables images and css inlining used by HTML {@link Email}s
 | |
| 1737 | *
 | |
| 1738 | * | |
| 1739 | *
 | |
| 1740 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
| 1741 | * loaded from the classpath. Only configurers that are in the provided | |
| 1742 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
| 1743 | * meaning that according to used modules, the behavior will vary. | |
| 1744 | * | |
| 1745 | * Loaded {@link MessagingConfigurer}s are applied to the | |
| 1746 | * {@link MessagingBuilder} only if they are for the "standard" builder. It | |
| 1747 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
| 1748 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
| 1749 | * set to "standard"). | |
| 1750 | * | |
| 1751 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
| 1752 | *
 | |
| 1753 | *
DefaultMessagingConfigurer: 100000
 | |
| 1754 | *
DefaultThymeleafEmailConfigurer: 90000
 | |
| 1755 | *
DefaultFreemarkerEmailConfigurer: 80000
 | |
| 1756 | *
DefaultThymeleafSmsConfigurer: 70000
 | |
| 1757 | *
DefaultFreemarkerSmsConfigurer: 60000
 | |
| 1758 | *
DefaultJavaMailConfigurer: 50000
 | |
| 1759 | *
DefaultCloudhopperConfigurer: 40000
 | |
| 1760 | *
DefaultSendGridConfigurer: 30000
 | |
| 1761 | *
DefaultOvhSmsConfigurer: 20000
 | |
| 1762 | *
 | |
| 1763 | * | |
| 1764 | * TODO: link to whole configuration that is applied by standard | |
| 1765 | * | |
| 1766 | *
 | |
| 1767 | * The auto-configured {@link MessagingBuilder} will provide a default | |
| 1768 | * behavior that fits 95% of usages. You can still override some behaviors | |
| 1769 | * for your needs. | |
| 1770 | * | |
| 1771 | * For example: | |
| 1772 | * | |
| 1773 | *
 | |
| 1774 | *  | |
| 1775 | * MessagingService service = MessagingBuilder.standard() | |
| 1776 | * .environment() | |
| 1777 | * .properties("application.properties") | |
| 1778 | * .and() | |
| 1779 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
| 1780 | * .build(); | |
| 1781 | *  | |
| 1782 | *
 | |
| 1783 | * | |
| 1784 | * | |
| 1785 | * @param factory | |
| 1786 | * the factory used to create the {@link MessagingBuilder} | |
| 1787 | * instance | |
| 1788 | * @param autoconfigure | |
| 1789 | * true to automatically apply found configurers, false to | |
| 1790 | * configure manually later by calling | |
| 1791 | * {@link #configure(ConfigurationPhase)} | |
| 1792 | * @param basePackages | |
| 1793 | * the base packages that are scanned to find | |
| 1794 | * {@link MessagingConfigurer} implementations | |
| 1795 | * @param <T> | |
| 1796 | * the type of final {@link MessagingBuilder} | |
| 1797 | * @return the messaging builder that can be customized | |
| 1798 | */ | |
| 1799 | public static <T extends MessagingBuilder> T standard(Supplier<T> factory, boolean autoconfigure, String... basePackages) { | |
| 1800 | T builder = factory.get(); | |
| 1801 |
1
1. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → RUN_ERROR |
findAndRegister(builder, "standard", basePackages); |
| 1802 |
1
1. standard : negated conditional → RUN_ERROR |
if (autoconfigure) { |
| 1803 |
1
1. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → RUN_ERROR |
builder.configure(ConfigurationPhase.AFTER_INIT); |
| 1804 | } | |
| 1805 |
1
1. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → RUN_ERROR |
return builder; |
| 1806 | } | |
| 1807 | ||
| 1808 | /** | |
| 1809 | * Static factory method that initializes a {@link MessagingBuilder} | |
| 1810 | * instance and auto-configures it with a predefined behavior named | |
| 1811 | * "minimal". | |
| 1812 | * | |
| 1813 | * Usage example: | |
| 1814 | * | |
| 1815 | *
 | |
| 1816 | *  | |
| 1817 | * MessagingService service = MessagingBuilder.minimal() | |
| 1818 | * .environment() | |
| 1819 | * .properties("application.properties") | |
| 1820 | * .and() | |
| 1821 | * .build(); | |
| 1822 | *  | |
| 1823 | *
 | |
| 1824 | * | |
| 1825 | *
 | |
| 1826 | * Basically, the minimal behavior: | |
| 1827 | *
 | |
| 1828 | *
Enables all template engines that are present in the classpath and | |
| 1829 | * configures them
 | |
| 1830 | *
Catches all uncaught exception to wrap them in order to avoid | |
| 1831 | * unwanted unchecked exception
 | |
| 1832 | *
Uses system properties
 | |
| 1833 | *
Enables and configures useful auto-filling mechanisms (using property | |
| 1834 | * values and providing email subject from templates)
 | |
| 1835 | *
Enables mimetype detection
 | |
| 1836 | *
Enables locating templates, css, images and all other resources using | |
| 1837 | * lookup prefix ("file:" for files that are present on the filesystem, | |
| 1838 | * "classpath:" and "" for files that are present in the classpath)
 | |
| 1839 | *
Enables use of some properties to provide path prefix/suffix for | |
| 1840 | * locating resources
 | |
| 1841 | *
Enables images and css inlining used by HTML {@link Email}s
 | |
| 1842 | *
 | |
| 1843 | * | |
| 1844 | * The minimal behavior doesn't automatically auto-configure sender | |
| 1845 | * implementations. | |
| 1846 | * | |
| 1847 | *
 | |
| 1848 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
| 1849 | * loaded from the classpath. Only configurers that are in "fr.sii.ogham" | |
| 1850 | * package and sub-packages are loaded. If you want to load from other | |
| 1851 | * packages, use {@link #minimal(String...)}. Some Ogham modules are | |
| 1852 | * optional meaning that according to used modules, the behavior will vary. | |
| 1853 | * | |
| 1854 | * Loaded {@link MessagingConfigurer}s are applied to the | |
| 1855 | * {@link MessagingBuilder} only if they are for the "minimal" builder. It | |
| 1856 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
| 1857 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
| 1858 | * set to "minimal"). | |
| 1859 | * | |
| 1860 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
| 1861 | *
 | |
| 1862 | *
DefaultMessagingConfigurer: 100000
 | |
| 1863 | *
DefaultThymeleafEmailConfigurer: 90000
 | |
| 1864 | *
DefaultFreemarkerEmailConfigurer: 80000
 | |
| 1865 | *
DefaultThymeleafSmsConfigurer: 70000
 | |
| 1866 | *
DefaultFreemarkerSmsConfigurer: 60000
 | |
| 1867 | *
 | |
| 1868 | * | |
| 1869 | * TODO: link to whole configuration that is applied by minimal | |
| 1870 | * | |
| 1871 | *
 | |
| 1872 | * The auto-configured {@link MessagingBuilder} will provide a default | |
| 1873 | * behavior with no sender implementation. This is useful if you only want | |
| 1874 | * to use a particular implementation or your custom sender implementation. | |
| 1875 | * You can still override some behaviors for your needs. | |
| 1876 | * | |
| 1877 | * For example: | |
| 1878 | * | |
| 1879 | *
 | |
| 1880 | *  | |
| 1881 | * MessagingService service = MessagingBuilder.minimal() | |
| 1882 | * .environment() | |
| 1883 | * .properties("application.properties") | |
| 1884 | * .and() | |
| 1885 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
| 1886 | * .build(); | |
| 1887 | *  | |
| 1888 | *
 | |
| 1889 | * | |
| 1890 | * @return the messaging builder that can be customized | |
| 1891 | */ | |
| 1892 | public static MessagingBuilder minimal() { | |
| 1893 |
1
1. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → RUN_ERROR |
return minimal(BASE_PACKAGE); |
| 1894 | } | |
| 1895 | ||
| 1896 | /** | |
| 1897 | * Static factory method that initializes a {@link MessagingBuilder} | |
| 1898 | * instance and auto-configures it with a predefined behavior named | |
| 1899 | * "minimal". | |
| 1900 | * | |
| 1901 | * Usage example: | |
| 1902 | * | |
| 1903 | *
 | |
| 1904 | *  | |
| 1905 | * MessagingService service = MessagingBuilder.minimal() | |
| 1906 | * .environment() | |
| 1907 | * .properties("application.properties") | |
| 1908 | * .and() | |
| 1909 | * .build(); | |
| 1910 | *  | |
| 1911 | *
 | |
| 1912 | * | |
| 1913 | *
 | |
| 1914 | * Basically, the minimal behavior: | |
| 1915 | *
 | |
| 1916 | *
Enables all template engines that are present in the classpath and | |
| 1917 | * configures them
 | |
| 1918 | *
Catches all uncaught exception to wrap them in order to avoid | |
| 1919 | * unwanted unchecked exception
 | |
| 1920 | *
Uses system properties
 | |
| 1921 | *
Enables and configures useful auto-filling mechanisms (using property | |
| 1922 | * values and providing email subject from templates)
 | |
| 1923 | *
Enables mimetype detection
 | |
| 1924 | *
Enables locating templates, css, images and all other resources using | |
| 1925 | * lookup prefix ("file:" for files that are present on the filesystem, | |
| 1926 | * "classpath:" and "" for files that are present in the classpath)
 | |
| 1927 | *
Enables use of some properties to provide path prefix/suffix for | |
| 1928 | * locating resources
 | |
| 1929 | *
Enables images and css inlining used by HTML {@link Email}s
 | |
| 1930 | *
 | |
| 1931 | * | |
| 1932 | * The minimal behavior doesn't automatically auto-configure sender | |
| 1933 | * implementations. | |
| 1934 | * | |
| 1935 | *
 | |
| 1936 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
| 1937 | * loaded from the classpath. Only configurers that are in the provided | |
| 1938 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
| 1939 | * meaning that according to used modules, the behavior will vary. | |
| 1940 | * | |
| 1941 | * Loaded {@link MessagingConfigurer}s are applied to the | |
| 1942 | * {@link MessagingBuilder} only if they are for the "minimal" builder. It | |
| 1943 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
| 1944 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
| 1945 | * set to "minimal"). | |
| 1946 | * | |
| 1947 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
| 1948 | *
 | |
| 1949 | *
DefaultMessagingConfigurer: 100000
 | |
| 1950 | *
DefaultThymeleafEmailConfigurer: 90000
 | |
| 1951 | *
DefaultFreemarkerEmailConfigurer: 80000
 | |
| 1952 | *
DefaultThymeleafSmsConfigurer: 70000
 | |
| 1953 | *
DefaultFreemarkerSmsConfigurer: 60000
 | |
| 1954 | *
 | |
| 1955 | * | |
| 1956 | * TODO: link to whole configuration that is applied by minimal | |
| 1957 | * | |
| 1958 | *
 | |
| 1959 | * The auto-configured {@link MessagingBuilder} will provide a default | |
| 1960 | * behavior with no sender implementation. This is useful if you only want | |
| 1961 | * to use a particular implementation or your custom sender implementation. | |
| 1962 | * You can still override some behaviors for your needs. | |
| 1963 | * | |
| 1964 | * For example: | |
| 1965 | * | |
| 1966 | *
 | |
| 1967 | *  | |
| 1968 | * MessagingService service = MessagingBuilder.minimal() | |
| 1969 | * .environment() | |
| 1970 | * .properties("application.properties") | |
| 1971 | * .and() | |
| 1972 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
| 1973 | * .build(); | |
| 1974 | *  | |
| 1975 | *
 | |
| 1976 | * | |
| 1977 | * @param basePackages | |
| 1978 | * the base packages that are scanned to find | |
| 1979 | * {@link MessagingConfigurer} implementations | |
| 1980 | * @return the messaging builder that can be customized | |
| 1981 | */ | |
| 1982 | public static MessagingBuilder minimal(String... basePackages) { | |
| 1983 |
1
1. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → RUN_ERROR |
return minimal(true, basePackages); |
| 1984 | } | |
| 1985 | ||
| 1986 | /** | |
| 1987 | * Static factory method that initializes a {@link MessagingBuilder} | |
| 1988 | * instance and registers auto-configures but doesn't apply them if | |
| 1989 | * autoconfigure parameter is false. The | |
| 1990 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
| 1991 | * | |
| 1992 | * Usage example: | |
| 1993 | * | |
| 1994 | *
 | |
| 1995 | *  | |
| 1996 | * MessagingService service = MessagingBuilder.minimal() | |
| 1997 | * .environment() | |
| 1998 | * .properties("application.properties") | |
| 1999 | * .and() | |
| 2000 | * .build(); | |
| 2001 | *  | |
| 2002 | *
 | |
| 2003 | * | |
| 2004 | *
 | |
| 2005 | * Basically, the minimal behavior: | |
| 2006 | *
 | |
| 2007 | *
Enables all template engines that are present in the classpath and | |
| 2008 | * configures them
 | |
| 2009 | *
Catches all uncaught exception to wrap them in order to avoid | |
| 2010 | * unwanted unchecked exception
 | |
| 2011 | *
Uses system properties
 | |
| 2012 | *
Enables and configures useful auto-filling mechanisms (using property | |
| 2013 | * values and providing email subject from templates)
 | |
| 2014 | *
Enables mimetype detection
 | |
| 2015 | *
Enables locating templates, css, images and all other resources using | |
| 2016 | * lookup prefix ("file:" for files that are present on the filesystem, | |
| 2017 | * "classpath:" and "" for files that are present in the classpath)
 | |
| 2018 | *
Enables use of some properties to provide path prefix/suffix for | |
| 2019 | * locating resources
 | |
| 2020 | *
Enables images and css inlining used by HTML {@link Email}s
 | |
| 2021 | *
 | |
| 2022 | * | |
| 2023 | * The minimal behavior doesn't automatically auto-configure sender | |
| 2024 | * implementations. | |
| 2025 | * | |
| 2026 | *
 | |
| 2027 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
| 2028 | * loaded from the classpath. Only configurers that are in "fr.sii.ogham" | |
| 2029 | * package and sub-packages are loaded. If you want to load from other | |
| 2030 | * packages, use {@link #minimal(String...)}. Some Ogham modules are | |
| 2031 | * optional meaning that according to used modules, the behavior will vary. | |
| 2032 | * | |
| 2033 | * Loaded {@link MessagingConfigurer}s are applied to the | |
| 2034 | * {@link MessagingBuilder} only if they are for the "minimal" builder. It | |
| 2035 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
| 2036 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
| 2037 | * set to "minimal"). | |
| 2038 | * | |
| 2039 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
| 2040 | *
 | |
| 2041 | *
DefaultMessagingConfigurer: 100000
 | |
| 2042 | *
DefaultThymeleafEmailConfigurer: 90000
 | |
| 2043 | *
DefaultFreemarkerEmailConfigurer: 80000
 | |
| 2044 | *
DefaultThymeleafSmsConfigurer: 70000
 | |
| 2045 | *
DefaultFreemarkerSmsConfigurer: 60000
 | |
| 2046 | *
 | |
| 2047 | * | |
| 2048 | * TODO: link to whole configuration that is applied by minimal | |
| 2049 | * | |
| 2050 | *
 | |
| 2051 | * The auto-configured {@link MessagingBuilder} will provide a default | |
| 2052 | * behavior with no sender implementation. This is useful if you only want | |
| 2053 | * to use a particular implementation or your custom sender implementation. | |
| 2054 | * You can still override some behaviors for your needs. | |
| 2055 | * | |
| 2056 | * For example: | |
| 2057 | * | |
| 2058 | *
 | |
| 2059 | *  | |
| 2060 | * MessagingService service = MessagingBuilder.minimal() | |
| 2061 | * .environment() | |
| 2062 | * .properties("application.properties") | |
| 2063 | * .and() | |
| 2064 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
| 2065 | * .build(); | |
| 2066 | *  | |
| 2067 | *
 | |
| 2068 | * | |
| 2069 | * @param autoconfigure | |
| 2070 | * true to automatically apply found configurers, false to | |
| 2071 | * configure manually later by calling | |
| 2072 | * {@link #configure(ConfigurationPhase)} | |
| 2073 | * @return the messaging builder that can be customized | |
| 2074 | */ | |
| 2075 | public static MessagingBuilder minimal(boolean autoconfigure) { | |
| 2076 |
1
1. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → NO_COVERAGE |
return minimal(autoconfigure, BASE_PACKAGE); |
| 2077 | } | |
| 2078 | ||
| 2079 | /** | |
| 2080 | * Static factory method that initializes a {@link MessagingBuilder} | |
| 2081 | * instance and registers auto-configures but doesn't apply them if | |
| 2082 | * autoconfigure parameter is false. The | |
| 2083 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
| 2084 | * | |
| 2085 | * | |
| 2086 | * Usage example: | |
| 2087 | * | |
| 2088 | *
 | |
| 2089 | *  | |
| 2090 | * MessagingService service = MessagingBuilder.minimal() | |
| 2091 | * .environment() | |
| 2092 | * .properties("application.properties") | |
| 2093 | * .and() | |
| 2094 | * .build(); | |
| 2095 | *  | |
| 2096 | *
 | |
| 2097 | * | |
| 2098 | *
 | |
| 2099 | * Basically, the minimal behavior: | |
| 2100 | *
 | |
| 2101 | *
Enables all template engines that are present in the classpath and | |
| 2102 | * configures them
 | |
| 2103 | *
Catches all uncaught exception to wrap them in order to avoid | |
| 2104 | * unwanted unchecked exception
 | |
| 2105 | *
Uses system properties
 | |
| 2106 | *
Enables and configures useful auto-filling mechanisms (using property | |
| 2107 | * values and providing email subject from templates)
 | |
| 2108 | *
Enables mimetype detection
 | |
| 2109 | *
Enables locating templates, css, images and all other resources using | |
| 2110 | * lookup prefix ("file:" for files that are present on the filesystem, | |
| 2111 | * "classpath:" and "" for files that are present in the classpath)
 | |
| 2112 | *
Enables use of some properties to provide path prefix/suffix for | |
| 2113 | * locating resources
 | |
| 2114 | *
Enables images and css inlining used by HTML {@link Email}s
 | |
| 2115 | *
 | |
| 2116 | * | |
| 2117 | * The minimal behavior doesn't automatically auto-configure sender | |
| 2118 | * implementations. | |
| 2119 | * | |
| 2120 | *
 | |
| 2121 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
| 2122 | * loaded from the classpath. Only configurers that are in the provided | |
| 2123 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
| 2124 | * meaning that according to used modules, the behavior will vary. | |
| 2125 | * | |
| 2126 | * Loaded {@link MessagingConfigurer}s are applied to the | |
| 2127 | * {@link MessagingBuilder} only if they are for the "minimal" builder. It | |
| 2128 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
| 2129 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
| 2130 | * set to "minimal"). | |
| 2131 | * | |
| 2132 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
| 2133 | *
 | |
| 2134 | *
DefaultMessagingConfigurer: 100000
 | |
| 2135 | *
DefaultThymeleafEmailConfigurer: 90000
 | |
| 2136 | *
DefaultFreemarkerEmailConfigurer: 80000
 | |
| 2137 | *
DefaultThymeleafSmsConfigurer: 70000
 | |
| 2138 | *
DefaultFreemarkerSmsConfigurer: 60000
 | |
| 2139 | *
 | |
| 2140 | * | |
| 2141 | * TODO: link to whole configuration that is applied by minimal | |
| 2142 | * | |
| 2143 | *
 | |
| 2144 | * The auto-configured {@link MessagingBuilder} will provide a default | |
| 2145 | * behavior with no sender implementation. This is useful if you only want | |
| 2146 | * to use a particular implementation or your custom sender implementation. | |
| 2147 | * You can still override some behaviors for your needs. | |
| 2148 | * | |
| 2149 | * For example: | |
| 2150 | * | |
| 2151 | *
 | |
| 2152 | *  | |
| 2153 | * MessagingService service = MessagingBuilder.minimal() | |
| 2154 | * .environment() | |
| 2155 | * .properties("application.properties") | |
| 2156 | * .and() | |
| 2157 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
| 2158 | * .build(); | |
| 2159 | *  | |
| 2160 | *
 | |
| 2161 | * | |
| 2162 | * @param autoconfigure | |
| 2163 | * true to automatically apply found configurers, false to | |
| 2164 | * configure manually later by calling | |
| 2165 | * {@link #configure(ConfigurationPhase)} | |
| 2166 | * @param basePackages | |
| 2167 | * the base packages that are scanned to find | |
| 2168 | * {@link MessagingConfigurer} implementations | |
| 2169 | * @return the messaging builder that can be customized | |
| 2170 | */ | |
| 2171 | public static MessagingBuilder minimal(boolean autoconfigure, String... basePackages) { | |
| 2172 |
2
1. lambda$minimal$1 : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::lambda$minimal$1 → RUN_ERROR 2. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → RUN_ERROR |
return minimal(() -> new MessagingBuilder(autoconfigure), autoconfigure, basePackages); |
| 2173 | } | |
| 2174 | ||
| 2175 | /** | |
| 2176 | * Static factory method that initializes a {@link MessagingBuilder} | |
| 2177 | * instance and registers auto-configures but doesn't apply them if | |
| 2178 | * autoconfigure parameter is false. The | |
| 2179 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
| 2180 | * | |
| 2181 | *
 | |
| 2182 | * This method allows to use a custom {@link MessagingBuilder} | |
| 2183 | * implementation. | |
| 2184 | * | |
| 2185 | *
 | |
| 2186 | * NOTE: This is for advanced usage only. | |
| 2187 | * | |
| 2188 | * | |
| 2189 | * Usage example: | |
| 2190 | * | |
| 2191 | *
 | |
| 2192 | *  | |
| 2193 | * MessagingService service = MessagingBuilder.minimal() | |
| 2194 | * .environment() | |
| 2195 | * .properties("application.properties") | |
| 2196 | * .and() | |
| 2197 | * .build(); | |
| 2198 | *  | |
| 2199 | *
 | |
| 2200 | * | |
| 2201 | *
 | |
| 2202 | * Basically, the minimal behavior: | |
| 2203 | *
 | |
| 2204 | *
Enables all template engines that are present in the classpath and | |
| 2205 | * configures them
 | |
| 2206 | *
Catches all uncaught exception to wrap them in order to avoid | |
| 2207 | * unwanted unchecked exception
 | |
| 2208 | *
Uses system properties
 | |
| 2209 | *
Enables and configures useful auto-filling mechanisms (using property | |
| 2210 | * values and providing email subject from templates)
 | |
| 2211 | *
Enables mimetype detection
 | |
| 2212 | *
Enables locating templates, css, images and all other resources using | |
| 2213 | * lookup prefix ("file:" for files that are present on the filesystem, | |
| 2214 | * "classpath:" and "" for files that are present in the classpath)
 | |
| 2215 | *
Enables use of some properties to provide path prefix/suffix for | |
| 2216 | * locating resources
 | |
| 2217 | *
Enables images and css inlining used by HTML {@link Email}s
 | |
| 2218 | *
 | |
| 2219 | * | |
| 2220 | * The minimal behavior doesn't automatically auto-configure sender | |
| 2221 | * implementations. | |
| 2222 | * | |
| 2223 | *
 | |
| 2224 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
| 2225 | * loaded from the classpath. Only configurers that are in the provided | |
| 2226 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
| 2227 | * meaning that according to used modules, the behavior will vary. | |
| 2228 | * | |
| 2229 | * Loaded {@link MessagingConfigurer}s are applied to the | |
| 2230 | * {@link MessagingBuilder} only if they are for the "minimal" builder. It | |
| 2231 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
| 2232 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
| 2233 | * set to "minimal"). | |
| 2234 | * | |
| 2235 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
| 2236 | *
 | |
| 2237 | *
DefaultMessagingConfigurer: 100000
 | |
| 2238 | *
DefaultThymeleafEmailConfigurer: 90000
 | |
| 2239 | *
DefaultFreemarkerEmailConfigurer: 80000
 | |
| 2240 | *
DefaultThymeleafSmsConfigurer: 70000
 | |
| 2241 | *
DefaultFreemarkerSmsConfigurer: 60000
 | |
| 2242 | *
 | |
| 2243 | * | |
| 2244 | * TODO: link to whole configuration that is applied by minimal | |
| 2245 | * | |
| 2246 | *
 | |
| 2247 | * The auto-configured {@link MessagingBuilder} will provide a default | |
| 2248 | * behavior with no sender implementation. This is useful if you only want | |
| 2249 | * to use a particular implementation or your custom sender implementation. | |
| 2250 | * You can still override some behaviors for your needs. | |
| 2251 | * | |
| 2252 | * For example: | |
| 2253 | * | |
| 2254 | *
 | |
| 2255 | *  | |
| 2256 | * MessagingService service = MessagingBuilder.minimal() | |
| 2257 | * .environment() | |
| 2258 | * .properties("application.properties") | |
| 2259 | * .and() | |
| 2260 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
| 2261 | * .build(); | |
| 2262 | *  | |
| 2263 | *
 | |
| 2264 | * | |
| 2265 | * @param factory | |
| 2266 | * the factory used to create the {@link MessagingBuilder} | |
| 2267 | * instance | |
| 2268 | * @param autoconfigure | |
| 2269 | * true to automatically apply found configurers, false to | |
| 2270 | * configure manually later by calling | |
| 2271 | * {@link #configure(ConfigurationPhase)} | |
| 2272 | * @param basePackages | |
| 2273 | * the base packages that are scanned to find | |
| 2274 | * {@link MessagingConfigurer} implementations | |
| 2275 | * @param <T> | |
| 2276 | * the type of final {@link MessagingBuilder} | |
| 2277 | * @return the messaging builder that can be customized | |
| 2278 | */ | |
| 2279 | public static <T extends MessagingBuilder> T minimal(Supplier<T> factory, boolean autoconfigure, String... basePackages) { | |
| 2280 | T builder = factory.get(); | |
| 2281 |
1
1. minimal : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → RUN_ERROR |
findAndRegister(builder, "minimal", basePackages); |
| 2282 |
1
1. minimal : negated conditional → RUN_ERROR |
if (autoconfigure) { |
| 2283 |
1
1. minimal : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → RUN_ERROR |
builder.configure(ConfigurationPhase.AFTER_INIT); |
| 2284 | } | |
| 2285 |
1
1. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → RUN_ERROR |
return builder; |
| 2286 | } | |
| 2287 | ||
| 2288 | /** | |
| 2289 | * You can use this method if {@link #standard()} and {@link #minimal()} | |
| 2290 | * factory methods doesn't fit your needs. The aim is to auto-configure a | |
| 2291 | * builder with matching configurers. | |
| 2292 | * | |
| 2293 | * Utility method that searches all {@link MessagingConfigurer}s that are in | |
| 2294 | * the classpath. Only configurers that are in the provided packages (and | |
| 2295 | * sub-packages) are loaded. | |
| 2296 | * | |
| 2297 | * Once configurers are found, they are filtered thanks to information | |
| 2298 | * provided by {@link ConfigurerFor} annotation. Only configurers with | |
| 2299 | * {@link ConfigurerFor#targetedBuilder()} value that matches the | |
| 2300 | * builderName parameter are kept. | |
| 2301 | * | |
| 2302 | * The found and filtered configurers are registered into the provided | |
| 2303 | * builder instance. | |
| 2304 | * | |
| 2305 | * @param builder | |
| 2306 | * the builder to configure with matching configurers | |
| 2307 | * @param builderName | |
| 2308 | * the name that is referenced by | |
| 2309 | * {@link ConfigurerFor#targetedBuilder()} | |
| 2310 | * @param basePackages | |
| 2311 | * the packages that are scanned to find | |
| 2312 | * {@link MessagingConfigurer} implementations | |
| 2313 | */ | |
| 2314 | public static void findAndRegister(MessagingBuilder builder, String builderName, String... basePackages) { | |
| 2315 | Reflections reflections = new Reflections(basePackages, new SubTypesScanner()); | |
| 2316 | Set<Class<? extends MessagingConfigurer>> configurerClasses = reflections.getSubTypesOf(MessagingConfigurer.class); | |
| 2317 | for (Class<? extends MessagingConfigurer> configurerClass : configurerClasses) { | |
| 2318 | ConfigurerFor annotation = configurerClass.getAnnotation(ConfigurerFor.class); | |
| 2319 |
2
1. findAndRegister : negated conditional → RUN_ERROR 2. findAndRegister : negated conditional → RUN_ERROR |
if (annotation != null && asList(annotation.targetedBuilder()).contains(builderName)) { |
| 2320 |
1
1. findAndRegister : removed call to fr/sii/ogham/core/builder/MessagingBuilder::register → RUN_ERROR |
register(builder, builderName, configurerClass, annotation); |
| 2321 | } | |
| 2322 | } | |
| 2323 | } | |
| 2324 | ||
| 2325 | private static void register(MessagingBuilder builder, String builderName, Class<? extends MessagingConfigurer> configurerClass, ConfigurerFor annotation) { | |
| 2326 | try { | |
| 2327 | builder.register(configurerClass.newInstance(), annotation.priority(), annotation.phase()); | |
| 2328 | } catch (InstantiationException | IllegalAccessException e) { | |
| 2329 | throw new BuildException("Failed to register custom auto-discovered configurer (" + configurerClass.getSimpleName() + ") for " + builderName + " messaging builder", e); | |
| 2330 | } | |
| 2331 | } | |
| 2332 | ||
| 2333 | private List<ConditionalSender> buildSenders() { | |
| 2334 | List<ConditionalSender> senders = new ArrayList<>(); | |
| 2335 |
1
1. buildSenders : negated conditional → RUN_ERROR |
if (emailBuilder != null) { |
| 2336 | LOG.debug("building email sender with {}", emailBuilder); | |
| 2337 | senders.add(emailBuilder.build()); | |
| 2338 | } | |
| 2339 |
1
1. buildSenders : negated conditional → RUN_ERROR |
if (smsBuilder != null) { |
| 2340 | LOG.debug("building email sender with {}", emailBuilder); | |
| 2341 | senders.add(smsBuilder.build()); | |
| 2342 | } | |
| 2343 |
1
1. buildSenders : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/MessagingBuilder::buildSenders → RUN_ERROR |
return senders; |
| 2344 | } | |
| 2345 | ||
| 2346 | private boolean alreadyConfigured(ConfigurationPhase phase) { | |
| 2347 | Boolean configured = alreadyConfigured.get(phase); | |
| 2348 |
3
1. alreadyConfigured : negated conditional → NO_COVERAGE 2. alreadyConfigured : negated conditional → RUN_ERROR 3. alreadyConfigured : replaced boolean return with true for fr/sii/ogham/core/builder/MessagingBuilder::alreadyConfigured → RUN_ERROR |
return configured != null && configured; |
| 2349 | } | |
| 2350 | ||
| 2351 | private static class ConfigurerWithPhase { | |
| 2352 | private final MessagingConfigurer configurer; | |
| 2353 | private final ConfigurationPhase phase; | |
| 2354 | ||
| 2355 | public ConfigurerWithPhase(MessagingConfigurer configurer, ConfigurationPhase phase) { | |
| 2356 | super(); | |
| 2357 | this.configurer = configurer; | |
| 2358 | this.phase = phase; | |
| 2359 | } | |
| 2360 | ||
| 2361 | public MessagingConfigurer getConfigurer() { | |
| 2362 |
1
1. getConfigurer : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getConfigurer → RUN_ERROR |
return configurer; |
| 2363 | } | |
| 2364 | ||
| 2365 | public ConfigurationPhase getPhase() { | |
| 2366 |
1
1. getPhase : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getPhase → RUN_ERROR |
return phase; |
| 2367 | } | |
| 2368 | ||
| 2369 | } | |
| 2370 | } | |
Mutations | ||
| 327 |
1.1 |
|
| 357 |
1.1 |
|
| 372 |
1.1 |
|
| 376 |
1.1 |
|
| 380 |
1.1 |
|
| 437 |
1.1 |
|
| 505 |
1.1 |
|
| 557 |
1.1 |
|
| 617 |
1.1 |
|
| 618 |
1.1 |
|
| 680 |
1.1 |
|
| 979 |
1.1 |
|
| 982 |
1.1 |
|
| 1223 |
1.1 |
|
| 1226 |
1.1 |
|
| 1252 |
1.1 |
|
| 1253 |
1.1 |
|
| 1259 |
1.1 |
|
| 1263 |
1.1 |
|
| 1267 |
1.1 |
|
| 1271 |
1.1 |
|
| 1275 |
1.1 |
|
| 1279 |
1.1 |
|
| 1283 |
1.1 |
|
| 1286 |
1.1 |
|
| 1290 |
1.1 |
|
| 1294 |
1.1 |
|
| 1306 |
1.1 |
|
| 1398 |
1.1 |
|
| 1492 |
1.1 |
|
| 1589 |
1.1 |
|
| 1688 |
1.1 2.2 |
|
| 1801 |
1.1 |
|
| 1802 |
1.1 |
|
| 1803 |
1.1 |
|
| 1805 |
1.1 |
|
| 1893 |
1.1 |
|
| 1983 |
1.1 |
|
| 2076 |
1.1 |
|
| 2172 |
1.1 2.2 |
|
| 2281 |
1.1 |
|
| 2282 |
1.1 |
|
| 2283 |
1.1 |
|
| 2285 |
1.1 |
|
| 2319 |
1.1 2.2 |
|
| 2320 |
1.1 |
|
| 2335 |
1.1 |
|
| 2339 |
1.1 |
|
| 2343 |
1.1 |
|
| 2348 |
1.1 2.2 3.3 |
|
| 2362 |
1.1 |
|
| 2366 |
1.1 |