aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch-protocol/src/main
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-07-27 16:25:31 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-07-28 14:54:10 +0200
commitb36bc464f98e0136d41e60774093aa946b207999 (patch)
treefabae7651b0705f3fd74144399e57350bc064565 /sonar-batch-protocol/src/main
parent7cb72d02dc84f620447d80b96cd518d8b7f54e9a (diff)
downloadsonarqube-b36bc464f98e0136d41e60774093aa946b207999.tar.gz
sonarqube-b36bc464f98e0136d41e60774093aa946b207999.zip
SONAR-6713 Load rules in global container
Diffstat (limited to 'sonar-batch-protocol/src/main')
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Rule.java74
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/RulesSearchResult.java45
2 files changed, 119 insertions, 0 deletions
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Rule.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Rule.java
new file mode 100644
index 00000000000..e1574f1c6be
--- /dev/null
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Rule.java
@@ -0,0 +1,74 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.batch.protocol.input;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+public class Rule {
+ private final String key;
+ private final String repo;
+ private final String internalKey;
+ private final String name;
+ private final String severity;
+ private final String lang;
+
+ public Rule(String ruleKey, String repositoryKey, String internalKey, String name, @Nullable String severity, @Nullable String language) {
+ this.key = ruleKey;
+ this.repo = repositoryKey;
+ this.internalKey = internalKey;
+ this.name = name;
+ this.severity = severity;
+ this.lang = language;
+ }
+
+ public String ruleKey() {
+ return key;
+ }
+
+ public String repositoryKey() {
+ return repo;
+ }
+
+ public String internalKey() {
+ return internalKey;
+ }
+
+ public String name() {
+ return name;
+ }
+
+ /**
+ * Is null on manual rules
+ */
+ @CheckForNull
+ public String severity() {
+ return severity;
+ }
+
+ /**
+ * Is null on manual rules
+ */
+ @CheckForNull
+ public String language() {
+ return lang;
+ }
+
+}
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/RulesSearchResult.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/RulesSearchResult.java
new file mode 100644
index 00000000000..91dccb179f7
--- /dev/null
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/RulesSearchResult.java
@@ -0,0 +1,45 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.batch.protocol.input;
+
+import java.util.List;
+
+import org.sonar.batch.protocol.GsonHelper;
+
+public class RulesSearchResult {
+ List<Rule> rules;
+
+ public List<Rule> getRules() {
+ return rules;
+ }
+
+ public void setRules(List<Rule> rules) {
+ this.rules = rules;
+ }
+
+ public String toJson() {
+ return GsonHelper.create().toJson(this);
+ }
+
+ public static RulesSearchResult fromJson(String json) {
+ return GsonHelper.create().fromJson(json, RulesSearchResult.class);
+ }
+
+}