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;
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.iface.Attachment;
21  import com.eviware.soapui.model.iface.MessageExchange;
22  import com.eviware.soapui.support.types.StringToStringMap;
23  
24  /***
25   * MessageExchange for WSDL-based exchanges
26   * 
27   * @author ole.matzura
28   */
29  
30  public abstract class WsdlMessageExchange implements MessageExchange
31  {
32  	private StringToStringMap properties;
33  	private String[] messages;
34  
35  	public void addProperty( String name, String value )
36  	{
37  		if( properties == null )
38  			properties = new StringToStringMap();
39  		
40  		properties.put( name, value );
41  	}
42  	
43  	public StringToStringMap getProperties()
44  	{
45  		return properties;
46  	}
47  	
48  	public boolean hasResponse()
49  	{
50  		String responseContent = getResponseContent();
51  		return responseContent != null && responseContent.trim().length() > 0;
52  	}
53  	
54  	public abstract WsdlOperation getOperation();
55  
56  	public Attachment[] getResponseAttachmentsForPart( String name )
57  	{
58  		List<Attachment> result = new ArrayList<Attachment>();
59  		
60  		for( Attachment attachment : getResponseAttachments() )
61  		{
62  			if( attachment.getPart().equals( name ))
63  				result.add( attachment );
64  		}
65  		
66  		return result.toArray( new Attachment[result.size()] );
67  	}
68  	
69  	public Attachment[] getRequestAttachmentsForPart( String name )
70  	{
71  		List<Attachment> result = new ArrayList<Attachment>();
72  		
73  		for( Attachment attachment : getRequestAttachments() )
74  		{
75  			if( attachment.getPart().equals( name ))
76  				result.add( attachment );
77  		}
78  		
79  		return result.toArray( new Attachment[result.size()] );
80  	}
81  
82  	public boolean hasRequest( boolean ignoreEmpty )
83  	{
84  		String requestContent = getRequestContent();
85  		return !(requestContent == null || (ignoreEmpty && requestContent.trim().length() == 0 ));
86  	}
87  
88  	public String[] getMessages()
89  	{
90  		return messages;
91  	}
92  
93  	public void setMessages( String[] messages )
94  	{
95  		this.messages = messages;
96  	}
97  
98  	public SoapVersion getSoapVersion()
99  	{
100 		return getOperation().getInterface().getSoapVersion();
101 	}
102 
103 	public boolean hasRawData()
104 	{
105 		return false;
106 	}
107 
108 	public byte[] getRawRequestData()
109 	{
110 		return null;
111 	}
112 	
113 	public byte[] getRawResponseData()
114 	{
115 		return null;
116 	}
117 }