View Javadoc

1   /*
2    *  soapUI, copyright (C) 2006 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of the GNU Lesser General Public License as published by the Free Software Foundation; 
6    *  either version 2.1 of the License, or (at your option) any later version.
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.model.iface.Attachment;
20  import com.eviware.soapui.model.iface.MessageExchange;
21  import com.eviware.soapui.support.types.StringToStringMap;
22  
23  public abstract class WsdlMessageExchange implements MessageExchange
24  {
25  	private StringToStringMap properties;
26  
27  	public void addProperty( String name, String value )
28  	{
29  		if( properties == null )
30  			properties = new StringToStringMap();
31  		
32  		properties.put( name, value );
33  	}
34  	
35  	public StringToStringMap getProperties()
36  	{
37  		return properties;
38  	}
39  	
40  	public boolean hasResponse()
41  	{
42  		String responseContent = getResponseContent();
43  		return responseContent != null && responseContent.trim().length() > 0;
44  	}
45  	
46  	public abstract WsdlOperation getOperation();
47  
48  	public Attachment[] getResponseAttachmentsForPart( String name )
49  	{
50  		List<Attachment> result = new ArrayList<Attachment>();
51  		
52  		for( Attachment attachment : getResponseAttachments() )
53  		{
54  			if( attachment.getPart().equals( name ))
55  				result.add( attachment );
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  }