[sonar-dev] How to get project scoped property value from a ruby widget class

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[sonar-dev] How to get project scoped property value from a ruby widget class

Carlos Fillol
Hello to everybody,

I'm trying to implement a widget java class that can be disabled for a project using a project scoped property.

I have tried with the code bellow but I have realised that "myplugin.enabled" property only has a value when is defined as a global scoped property. When it is defined as a project scoped property is always empty. And when defined as global and project, conf.getString("myplugin.enabled") always returns the global value.

 * An example of a widget that can be disabled
public class DisableableRubyWidget extends AbstractRubyTemplate 
    implements RubyRailsWidget{
  private Configuration conf;
   * Instances of this class needs a reference to the configuration 
   * object, so they will be able to retrieve info from properties.
  public DisableableRubyWidget(Configuration conf) {
    this.conf = conf;
   * If plugin is enabled, gets the template, else shows nothing.
  public final String getTemplate() {
    if ("true".equals(conf.getString("myplugin.enabled"))) {
      return "<b>The plugin is enabled! :)</b>";
    } else {
      return "";

I know that it is possible to get global and project properties from widget ruby code, but we were thinking about implementing a generic java widget class with enabling/disabling capabilities.

So, is it possible to get project scoped property value from a ruby widget class?

Thanks in advance,
Carlos Fillol Sendra (Linkedin)