1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.mail.internal.factory

File AbstractMimeBodyPartFactory.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
4
1
1
54
17
3
0.75
4
1
3

Classes

Class Line # Actions
AbstractMimeBodyPartFactory 36 4 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 15 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.mail.internal.factory;
21   
22    import java.util.Map;
23   
24    import javax.mail.MessagingException;
25    import javax.mail.internet.MimeBodyPart;
26   
27    import org.xwiki.mail.MimeBodyPartFactory;
28   
29    /**
30    * Helper that knows how to handle mail headers by extracting them from the passed parameters.
31    *
32    * @param <T> the type of content to be added to a Multi Part message
33    * @version $Id: a17f749d2c930b5a3c891d5a744bc98251610f1d $
34    * @since 6.1M2
35    */
 
36    public abstract class AbstractMimeBodyPartFactory<T> implements MimeBodyPartFactory<T>
37    {
38    /**
39    * Add the mail headers passed as parameters into the Mime Body part also passed as parameter.
40    *
41    * @param part the body part to which we're adding the headers
42    * @param parameters the parameters from which to extract the headers
43    * @throws MessagingException in case an error happens when setting a header
44    */
 
45  54 toggle protected void addHeaders(MimeBodyPart part, Map<String, Object> parameters) throws MessagingException
46    {
47  54 Map<String, String> headers = (Map<String, String>) parameters.<String, String>get("headers");
48  54 if (headers != null && headers instanceof Map) {
49  5 for (Map.Entry<String, String> header : headers.entrySet()) {
50  5 part.setHeader(header.getKey(), header.getValue());
51    }
52    }
53    }
54    }