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.model.iface.Attachment;
16
17 import javax.activation.DataSource;
18 import java.io.IOException;
19 import java.io.InputStream;
20 import java.io.OutputStream;
21
22 /***
23 * Standard DataSource for existing attachments in soapUI
24 *
25 * @author ole.matzura
26 */
27
28 class AttachmentDataSource implements DataSource
29 {
30 private final Attachment attachment;
31
32 public AttachmentDataSource(Attachment attachment)
33 {
34 this.attachment = attachment;
35 }
36
37 public String getContentType()
38 {
39 return attachment.getContentType();
40 }
41
42 public InputStream getInputStream() throws IOException
43 {
44 try
45 {
46 return attachment.getInputStream();
47 }
48 catch( Exception e )
49 {
50 throw new IOException( e.toString() );
51 }
52 }
53
54 public String getName()
55 {
56 return attachment.getName();
57 }
58
59 public OutputStream getOutputStream() throws IOException
60 {
61 return null;
62 }
63 }