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.internet.MimeMultipart;
19 import java.io.*;
20
21 /***
22 * DataSource for multipart attachments
23 *
24 * @author ole.matzura
25 */
26
27 class MultipartAttachmentDataSource implements DataSource
28 {
29 private final MimeMultipart multipart;
30
31 public MultipartAttachmentDataSource(MimeMultipart multipart)
32 {
33 this.multipart = multipart;
34 }
35
36 public String getContentType()
37 {
38 return multipart.getContentType();
39 }
40
41 public InputStream getInputStream() throws IOException
42 {
43 try
44 {
45 ByteArrayOutputStream out = new ByteArrayOutputStream();
46 multipart.writeTo(out);
47 return new ByteArrayInputStream( out.toByteArray() );
48 }
49 catch (Exception e)
50 {
51 SoapUI.logError( e );
52 return null;
53 }
54 }
55
56 public String getName()
57 {
58 return multipart.toString();
59 }
60
61 public OutputStream getOutputStream() throws IOException
62 {
63 return null;
64 }}