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.wsdl.submit.filters;
14  
15  import org.apache.log4j.Logger;
16  
17  import com.eviware.soapui.impl.wsdl.WsdlRequest;
18  import com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpRequestTransport;
19  import com.eviware.soapui.model.iface.SubmitContext;
20  import com.eviware.soapui.model.propertyexpansion.PropertyExpander;
21  import com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils;
22  import com.eviware.soapui.model.propertyexpansion.resolvers.ResolverUtils;
23  import com.eviware.soapui.settings.CommonSettings;
24  
25  /***
26   * RequestFilter that expands properties in request content
27   * 
28   * @author Ole.Matzura
29   */
30  
31  public class PropertyExpansionRequestFilter extends AbstractRequestFilter
32  {
33  	public final static Logger log = Logger.getLogger( PropertyExpansionRequestFilter.class );
34  
35  	@Override
36  	public void filterWsdlRequest( SubmitContext context, WsdlRequest request )
37  	{
38  		String content = ( String )context.getProperty( BaseHttpRequestTransport.REQUEST_CONTENT );
39  		if( content == null )
40  		{
41  			log.warn( "Missing request content in context, skipping property expansion" );
42  		}
43  		else
44  		{
45  			content = PropertyExpander.expandProperties( context, content, request.getSettings().getBoolean(
46  					CommonSettings.ENTITIZE_PROPERTIES ) );
47  
48  			if( content != null )
49  			{
50  				context.setProperty( BaseHttpRequestTransport.REQUEST_CONTENT, content );
51  			}
52  		}
53  	}
54  
55  	/***
56  	 * @deprecated
57  	 */
58  
59  	public static String expandProperties( SubmitContext context, String content )
60  	{
61  		return PropertyExpander.expandProperties( context, content );
62  	}
63  
64  	/***
65  	 * @deprecated
66  	 */
67  
68  	public static String getGlobalProperty( String propertyName )
69  	{
70  		return PropertyExpansionUtils.getGlobalProperty( propertyName );
71  	}
72  
73  	/***
74  	 * @deprecated Use
75  	 *             {@link ResolverUtils#extractXPathPropertyValue(Object,String)}
76  	 *             instead
77  	 */
78  	public static String extractXPathPropertyValue( Object property, String xpath )
79  	{
80  		return ResolverUtils.extractXPathPropertyValue( property, xpath );
81  	}
82  }