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