View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 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.log4j.Logger;
16  import org.apache.xmlbeans.XmlObject;
17  
18  import com.eviware.soapui.impl.rest.RestService;
19  import com.eviware.soapui.impl.support.definition.DefinitionLoader;
20  import com.eviware.soapui.impl.support.definition.support.XmlSchemaBasedInterfaceDefinition;
21  import net.java.dev.wadl.x2009.x02.ApplicationDocument;
22  
23  public class WadlInterfaceDefinition extends XmlSchemaBasedInterfaceDefinition<RestService>
24  {
25  	private ApplicationDocument applicationDocument;
26  	private Logger log = Logger.getLogger( WadlInterfaceDefinition.class );
27  
28  	public WadlInterfaceDefinition( RestService iface )
29  	{
30  		super( iface );
31  	}
32  
33  	public WadlInterfaceDefinition load( DefinitionLoader loader ) throws Exception
34  	{
35  		XmlObject obj = loader.loadXmlObject( loader.getBaseURI(), null );
36  		applicationDocument = ( ApplicationDocument )obj.changeType( ApplicationDocument.type );
37  
38  		if( !loader.isAborted() )
39  		{
40  			super.loadSchemaTypes( loader );
41  		}
42  		else
43  			throw new Exception( "Loading of WADL from [" + loader.getBaseURI() + "] was aborted" );
44  
45  		return this;
46  	}
47  
48  	public String getTargetNamespace()
49  	{
50  		return null;
51  	}
52  
53  	public ApplicationDocument.Application getApplication()
54  	{
55  		return applicationDocument.getApplication();
56  	}
57  }