View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  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  {
33  	private final BodyPart bodyPart;
34  
35  	public BodyPartDataSource(BodyPart bodyPart)
36  	{
37  		this.bodyPart = bodyPart;
38  	}
39  
40  	public String getContentType()
41  	{
42  		try
43  		{
44  			return bodyPart.getContentType();
45  		}
46  		catch (MessagingException e)
47  		{
48  			SoapUI.logError( e );
49  			return null;
50  		}
51  	}
52  
53  	public InputStream getInputStream() throws IOException
54  	{
55  		try
56  		{
57  			return bodyPart.getInputStream();
58  		}
59  		catch (MessagingException e)
60  		{
61  			SoapUI.logError( e );
62  			return null;
63  		}
64  	}
65  
66  	public String getName()
67  	{
68  		try
69  		{
70  			return bodyPart.getHeader( "Content-ID" )[0];
71  		}
72  		catch (MessagingException e)
73  		{
74  			SoapUI.logError( e );
75  			return null;
76  		}
77  	}
78  
79  	public OutputStream getOutputStream() throws IOException
80  	{
81  		return null;
82  	}
83  
84  }