01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
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: private final BodyPart bodyPart;
33:
34: public BodyPartDataSource(BodyPart bodyPart) {
35: this .bodyPart = bodyPart;
36: }
37:
38: public String getContentType() {
39: try {
40: return bodyPart.getContentType();
41: } catch (MessagingException e) {
42: SoapUI.logError(e);
43: return null;
44: }
45: }
46:
47: public InputStream getInputStream() throws IOException {
48: try {
49: return bodyPart.getInputStream();
50: } catch (MessagingException e) {
51: SoapUI.logError(e);
52: return null;
53: }
54: }
55:
56: public String getName() {
57: try {
58: return bodyPart.getHeader("Content-ID")[0];
59: } catch (MessagingException e) {
60: SoapUI.logError(e);
61: return null;
62: }
63: }
64:
65: public OutputStream getOutputStream() throws IOException {
66: return null;
67: }
68:
69: }
|