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