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.panels.request.components;
14  
15  import java.beans.PropertyChangeEvent;
16  import java.beans.PropertyChangeListener;
17  
18  import org.apache.xmlbeans.SchemaTypeSystem;
19  import org.apache.xmlbeans.XmlBeans;
20  
21  import com.eviware.soapui.SoapUI;
22  import com.eviware.soapui.impl.wsdl.WsdlInterface;
23  import com.eviware.soapui.impl.wsdl.WsdlRequest;
24  import com.eviware.soapui.impl.wsdl.panels.request.components.editor.support.AbstractXmlDocument;
25  import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext;
26  
27  /***
28   * XmlDocument for a WsdlRequest
29   * 
30   * @author ole.matzura
31   */
32  
33  public class RequestXmlDocument extends AbstractXmlDocument implements PropertyChangeListener
34  {
35  	private final WsdlRequest request;
36  	private boolean updating;
37  
38  	public RequestXmlDocument(WsdlRequest request)
39  	{
40  		this.request = request;
41  		request.addPropertyChangeListener( WsdlRequest.REQUEST_PROPERTY, this );
42  	}
43  
44  	public String getXml()
45  	{
46  		return request.getRequestContent();
47  	}
48  
49  	public void setXml(String xml)
50  	{
51  		request.setRequestContent( xml );
52  	}
53  
54  	public void propertyChange(PropertyChangeEvent evt)
55  	{
56  		if( !updating )
57  			fireXmlChanged( (String)evt.getOldValue(), (String)evt.getNewValue() );
58  	}
59  
60  	public SchemaTypeSystem getTypeSystem()
61  	{
62  		WsdlInterface iface = (WsdlInterface) request.getOperation().getInterface();
63  		WsdlContext wsdlContext = iface.getWsdlContext();
64  		try
65  		{
66  			return wsdlContext.getSchemaTypeSystem();
67  		}
68  		catch (Exception e1)
69  		{
70  			SoapUI.logError( e1 );
71  			return XmlBeans.getBuiltinTypeSystem();
72  		}
73  	}
74  	
75  	public void release()
76  	{
77  		request.removePropertyChangeListener( WsdlRequest.REQUEST_PROPERTY, this );
78  	}
79  }