1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.rest.actions.service;
14
15 import java.io.File;
16
17 import com.eviware.soapui.impl.rest.RestService;
18 import com.eviware.soapui.impl.support.definition.export.WadlDefinitionExporter;
19 import com.eviware.soapui.support.UISupport;
20 import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
21
22 /***
23 * Exports the definition (wsdls and xsds) of a WsdlInterface to the file system
24 *
25 * @author Ole.Matzura
26 */
27
28 @SuppressWarnings( "unchecked" )
29 public class ExportWadlAction extends AbstractSoapUIAction<RestService>
30 {
31 public static final String SOAPUI_ACTION_ID = "ExportWadlAction";
32
33 public ExportWadlAction()
34 {
35 super( "Export WADL", "Exports the entire WADL and included/imported files to a local directory" );
36 }
37
38 public void perform( RestService iface, Object param )
39 {
40 try
41 {
42 String path = exportDefinition( null, iface );
43 if( path != null )
44 {
45 UISupport.showInfoMessage( "WADL exported succesfully to [" + path + "]", "Export WADL" );
46 }
47 }
48 catch( Exception e1 )
49 {
50 UISupport.showErrorMessage( e1 );
51 }
52 }
53
54 public String exportDefinition( String location, RestService iface ) throws Exception
55 {
56 File folderName = location == null ? UISupport.getFileDialogs().openDirectory( this, "Select output directory",
57 null ) : new File( location );
58
59 if( folderName == null )
60 return null;
61
62 WadlDefinitionExporter exporter = new WadlDefinitionExporter( iface );
63 return exporter.export( folderName.getAbsolutePath() );
64 }
65 }