01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * 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: /**
24: * MessageExchange for WSDL-based exchanges
25: *
26: * @author ole.matzura
27: */
28:
29: public abstract class WsdlMessageExchange implements MessageExchange {
30: private StringToStringMap properties;
31: private String[] messages;
32:
33: public void addProperty(String name, String value) {
34: if (properties == null)
35: properties = new StringToStringMap();
36:
37: properties.put(name, value);
38: }
39:
40: public StringToStringMap getProperties() {
41: return properties;
42: }
43:
44: public boolean hasResponse() {
45: String responseContent = getResponseContent();
46: return responseContent != null
47: && responseContent.trim().length() > 0;
48: }
49:
50: public abstract WsdlOperation getOperation();
51:
52: public Attachment[] getResponseAttachmentsForPart(String name) {
53: List<Attachment> result = new ArrayList<Attachment>();
54:
55: for (Attachment attachment : getResponseAttachments()) {
56: if (attachment.getPart().equals(name))
57: result.add(attachment);
58: }
59:
60: return result.toArray(new Attachment[result.size()]);
61: }
62:
63: public Attachment[] getRequestAttachmentsForPart(String name) {
64: List<Attachment> result = new ArrayList<Attachment>();
65:
66: for (Attachment attachment : getRequestAttachments()) {
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: String requestContent = getRequestContent();
76: return !(requestContent == null || (ignoreEmpty && requestContent
77: .trim().length() == 0));
78: }
79:
80: public String[] getMessages() {
81: return messages;
82: }
83:
84: public void setMessages(String[] messages) {
85: this.messages = messages;
86: }
87: }
|