View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 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 WsdlMessageExchange
30  {
31  	public AbstractWsdlMessageExchange(T modelItem)
32  	{
33  		super(modelItem);
34  	}
35  
36  	public boolean hasResponse()
37  	{
38  		String responseContent = getResponseContent();
39  		return responseContent != null && responseContent.trim().length() > 0;
40  	}
41  	
42  	public abstract WsdlOperation getOperation();
43  
44  	public Attachment[] getResponseAttachmentsForPart( String name )
45  	{
46  		List<Attachment> result = new ArrayList<Attachment>();
47  		
48  		for( Attachment attachment : getResponseAttachments() )
49  		{
50  			if( attachment.getPart().equals( name ))
51  				result.add( attachment );
52  		}
53  		
54  		return result.toArray( new Attachment[result.size()] );
55  	}
56  	
57  	public Attachment[] getRequestAttachmentsForPart( String name )
58  	{
59  		List<Attachment> result = new ArrayList<Attachment>();
60  		
61  		for( Attachment attachment : getRequestAttachments() )
62  		{
63  			if( attachment.getPart().equals( name ))
64  				result.add( attachment );
65  		}
66  		
67  		return result.toArray( new Attachment[result.size()] );
68  	}
69  
70  	public boolean hasRequest( boolean ignoreEmpty )
71  	{
72  		String requestContent = getRequestContent();
73  		return !(requestContent == null || (ignoreEmpty && requestContent.trim().length() == 0 ));
74  	}
75  
76  	/* (non-Javadoc)
77  	 * @see com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange#getSoapVersion()
78  	 */
79  	public SoapVersion getSoapVersion()
80  	{
81  		return getOperation().getInterface().getSoapVersion();
82  	}
83  
84  	public boolean hasRawData()
85  	{
86  		return false;
87  	}
88  
89  	public byte[] getRawRequestData()
90  	{
91  		return null;
92  	}
93  	
94  	public byte[] getRawResponseData()
95  	{
96  		return null;
97  	}
98  }