View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 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  		if( getResponseAttachments() != null )
46  		{
47  		for( Attachment attachment : getResponseAttachments() )
48  		{
49  			if( attachment.getPart().equals( name ) )
50  				result.add( attachment );
51  		}
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  	public boolean hasRawData()
77  	{
78  		return false;
79  	}
80  
81  	public byte[] getRawRequestData()
82  	{
83  		return null;
84  	}
85  
86  	public byte[] getRawResponseData()
87  	{
88  		return null;
89  	}
90  }