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.actions.project;
14  
15  import com.eviware.soapui.impl.WsdlInterfaceFactory;
16  import com.eviware.soapui.impl.wsdl.WsdlProject;
17  import com.eviware.soapui.model.iface.Interface;
18  import com.eviware.soapui.support.UISupport;
19  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
20  
21  /***
22   * Adds a WsdlInterface to a WsdlProject from a URL
23   * 
24   * @author Ole.Matzura
25   */
26  
27  public class AddInterfaceActionFromURL extends AbstractSoapUIAction<WsdlProject>
28  {
29  	public static final String SOAPUI_ACTION_ID = "AddInterfaceActionFromURL";
30  
31  	public AddInterfaceActionFromURL()
32  	{
33  		super( "Add WSDL from URL", "Adds all interfaces in a specified WSDL URL to the current project" );
34  	}
35  
36  	public void perform( WsdlProject project, Object param )
37  	{
38  		String url = UISupport.prompt( "Enter WSDL URL", "Add WSDL from URL", "" );
39  		if( url == null )
40  			return;
41  
42  		try
43  		{
44  			Boolean createRequests = UISupport.confirmOrCancel( "Create default requests for all operations",
45  					"Import WSDL" );
46  			if( createRequests == null )
47  				return;
48  
49  			Interface[] ifaces = WsdlInterfaceFactory.importWsdl( project, url, createRequests );
50  			if( ifaces != null && ifaces.length > 0 )
51  				UISupport.select( ifaces[0] );
52  		}
53  		catch( Exception ex )
54  		{
55  			UISupport.showErrorMessage( ex.getMessage() + ":" + ex.getCause() );
56  		}
57  	}
58  }