Cannot retrieve SQ 4.5.4 server properties with WS client api

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

Cannot retrieve SQ 4.5.4 server properties with WS client api

Michel Pawlak
Hi people,

I'm trying to retrieve server properties with SQ 4.5.4 WS client api but with no success. The properties I'd like to retrieve are : "sonar.technicalDebt.developmentCost" and "sonar.technicalDebt.ratingGrid".

I'm using the following Maven dependency:

        <dependency>
            <groupId>org.codehaus.sonar</groupId>
            <artifactId>sonar-ws-client</artifactId>
            <version>4.5.4</version>
        </dependency>

And have the following method (findProperty) in my code:

    public Property findProperty(final String propertyKey) {
        PropertyQuery query = PropertyQuery.createForKey(propertyKey);
        LOGGER.debug("Find Property Query: {}", query.getUrl());
        return this.sonarQubeInstance.find(query);
    }

The sonarQubeInstance is created as follows :

        sonarQubeInstance = Sonar.create(connectionInformation.getHost(), connectionInformation.getUsername(), connectionInformation.getPassword());


The findProperty method is called by this snippet:

        for (ServerProperty property : ServerProperty.values()) {
            Property result = this.connector.findProperty(property.getInternalName());
            String value = property.getDefaultValue();
            if (result != null) {
                LOGGER.debug("Loaded configuration for property {}: {}", property.getInternalName(), result.getValue());
                value = result.getValue();
            } else {
                LOGGER.warn("Configuration not found for property {}, using default value: {}", property.getInternalName(), value);
            }
            this.properties.put(property, value);
        }


The debug messages I get are the following :

11:58:08.041 [main] INFO  c.c.a.t.c.reportgenerator.Runner - Retrieval of global host properties : Started
11:58:08.043 [main] DEBUG c.c.a.t.c.r.d.retrieval.Connection - Find Property Query URL: /api/properties/sonar.technicalDebt.developmentCost?
11:58:08.097 [main] WARN  c.c.a.t.c.reportgenerator.Runner - Configuration not found for property sonar.technicalDebt.developmentCost, using default value: 30
11:58:08.097 [main] DEBUG c.c.a.t.c.r.d.retrieval.Connection - Find Property Query URL: /api/properties/sonar.technicalDebt.ratingGrid?
11:58:08.107 [main] WARN  c.c.a.t.c.reportgenerator.Runner - Configuration not found for property sonar.technicalDebt.ratingGrid, using default value: 0.1,0.2,0.5,1
11:58:08.107 [main] INFO  c.c.a.t.c.reportgenerator.Runner - Retrieval of global host properties : Done

It looks like the properties cannot be retrieved from the server... but when I directly type the URL in a browser (I log in with the same username/password used by my program) I get the following results :

For http://sqhost/sqinstance/api/properties/sonar.technicalDebt.ratingGrid? :

<properties>
<property>
<key>sonar.technicalDebt.ratingGrid</key>
<value>
<![CDATA[ 0.1,0.2,0.5,1 ]]>

</value>
</property>
</properties>

And for http://sqhost/sqinstance/api/properties/sonar.technicalDebt.developmentCost?

<properties>
<property>
<key>sonar.technicalDebt.developmentCost</key>
<value>
<![CDATA[ 30 ]]>

</value>
</property>
</properties>

So the properties are set and are available...

Am I doing something wrong ? How can I fix this ?

Thank you in advance,

Michel
Loading...