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.wadl.support;
14  
15  import org.apache.xmlbeans.XmlObject;
16  import org.apache.xmlbeans.XmlOptions;
17  
18  import com.eviware.soapui.impl.rest.RestService;
19  import com.eviware.soapui.impl.rest.WadlGenerator;
20  import com.eviware.soapui.impl.rest.panels.request.inspectors.schema.InferredSchemaManager;
21  import com.eviware.soapui.impl.support.definition.support.AbstractDefinitionLoader;
22  
23  public class GeneratedWadlDefinitionLoader extends AbstractDefinitionLoader
24  {
25  	private RestService restService;
26  
27  	public GeneratedWadlDefinitionLoader( RestService restService )
28  	{
29  		this.restService = restService;
30  	}
31  
32  	public XmlObject loadXmlObject( String wsdlUrl, XmlOptions options ) throws Exception
33  	{
34  		if( wsdlUrl.toLowerCase().endsWith( ".xsd" ) )
35  			return XmlObject.Factory.parse( InferredSchemaManager.getInferredSchema( restService ).getXsdForNamespace(
36  					InferredSchemaManager.namespaceForFilename( wsdlUrl ) ) );
37  		return new WadlGenerator( restService ).generateWadl();
38  	}
39  
40  	public String getBaseURI()
41  	{
42  		return restService.getName() + ".wadl";
43  	}
44  
45  	public void setNewBaseURI( String uri )
46  	{
47  		// not implemented
48  	}
49  
50  	public String getFirstNewURI()
51  	{
52  		return getBaseURI();
53  	}
54  }