View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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.model.ModelItem;
19  import com.eviware.soapui.model.iface.Attachment;
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
28  		RestMessageExchange
29  {
30  	public AbstractRestMessageExchange( T modelItem )
31  	{
32  		super( modelItem );
33  	}
34  
35  	public boolean hasResponse()
36  	{
37  		String responseContent = getResponseContent();
38  		return responseContent != null && responseContent.trim().length() > 0;
39  	}
40  
41  	public Attachment[] getResponseAttachmentsForPart( String name )
42  	{
43  		List<Attachment> result = new ArrayList<Attachment>();
44  
45  		for( Attachment attachment : getResponseAttachments() )
46  		{
47  			if( attachment.getPart().equals( name ) )
48  				result.add( attachment );
49  		}
50  
51  		return result.toArray( new Attachment[result.size()] );
52  	}
53  
54  	public Attachment[] getRequestAttachmentsForPart( String name )
55  	{
56  		List<Attachment> result = new ArrayList<Attachment>();
57  
58  		for( Attachment attachment : getRequestAttachments() )
59  		{
60  			if( attachment.getPart().equals( name ) )
61  				result.add( attachment );
62  		}
63  
64  		return result.toArray( new Attachment[result.size()] );
65  	}
66  
67  	public boolean hasRequest( boolean ignoreEmpty )
68  	{
69  		String requestContent = getRequestContent();
70  		return !( requestContent == null || ( ignoreEmpty && requestContent.trim().length() == 0 ) );
71  	}
72  
73  	public boolean hasRawData()
74  	{
75  		return false;
76  	}
77  
78  	public byte[] getRawRequestData()
79  	{
80  		return null;
81  	}
82  
83  	public byte[] getRawResponseData()
84  	{
85  		return null;
86  	}
87  }