1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.submit.transports.http.support.attachments;
14
15 import com.eviware.soapui.SoapUI;
16
17 import javax.activation.DataSource;
18 import javax.mail.BodyPart;
19 import javax.mail.MessagingException;
20 import java.io.IOException;
21 import java.io.InputStream;
22 import java.io.OutputStream;
23
24 /***
25 * DataSource for a BodyPart
26 *
27 * @author ole.matzura
28 */
29
30 public class BodyPartDataSource implements DataSource
31 {
32 private final BodyPart bodyPart;
33
34 public BodyPartDataSource(BodyPart bodyPart)
35 {
36 this.bodyPart = bodyPart;
37 }
38
39 public String getContentType()
40 {
41 try
42 {
43 return bodyPart.getContentType();
44 }
45 catch (MessagingException e)
46 {
47 SoapUI.logError( e );
48 return null;
49 }
50 }
51
52 public InputStream getInputStream() throws IOException
53 {
54 try
55 {
56 return bodyPart.getInputStream();
57 }
58 catch (MessagingException e)
59 {
60 SoapUI.logError( e );
61 return null;
62 }
63 }
64
65 public String getName()
66 {
67 try
68 {
69 return bodyPart.getHeader( "Content-ID" )[0];
70 }
71 catch (MessagingException e)
72 {
73 SoapUI.logError( e );
74 return null;
75 }
76 }
77
78 public OutputStream getOutputStream() throws IOException
79 {
80 return null;
81 }
82
83 }