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 public class BodyPartDataSource implements DataSource
24 {
25 private final BodyPart bodyPart;
26
27 public BodyPartDataSource(BodyPart bodyPart)
28 {
29 this.bodyPart = bodyPart;
30 }
31
32 public String getContentType()
33 {
34 try
35 {
36 return bodyPart.getContentType();
37 }
38 catch (MessagingException e)
39 {
40 e.printStackTrace();
41 return null;
42 }
43 }
44
45 public InputStream getInputStream() throws IOException
46 {
47 try
48 {
49 return bodyPart.getInputStream();
50 }
51 catch (MessagingException e)
52 {
53 e.printStackTrace();
54 return null;
55 }
56 }
57
58 public String getName()
59 {
60 try
61 {
62 return bodyPart.getHeader( "Content-ID" )[0];
63 }
64 catch (MessagingException e)
65 {
66 e.printStackTrace();
67 return null;
68 }
69 }
70
71 public OutputStream getOutputStream() throws IOException
72 {
73 return null;
74 }
75
76 }