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  public class BodyPartDataSource implements DataSource
24  {
25  	private final BodyPart bodyPart;
26  
27  	public BodyPartDataSource(BodyPart bodyPart)
28  	{
29  		this.bodyPart = bodyPart;
30  	}
31  
32  	public String getContentType()
33  	{
34  		try
35  		{
36  			return bodyPart.getContentType();
37  		}
38  		catch (MessagingException e)
39  		{
40  			e.printStackTrace();
41  			return null;
42  		}
43  	}
44  
45  	public InputStream getInputStream() throws IOException
46  	{
47  		try
48  		{
49  			return bodyPart.getInputStream();
50  		}
51  		catch (MessagingException e)
52  		{
53  			e.printStackTrace();
54  			return null;
55  		}
56  	}
57  
58  	public String getName()
59  	{
60  		try
61  		{
62  			return bodyPart.getHeader( "Content-ID" )[0];
63  		}
64  		catch (MessagingException e)
65  		{
66  			e.printStackTrace();
67  			return null;
68  		}
69  	}
70  
71  	public OutputStream getOutputStream() throws IOException
72  	{
73  		return null;
74  	}
75  
76  }