throw new IllegalStateException( "Failed to serialize settings to memory", e );
}
String serializedSettings = writer.toString();
RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
interpolator.addValueSource( new PropertiesBasedValueSource( request.getUserProperties() ) );
interpolator.addValueSource( new PropertiesBasedValueSource( request.getSystemProperties() ) );
try
{
interpolator.addValueSource( new EnvarBasedValueSource() );
}
catch ( IOException e )
{
problems.add( SettingsProblem.Severity.WARNING, "Failed to use environment variables for interpolation: "
+ e.getMessage(), -1, -1, e );
}
interpolator.addPostProcessor( new InterpolationPostProcessor()
{
public Object execute( String expression, Object value )
{
if ( value != null )
{
// we're going to parse this back in as XML so we need to escape XML markup
value = value.toString().replace( "&", "&" ).replace( "<", "<" ).replace( ">", ">" );
return value;
}
return null;
}
} );
try
{
serializedSettings = interpolator.interpolate( serializedSettings, "settings" );
}
catch ( InterpolationException e )
{
problems.add( SettingsProblem.Severity.ERROR, "Failed to interpolate settings: " + e.getMessage(), -1, -1,
e );