1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package com.eviware.soapui.impl.wsdl.submit.transports.http.support.attachments;
26
27 import java.io.ByteArrayInputStream;
28 import java.io.IOException;
29 import java.io.InputStream;
30 import java.io.OutputStream;
31
32 import javax.activation.DataSource;
33
34 import com.eviware.soapui.impl.support.http.HttpRequestInterface;
35
36 /***
37 * DataSource for an existing WsdlRequest
38 *
39 * @author ole.matzura
40 */
41
42 public class RestRequestDataSource implements DataSource
43 {
44 private final HttpRequestInterface<?> restRequest;
45 private final String requestContent;
46
47 public RestRequestDataSource( HttpRequestInterface<?> restRequest, String requestContent )
48 {
49 this.restRequest = restRequest;
50 this.requestContent = requestContent;
51 }
52
53 public String getContentType()
54 {
55 return restRequest.getMediaType();
56 }
57
58 public InputStream getInputStream() throws IOException
59 {
60 byte[] bytes = requestContent.getBytes( "UTF-8" );
61 return new ByteArrayInputStream( bytes );
62 }
63
64 public String getName()
65 {
66 return restRequest.getName();
67 }
68
69 public OutputStream getOutputStream() throws IOException
70 {
71 return null;
72 }
73 }