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 com.eviware.soapui.model.ModelItem;
16  import com.eviware.soapui.model.iface.Attachment;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  /***
22   * MessageExchange for WSDL-based exchanges
23   * 
24   * @author ole.matzura
25   */
26  
27  public abstract class AbstractRestMessageExchange<T extends ModelItem> extends AbstractMessageExchange<T> implements RestMessageExchange 
28  {
29  	public AbstractRestMessageExchange(T modelItem)
30  	{
31  		super(modelItem);
32  	}
33  
34  	public boolean hasResponse()
35  	{
36  		String responseContent = getResponseContent();
37  		return responseContent != null && responseContent.trim().length() > 0;
38  	}
39  	
40  	public Attachment[] getResponseAttachmentsForPart( String name )
41  	{
42  		List<Attachment> result = new ArrayList<Attachment>();
43  		
44  		for( Attachment attachment : getResponseAttachments() )
45  		{
46  			if( attachment.getPart().equals( name ))
47  				result.add( attachment );
48  		}
49  		
50  		return result.toArray( new Attachment[result.size()] );
51  	}
52  	
53  	public Attachment[] getRequestAttachmentsForPart( String name )
54  	{
55  		List<Attachment> result = new ArrayList<Attachment>();
56  		
57  		for( Attachment attachment : getRequestAttachments() )
58  		{
59  			if( attachment.getPart().equals( name ))
60  				result.add( attachment );
61  		}
62  		
63  		return result.toArray( new Attachment[result.size()] );
64  	}
65  
66  	public boolean hasRequest( boolean ignoreEmpty )
67  	{
68  		String requestContent = getRequestContent();
69  		return !(requestContent == null || (ignoreEmpty && requestContent.trim().length() == 0 ));
70  	}
71  
72  	public boolean hasRawData()
73  	{
74  		return false;
75  	}
76  
77  	public byte[] getRawRequestData()
78  	{
79  		return null;
80  	}
81  	
82  	public byte[] getRawResponseData()
83  	{
84  		return null;
85  	}
86  }