diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-04-21 16:56:21 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-04-21 18:40:48 +0200 |
commit | e8bf534ec680e583b0e7683c92f1be31ab66a74e (patch) | |
tree | 69a2281fa2f3b036e945c1b27d41c9afd2043a75 /sonar-ws-client/src/main/java/org | |
parent | 5c66787f6e31f2931f28b78d3eb056503cdfe57a (diff) | |
download | sonarqube-e8bf534ec680e583b0e7683c92f1be31ab66a74e.tar.gz sonarqube-e8bf534ec680e583b0e7683c92f1be31ab66a74e.zip |
SONAR-2380 The "violations" web service API must not return
"false-positive" violation
Also modified the batch side ViolationQuery class that I created so
that they have the same API.
Diffstat (limited to 'sonar-ws-client/src/main/java/org')
3 files changed, 38 insertions, 1 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java index f993b14321f..e29c37396ba 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java @@ -33,6 +33,7 @@ public class Violation extends Model { private String resourceScope = null; private String resourceQualifier = null; private Date createdAt = null; + private boolean switchedOff; public String getMessage() { return message; @@ -152,6 +153,22 @@ public class Violation extends Model { * @since 2.5 */ public boolean isCreatedAfter(Date date) { - return createdAt!=null && date!=null && createdAt.after(date); + return createdAt != null && date != null && createdAt.after(date); } + + /** + * @since 2.8 + */ + public Violation setSwitchedOff(boolean switchedOff) { + this.switchedOff = switchedOff; + return this; + } + + /** + * @since 2.8 + */ + public boolean isSwitchedOff() { + return switchedOff; + } + } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java index 0fc6d244d57..06a75f94c9e 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java @@ -20,6 +20,7 @@ package org.sonar.wsclient.services; public class ViolationQuery extends Query<Violation> { + public static final String BASE_URL = "/api/violations"; private String resourceKeyOrId; @@ -30,6 +31,7 @@ public class ViolationQuery extends Query<Violation> { private String[] categories; private String[] severities; private Integer limit; + private boolean isSwitchedOff; public ViolationQuery(String resourceKeyOrId) { this.resourceKeyOrId = resourceKeyOrId; @@ -127,6 +129,21 @@ public class ViolationQuery extends Query<Violation> { return this; } + /** + * @since 2.8 + */ + public ViolationQuery setSwitchedOff(boolean ignore) { + this.isSwitchedOff = ignore; + return this; + } + + /** + * @since 2.8 + */ + public boolean isSwitchedOff() { + return isSwitchedOff; + } + @Override public String getUrl() { StringBuilder url = new StringBuilder(BASE_URL); @@ -141,6 +158,8 @@ public class ViolationQuery extends Query<Violation> { appendUrlParameter(url, "rules", ruleKeys); appendUrlParameter(url, "categories", categories); appendUrlParameter(url, "priorities", severities); + appendUrlParameter(url, "switched_off", isSwitchedOff); + return url.toString(); } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java index 0df77ae74fc..df62e5c0e16 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java @@ -33,6 +33,7 @@ public class ViolationUnmarshaller extends AbstractUnmarshaller<Violation> { violation.setLine(utils.getInteger(json, "line")); violation.setSeverity(utils.getString(json, "priority")); violation.setCreatedAt(utils.getDateTime(json, "createdAt")); + violation.setSwitchedOff(utils.getBoolean(json, "switchedOff")); Object rule = utils.getField(json, "rule"); if (rule != null) { |