View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 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;
14  
15  import java.util.ArrayList;
16  import java.util.List;
17  
18  import com.eviware.soapui.impl.wsdl.WsdlOperation;
19  import com.eviware.soapui.impl.wsdl.support.soap.SoapVersion;
20  import com.eviware.soapui.model.ModelItem;
21  import com.eviware.soapui.model.iface.Attachment;
22  
23  /***
24   * MessageExchange for WSDL-based exchanges
25   * 
26   * @author ole.matzura
27   */
28  
29  public abstract class AbstractWsdlMessageExchange<T extends ModelItem> extends AbstractMessageExchange<T> implements
30  		WsdlMessageExchange
31  {
32  	public AbstractWsdlMessageExchange( T modelItem )
33  	{
34  		super( modelItem );
35  	}
36  
37  	public boolean hasResponse()
38  	{
39  		String responseContent = getResponseContent();
40  		return responseContent != null && responseContent.trim().length() > 0;
41  	}
42  
43  	public abstract WsdlOperation getOperation();
44  
45  	public Attachment[] getResponseAttachmentsForPart( String name )
46  	{
47  		List<Attachment> result = new ArrayList<Attachment>();
48  
49  		if( getResponseAttachments() != null )
50  		{
51  		for( Attachment attachment : getResponseAttachments() )
52  		{
53  			if( attachment.getPart().equals( name ) )
54  				result.add( attachment );
55  		}
56  		}
57  
58  		return result.toArray( new Attachment[result.size()] );
59  	}
60  
61  	public Attachment[] getRequestAttachmentsForPart( String name )
62  	{
63  		List<Attachment> result = new ArrayList<Attachment>();
64  
65  		for( Attachment attachment : getRequestAttachments() )
66  		{
67  			if( attachment.getPart().equals( name ) )
68  				result.add( attachment );
69  		}
70  
71  		return result.toArray( new Attachment[result.size()] );
72  	}
73  
74  	public boolean hasRequest( boolean ignoreEmpty )
75  	{
76  		String requestContent = getRequestContent();
77  		return !( requestContent == null || ( ignoreEmpty && requestContent.trim().length() == 0 ) );
78  	}
79  
80  	/*
81  	 * (non-Javadoc)
82  	 * 
83  	 * @see
84  	 * com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange#getSoapVersion()
85  	 */
86  	public SoapVersion getSoapVersion()
87  	{
88  		return getOperation().getInterface().getSoapVersion();
89  	}
90  
91  	public boolean hasRawData()
92  	{
93  		return false;
94  	}
95  
96  	public byte[] getRawRequestData()
97  	{
98  		return null;
99  	}
100 
101 	public byte[] getRawResponseData()
102 	{
103 		return null;
104 	}
105 }