| 1 | package fr.sii.ogham.email.builder; | |
| 2 | ||
| 3 | import java.io.InputStream; | |
| 4 | import java.nio.file.Files; | |
| 5 | import java.util.List; | |
| 6 | ||
| 7 | import javax.activation.MimetypesFileTypeMap; | |
| 8 | ||
| 9 | import org.slf4j.Logger; | |
| 10 | import org.slf4j.LoggerFactory; | |
| 11 | ||
| 12 | import fr.sii.ogham.core.builder.Builder; | |
| 13 | import fr.sii.ogham.core.builder.context.BuildContext; | |
| 14 | import fr.sii.ogham.core.builder.env.EnvironmentBuilder; | |
| 15 | import fr.sii.ogham.core.builder.mimetype.MimetypeDetectionBuilder; | |
| 16 | import fr.sii.ogham.core.builder.mimetype.MimetypeDetectionBuilderDelegate; | |
| 17 | import fr.sii.ogham.core.builder.mimetype.SimpleMimetypeDetectionBuilder; | |
| 18 | import fr.sii.ogham.core.builder.resolution.ClassPathResolutionBuilder; | |
| 19 | import fr.sii.ogham.core.builder.resolution.FileResolutionBuilder; | |
| 20 | import fr.sii.ogham.core.builder.resolution.ResourceResolutionBuilder; | |
| 21 | import fr.sii.ogham.core.builder.resolution.ResourceResolutionBuilderHelper; | |
| 22 | import fr.sii.ogham.core.builder.resolution.StringResolutionBuilder; | |
| 23 | import fr.sii.ogham.core.fluent.AbstractParent; | |
| 24 | import fr.sii.ogham.core.mimetype.MimeTypeProvider; | |
| 25 | import fr.sii.ogham.core.resource.path.LookupAwareRelativePathResolver; | |
| 26 | import fr.sii.ogham.core.resource.path.RelativePathResolver; | |
| 27 | import fr.sii.ogham.core.resource.resolver.FirstSupportingResourceResolver; | |
| 28 | import fr.sii.ogham.core.resource.resolver.ResourceResolver; | |
| 29 | import fr.sii.ogham.core.translator.content.ContentTranslator; | |
| 30 | import fr.sii.ogham.html.inliner.EveryImageInliner; | |
| 31 | import fr.sii.ogham.html.inliner.ImageInliner; | |
| 32 | import fr.sii.ogham.html.translator.InlineImageTranslator; | |
| 33 | ||
| 34 | /** | |
| 35 | * Configures how images declared in the HTML content are automatically | |
| 36 | * transformed to make it work with email. | |
| 37 | * | |
| 38 | * Images can be either: | |
| 39 | * <ul> | |
| 40 | * <li>Attached to the email</li> | |
| 41 | * <li>Encoded to a base64 string</li> | |
| 42 | * <li>Not inlined at all</li> | |
| 43 | * </ul> | |
| 44 | * | |
| 45 | * This builder is used to enable the inlining modes (and to configure them). | |
| 46 | * Several modes can be enabled. | |
| 47 | * | |
| 48 | * <p> | |
| 49 | * If {@link #attach()} is called, it enables image attachment. | |
| 50 | * | |
| 51 | * Image defined in a html must be referenced by a | |
| 52 | * <a href="https://tools.ietf.org/html/rfc4021#section-2.2.2">Content-ID (or | |
| 53 | * CID)</a> if the image is attached to the email. | |
| 54 | * | |
| 55 | * For example, if your template contains the following HTML code: | |
| 56 | * | |
| 57 | * <pre> | |
| 58 | * {@code | |
| 59 | * <img src="classpath:/foo.png" data-inline-image="attach" /> | |
| 60 | * } | |
| 61 | * </pre> | |
| 62 | * | |
| 63 | * Then the image will be loaded from the classpath and attached to the email. | |
| 64 | * The src attribute will be replaced by the Content-ID. | |
| 65 | * | |
| 66 | * | |
| 67 | * <p> | |
| 68 | * If {@link #base64()} is called, it enables inlining by converting image | |
| 69 | * content into base64 string and using the base64 string as image source. | |
| 70 | * | |
| 71 | * For example, if your template contains the following HTML code: | |
| 72 | * | |
| 73 | * <pre> | |
| 74 | * {@code | |
| 75 | * <img src="classpath:/foo.png" data-inline-image="base64" /> | |
| 76 | * } | |
| 77 | * </pre> | |
| 78 | * | |
| 79 | * Then the image will be loaded from the classpath and encoded into a base64 | |
| 80 | * string. This base64 string is used in the src attribute of the image. | |
| 81 | * | |
| 82 | * <p> | |
| 83 | * If you don't want to inline a particular image, you can set the | |
| 84 | * "data-inline-image" attribute to "skip": | |
| 85 | * | |
| 86 | * <pre> | |
| 87 | * {@code | |
| 88 | * <img src="classpath:/foo.png" data-inline-image="skip" /> | |
| 89 | * } | |
| 90 | * </pre> | |
| 91 | * | |
| 92 | * Then the image won't be inlined at all. | |
| 93 | * | |
| 94 | * <p> | |
| 95 | * If no inline mode is explicitly defined on the {@code <img>}: | |
| 96 | * | |
| 97 | * <pre> | |
| 98 | * {@code | |
| 99 | * <img src="classpath:/foo.png" /> | |
| 100 | * } | |
| 101 | * </pre> | |
| 102 | * | |
| 103 | * The behavior depends on what you have configured: | |
| 104 | * <ul> | |
| 105 | * <li>If {@link #attach()} is enabled (has been called), then image will be | |
| 106 | * loaded from the classpath and attached to the email. The src attribute will | |
| 107 | * be replaced by the Content-ID.</li> | |
| 108 | * <li>If {@link #attach()} is not enabled (never called) and {@link #base64()} | |
| 109 | * is enabled (has been called), then the image will be loaded from the | |
| 110 | * classpath and encoded into a base64 string. This base64 string is used in the | |
| 111 | * src attribute of the image.</li> | |
| 112 | * <li>If neither {@link #attach()} nor {@link #base64()} are enabled (never | |
| 113 | * called), then images won't be inlined at all</li> | |
| 114 | * </ul> | |
| 115 | * | |
| 116 | * | |
| 117 | * @author Aurélien Baudet | |
| 118 | * | |
| 119 | */ | |
| 120 | public class ImageInliningBuilder extends AbstractParent<ImageHandlingBuilder> implements ResourceResolutionBuilder<ImageInliningBuilder>, Builder<ContentTranslator> { | |
| 121 | private static final Logger LOG = LoggerFactory.getLogger(ImageInliningBuilder.class); | |
| 122 | ||
| 123 | private final BuildContext buildContext; | |
| 124 | private final ResourceResolutionBuilderHelper<ImageInliningBuilder> resourceResolutionBuilderHelper; | |
| 125 | private AttachImageBuilder attachBuilder; | |
| 126 | private Base64InliningBuilder base64Builder; | |
| 127 | private MimetypeDetectionBuilder<ImageInliningBuilder> mimetypeBuilder; | |
| 128 | ||
| 129 | /** | |
| 130 | * Initializes the builder with a parent builder. The parent builder is used | |
| 131 | * when calling {@link #and()} method. The {@link EnvironmentBuilder} is | |
| 132 | * used to evaluate properties when {@link #build()} method is called. | |
| 133 | * | |
| 134 | * @param parent | |
| 135 | * the parent builder | |
| 136 | * @param buildContext | |
| 137 | * for registering instances and property evaluation | |
| 138 | */ | |
| 139 | public ImageInliningBuilder(ImageHandlingBuilder parent, BuildContext buildContext) { | |
| 140 | super(parent); | |
| 141 | this.buildContext = buildContext; | |
| 142 | resourceResolutionBuilderHelper = new ResourceResolutionBuilderHelper<>(this, buildContext); | |
| 143 | } | |
| 144 | ||
| 145 | /** | |
| 146 | * Configures how attachment of images is handled. | |
| 147 | * | |
| 148 | * <p> | |
| 149 | * If this method is called, it enables image attachment. | |
| 150 | * | |
| 151 | * Image defined in a html must be referenced by a | |
| 152 | * <a href="https://tools.ietf.org/html/rfc4021#section-2.2.2">Content-ID | |
| 153 | * (or CID)</a> if the image is attached to the email. | |
| 154 | * | |
| 155 | * For example, if your template contains the following HTML code: | |
| 156 | * | |
| 157 | * <pre> | |
| 158 | * {@code | |
| 159 | * <img src="classpath:/foo.png" data-inline-image="attach" /> | |
| 160 | * } | |
| 161 | * </pre> | |
| 162 | * | |
| 163 | * Then the image will be loaded from the classpath and attached to the | |
| 164 | * email. The src attribute will be replaced by the Content-ID. | |
| 165 | * | |
| 166 | * | |
| 167 | * | |
| 168 | * <p> | |
| 169 | * In the same way, if your template contains the following code: | |
| 170 | * | |
| 171 | * <pre> | |
| 172 | * <code> | |
| 173 | * <style> | |
| 174 | * .some-class { | |
| 175 | * background: url('classpath:/foo.png'); | |
| 176 | * --inline-image: attach; | |
| 177 | * } | |
| 178 | * </style> | |
| 179 | * </code> | |
| 180 | * </pre> | |
| 181 | * | |
| 182 | * Or directly on {@code style} attribute: | |
| 183 | * | |
| 184 | * <pre> | |
| 185 | * {@code | |
| 186 | * <div style= | |
| 187 | "background: url('classpath:/foo.png'); --inline-image: attach;"></div> | |
| 188 | * } | |
| 189 | * </pre> | |
| 190 | * | |
| 191 | * Then the image will be loaded from the classpath and attached to the | |
| 192 | * email. The url will be replaced by the Content-ID. | |
| 193 | * | |
| 194 | * <p> | |
| 195 | * If no inline mode is defined, image attachment is used by default: | |
| 196 | * | |
| 197 | * <pre> | |
| 198 | * {@code | |
| 199 | * <img src="classpath:/foo.png" /> | |
| 200 | * } | |
| 201 | * </pre> | |
| 202 | * | |
| 203 | * Or: | |
| 204 | * | |
| 205 | * <pre> | |
| 206 | * <code> | |
| 207 | * <style> | |
| 208 | * .some-class { | |
| 209 | * background: url('classpath:/foo.png'); | |
| 210 | * } | |
| 211 | * </style> | |
| 212 | * </code> | |
| 213 | * </pre> | |
| 214 | * | |
| 215 | * Or: | |
| 216 | * | |
| 217 | * <pre> | |
| 218 | * {@code | |
| 219 | * <div style="background: url('classpath:/foo.png');"></div> | |
| 220 | * } | |
| 221 | * </pre> | |
| 222 | * | |
| 223 | * The examples above have the same result as the example that explicitly | |
| 224 | * defines the inline mode. | |
| 225 | * | |
| 226 | * | |
| 227 | * @return the builder to configure how images are automatically attached | |
| 228 | */ | |
| 229 | public AttachImageBuilder attach() { | |
| 230 |
8
1. attach : negated conditional → NO_COVERAGE 2. attach : negated conditional → KILLED 3. attach : negated conditional → KILLED 4. attach : negated conditional → KILLED 5. attach : negated conditional → KILLED 6. attach : negated conditional → KILLED 7. attach : negated conditional → KILLED 8. attach : negated conditional → KILLED |
if (attachBuilder == null) { |
| 231 | attachBuilder = new AttachImageBuilder(this, buildContext); | |
| 232 | } | |
| 233 |
8
1. attach : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::attach → NO_COVERAGE 2. attach : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::attach → KILLED 3. attach : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::attach → KILLED 4. attach : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::attach → KILLED 5. attach : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::attach → KILLED 6. attach : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::attach → KILLED 7. attach : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::attach → KILLED 8. attach : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::attach → KILLED |
return attachBuilder; |
| 234 | } | |
| 235 | ||
| 236 | /** | |
| 237 | * Configures how attachment of images is handled. | |
| 238 | * | |
| 239 | * <p> | |
| 240 | * If this method is called, it enables inlining by converting image content | |
| 241 | * into base64 string and using the base64 string as image source. | |
| 242 | * | |
| 243 | * For example, if your template contains the following HTML code: | |
| 244 | * | |
| 245 | * <pre> | |
| 246 | * {@code | |
| 247 | * <img src="classpath:/foo.png" data-inline-image="base64" /> | |
| 248 | * } | |
| 249 | * </pre> | |
| 250 | * | |
| 251 | * Then the image will be loaded from the classpath and encoded into a | |
| 252 | * base64 string. This base64 string is used in the src attribute of the | |
| 253 | * {@code <img>}. | |
| 254 | * | |
| 255 | * | |
| 256 | * <p> | |
| 257 | * In the same way, if your template contains the following code: | |
| 258 | * | |
| 259 | * <pre> | |
| 260 | * <code> | |
| 261 | * <style> | |
| 262 | * .some-class { | |
| 263 | * background: url('classpath:/foo.png'); | |
| 264 | * --inline-image: base64; | |
| 265 | * } | |
| 266 | * </style> | |
| 267 | * </code> | |
| 268 | * </pre> | |
| 269 | * | |
| 270 | * Or directly on {@code style} attribute: | |
| 271 | * | |
| 272 | * <pre> | |
| 273 | * {@code | |
| 274 | * <div style="background: url('classpath:/foo.png'); --inline-image: base64;"></div> | |
| 275 | * } | |
| 276 | * </pre> | |
| 277 | * | |
| 278 | * Then the image will be loaded from the classpath and encoded into a | |
| 279 | * base64 string. The url is updated with the base64 string. | |
| 280 | * | |
| 281 | * <p> | |
| 282 | * If no inline mode is defined <strong>and</strong> image attachment is not | |
| 283 | * enable ({@link #attach()} is not called), this mode is used by default: | |
| 284 | * | |
| 285 | * <pre> | |
| 286 | * {@code | |
| 287 | * <img src="classpath:/foo.png" /> | |
| 288 | * } | |
| 289 | * </pre> | |
| 290 | * | |
| 291 | * In this case, the example above as the same result as the example that | |
| 292 | * explicitly defines the inline mode. | |
| 293 | * | |
| 294 | * | |
| 295 | * @return the builder to configure how images are automatically converted | |
| 296 | * to base64 | |
| 297 | */ | |
| 298 | public Base64InliningBuilder base64() { | |
| 299 |
8
1. base64 : negated conditional → NO_COVERAGE 2. base64 : negated conditional → KILLED 3. base64 : negated conditional → KILLED 4. base64 : negated conditional → KILLED 5. base64 : negated conditional → KILLED 6. base64 : negated conditional → KILLED 7. base64 : negated conditional → KILLED 8. base64 : negated conditional → KILLED |
if (base64Builder == null) { |
| 300 | base64Builder = new Base64InliningBuilder(this, buildContext); | |
| 301 | } | |
| 302 |
8
1. base64 : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::base64 → NO_COVERAGE 2. base64 : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::base64 → KILLED 3. base64 : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::base64 → KILLED 4. base64 : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::base64 → KILLED 5. base64 : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::base64 → KILLED 6. base64 : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::base64 → KILLED 7. base64 : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::base64 → KILLED 8. base64 : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::base64 → KILLED |
return base64Builder; |
| 303 | } | |
| 304 | ||
| 305 | /** | |
| 306 | * Builder that configures mimetype detection. | |
| 307 | * | |
| 308 | * There exists several implementations to provide the mimetype: | |
| 309 | * <ul> | |
| 310 | * <li>Using Java {@link MimetypesFileTypeMap}</li> | |
| 311 | * <li>Using Java 7 {@link Files#probeContentType(java.nio.file.Path)}</li> | |
| 312 | * <li>Using <a href="http://tika.apache.org/">Apache Tika</a></li> | |
| 313 | * <li>Using | |
| 314 | * <a href="https://github.com/arimus/jmimemagic">JMimeMagic</a></li> | |
| 315 | * </ul> | |
| 316 | * | |
| 317 | * <p> | |
| 318 | * Both implementations provided by Java are based on file extensions. This | |
| 319 | * can't be used in most cases as we often handle {@link InputStream}s. | |
| 320 | * </p> | |
| 321 | * | |
| 322 | * <p> | |
| 323 | * In previous version of Ogham, JMimeMagic was used and was working quite | |
| 324 | * well. Unfortunately, the library is no more maintained. | |
| 325 | * </p> | |
| 326 | * | |
| 327 | * <p> | |
| 328 | * You can configure how Tika will detect mimetype: | |
| 329 | * | |
| 330 | * <pre> | |
| 331 | * .mimetype() | |
| 332 | * .tika() | |
| 333 | * ... | |
| 334 | * </pre> | |
| 335 | * | |
| 336 | * <p> | |
| 337 | * This builder allows to use several providers. It will chain them until | |
| 338 | * one can find a valid mimetype. If none is found, you can explicitly | |
| 339 | * provide the default one: | |
| 340 | * | |
| 341 | * <pre> | |
| 342 | * .mimetype() | |
| 343 | * .defaultMimetype("text/html") | |
| 344 | * </pre> | |
| 345 | * | |
| 346 | * <p> | |
| 347 | * If no mimetype detector was previously defined, it creates a new one. | |
| 348 | * Then each time you call {@link #mimetype()}, the same instance is used. | |
| 349 | * </p> | |
| 350 | * | |
| 351 | * @return the builder to configure mimetype detection | |
| 352 | */ | |
| 353 | public MimetypeDetectionBuilder<ImageInliningBuilder> mimetype() { | |
| 354 |
8
1. mimetype : negated conditional → NO_COVERAGE 2. mimetype : negated conditional → KILLED 3. mimetype : negated conditional → KILLED 4. mimetype : negated conditional → KILLED 5. mimetype : negated conditional → KILLED 6. mimetype : negated conditional → KILLED 7. mimetype : negated conditional → KILLED 8. mimetype : negated conditional → KILLED |
if (mimetypeBuilder == null) { |
| 355 | mimetypeBuilder = new SimpleMimetypeDetectionBuilder<>(this, buildContext); | |
| 356 | } | |
| 357 |
8
1. mimetype : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::mimetype → NO_COVERAGE 2. mimetype : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::mimetype → KILLED 3. mimetype : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::mimetype → KILLED 4. mimetype : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::mimetype → KILLED 5. mimetype : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::mimetype → KILLED 6. mimetype : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::mimetype → KILLED 7. mimetype : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::mimetype → KILLED 8. mimetype : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::mimetype → KILLED |
return mimetypeBuilder; |
| 358 | } | |
| 359 | ||
| 360 | /** | |
| 361 | * NOTE: this is mostly for advance usage (when creating a custom module). | |
| 362 | * | |
| 363 | * Inherits mimetype configuration from another builder. This is useful for | |
| 364 | * configuring independently different parts of Ogham but keeping a whole | |
| 365 | * coherence. | |
| 366 | * | |
| 367 | * The same instance is shared meaning that all changes done here will also | |
| 368 | * impact the other builder. | |
| 369 | * | |
| 370 | * <p> | |
| 371 | * If a previous builder was defined (by calling {@link #mimetype()} for | |
| 372 | * example), the new builder will override it. | |
| 373 | * | |
| 374 | * @param builder | |
| 375 | * the builder to inherit | |
| 376 | * @return this instance for fluent chaining | |
| 377 | */ | |
| 378 | public ImageInliningBuilder mimetype(MimetypeDetectionBuilder<?> builder) { | |
| 379 | mimetypeBuilder = new MimetypeDetectionBuilderDelegate<>(this, builder); | |
| 380 |
1
1. mimetype : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::mimetype → NO_COVERAGE |
return this; |
| 381 | } | |
| 382 | ||
| 383 | @Override | |
| 384 | public ClassPathResolutionBuilder<ImageInliningBuilder> classpath() { | |
| 385 |
8
1. classpath : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::classpath → NO_COVERAGE 2. classpath : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::classpath → KILLED 3. classpath : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::classpath → KILLED 4. classpath : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::classpath → KILLED 5. classpath : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::classpath → KILLED 6. classpath : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::classpath → KILLED 7. classpath : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::classpath → KILLED 8. classpath : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::classpath → KILLED |
return resourceResolutionBuilderHelper.classpath(); |
| 386 | } | |
| 387 | ||
| 388 | @Override | |
| 389 | public FileResolutionBuilder<ImageInliningBuilder> file() { | |
| 390 |
8
1. file : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::file → NO_COVERAGE 2. file : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::file → KILLED 3. file : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::file → KILLED 4. file : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::file → KILLED 5. file : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::file → KILLED 6. file : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::file → KILLED 7. file : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::file → KILLED 8. file : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::file → KILLED |
return resourceResolutionBuilderHelper.file(); |
| 391 | } | |
| 392 | ||
| 393 | @Override | |
| 394 | public StringResolutionBuilder<ImageInliningBuilder> string() { | |
| 395 |
8
1. string : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::string → NO_COVERAGE 2. string : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::string → KILLED 3. string : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::string → KILLED 4. string : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::string → KILLED 5. string : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::string → KILLED 6. string : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::string → KILLED 7. string : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::string → KILLED 8. string : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::string → KILLED |
return resourceResolutionBuilderHelper.string(); |
| 396 | } | |
| 397 | ||
| 398 | @Override | |
| 399 | public ImageInliningBuilder resolver(ResourceResolver resolver) { | |
| 400 |
1
1. resolver : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::resolver → NO_COVERAGE |
return resourceResolutionBuilderHelper.resolver(resolver); |
| 401 | } | |
| 402 | ||
| 403 | @Override | |
| 404 | public ContentTranslator build() { | |
| 405 | MimeTypeProvider mimetypeProvider = buildMimetypeProvider(); | |
| 406 |
3
1. build : negated conditional → SURVIVED 2. build : negated conditional → NO_COVERAGE 3. build : negated conditional → KILLED |
if (mimetypeProvider == null) { |
| 407 | LOG.info("Images won't be inlined because no mimetype detector is configured"); | |
| 408 | return null; | |
| 409 | } | |
| 410 | LOG.info("Images will be inlined"); | |
| 411 |
3
1. build : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::build → NO_COVERAGE 2. build : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::build → SURVIVED 3. build : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::build → KILLED |
return buildContext.register(new InlineImageTranslator(buildInliner(), buildResolver(), mimetypeProvider, buildRelativePathProvider())); |
| 412 | } | |
| 413 | ||
| 414 | private MimeTypeProvider buildMimetypeProvider() { | |
| 415 |
3
1. buildMimetypeProvider : negated conditional → SURVIVED 2. buildMimetypeProvider : negated conditional → NO_COVERAGE 3. buildMimetypeProvider : negated conditional → KILLED |
if (mimetypeBuilder == null) { |
| 416 | return null; | |
| 417 | } | |
| 418 |
3
1. buildMimetypeProvider : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildMimetypeProvider → SURVIVED 2. buildMimetypeProvider : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildMimetypeProvider → NO_COVERAGE 3. buildMimetypeProvider : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildMimetypeProvider → KILLED |
return mimetypeBuilder.build(); |
| 419 | } | |
| 420 | ||
| 421 | private ImageInliner buildInliner() { | |
| 422 | EveryImageInliner inliner = buildContext.register(new EveryImageInliner()); | |
| 423 |
3
1. buildInliner : negated conditional → NO_COVERAGE 2. buildInliner : negated conditional → SURVIVED 3. buildInliner : negated conditional → KILLED |
if (attachBuilder != null) { |
| 424 | inliner.addInliner(attachBuilder.build()); | |
| 425 | } | |
| 426 |
3
1. buildInliner : negated conditional → SURVIVED 2. buildInliner : negated conditional → NO_COVERAGE 3. buildInliner : negated conditional → KILLED |
if (base64Builder != null) { |
| 427 | inliner.addInliner(base64Builder.build()); | |
| 428 | } | |
| 429 |
3
1. buildInliner : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildInliner → SURVIVED 2. buildInliner : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildInliner → NO_COVERAGE 3. buildInliner : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildInliner → KILLED |
return inliner; |
| 430 | } | |
| 431 | ||
| 432 | private ResourceResolver buildResolver() { | |
| 433 | List<ResourceResolver> resolvers = resourceResolutionBuilderHelper.buildResolvers(); | |
| 434 |
3
1. buildResolver : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildResolver → NO_COVERAGE 2. buildResolver : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildResolver → SURVIVED 3. buildResolver : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildResolver → KILLED |
return buildContext.register(new FirstSupportingResourceResolver(resolvers)); |
| 435 | } | |
| 436 | ||
| 437 | private RelativePathResolver buildRelativePathProvider() { | |
| 438 |
3
1. buildRelativePathProvider : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildRelativePathProvider → SURVIVED 2. buildRelativePathProvider : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildRelativePathProvider → NO_COVERAGE 3. buildRelativePathProvider : replaced return value with null for fr/sii/ogham/email/builder/ImageInliningBuilder::buildRelativePathProvider → KILLED |
return buildContext.register(new LookupAwareRelativePathResolver(resourceResolutionBuilderHelper.getAllLookups())); |
| 439 | } | |
| 440 | } | |
Mutations | ||
| 230 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 233 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 299 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 302 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 354 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 357 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 380 |
1.1 |
|
| 385 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 390 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 395 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 400 |
1.1 |
|
| 406 |
1.1 2.2 3.3 |
|
| 411 |
1.1 2.2 3.3 |
|
| 415 |
1.1 2.2 3.3 |
|
| 418 |
1.1 2.2 3.3 |
|
| 423 |
1.1 2.2 3.3 |
|
| 426 |
1.1 2.2 3.3 |
|
| 429 |
1.1 2.2 3.3 |
|
| 434 |
1.1 2.2 3.3 |
|
| 438 |
1.1 2.2 3.3 |