diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-04-25 20:42:57 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-04-25 20:43:08 +0200 |
commit | 097437f96c9d57375e7537da53a5a95bc096655a (patch) | |
tree | 2e7b8a7cdbaddb43b9a7c29f2bef9ed0e10c5638 /sonar-server/src/main | |
parent | f3209b446356db78f90a102890d453f0c487f047 (diff) | |
download | sonarqube-097437f96c9d57375e7537da53a5a95bc096655a.tar.gz sonarqube-097437f96c9d57375e7537da53a5a95bc096655a.zip |
Complete WebService with new param metadata
Diffstat (limited to 'sonar-server/src/main')
5 files changed, 227 insertions, 0 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/RuleService.java b/sonar-server/src/main/java/org/sonar/server/rule2/RuleService.java new file mode 100644 index 00000000000..f00af95d68e --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/rule2/RuleService.java @@ -0,0 +1,35 @@ +/* + * 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.server.rule2; + +import org.sonar.api.rule.RuleKey; + +import javax.annotation.CheckForNull; + +/** + * @since 4.4 + */ +public class RuleService { + + @CheckForNull + public Rule getByKey(RuleKey key) { + return null; + } +} diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/ws/RulesWebService.java b/sonar-server/src/main/java/org/sonar/server/rule2/ws/RulesWebService.java new file mode 100644 index 00000000000..7b54490d79e --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/rule2/ws/RulesWebService.java @@ -0,0 +1,46 @@ +/* + * 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.server.rule2.ws; + +import org.sonar.api.server.ws.WebService; + +public class RulesWebService implements WebService { + + private final SearchAction search; + private final ShowAction show; + + public RulesWebService(SearchAction search, ShowAction show) { + this.search = search; + this.show = show; + } + + @Override + public void define(Context context) { + NewController controller = context + .createController("api/rules2") + .setDescription("Coding rules") + .setSince("4.4"); + + search.define(controller); + show.define(controller); + + controller.done(); + } +} diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/ws/SearchAction.java b/sonar-server/src/main/java/org/sonar/server/rule2/ws/SearchAction.java new file mode 100644 index 00000000000..21f659a63f6 --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/rule2/ws/SearchAction.java @@ -0,0 +1,66 @@ +/* + * 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.server.rule2.ws; + +import org.sonar.api.server.ws.Request; +import org.sonar.api.server.ws.RequestHandler; +import org.sonar.api.server.ws.Response; +import org.sonar.api.server.ws.WebService; +import org.sonar.server.rule2.RuleService; + +/** + * @since 4.4 + */ +public class SearchAction implements RequestHandler { + + private final RuleService service; + + public SearchAction(RuleService service) { + this.service = service; + } + + void define(WebService.NewController controller) { + WebService.NewAction action = controller + .createAction("search") + .setDescription("Returns a collection of relevant rules matching a specified query") + .setSince("4.4") + .setHandler(this); + + action + .createParam("q") + .setDescription("UTF-8 search query") + .setExampleValue("null pointer"); + + action + .createParam("qProfile") + .setDescription("Key of Quality profile") + .setExampleValue("java:Sonar way"); + + action + .createParam("activation") + .setDescription("Only if 'qProfile' is set. Possible values are: true | false | all") + .setExampleValue("java:Sonar way"); + } + + @Override + public void handle(Request request, Response response) { + + } +} diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/ws/ShowAction.java b/sonar-server/src/main/java/org/sonar/server/rule2/ws/ShowAction.java new file mode 100644 index 00000000000..b844aad181f --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/rule2/ws/ShowAction.java @@ -0,0 +1,57 @@ +/* + * 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.server.rule2.ws; + +import org.sonar.api.server.ws.Request; +import org.sonar.api.server.ws.RequestHandler; +import org.sonar.api.server.ws.Response; +import org.sonar.api.server.ws.WebService; +import org.sonar.server.rule2.RuleService; + +/** + * @since 4.4 + */ +public class ShowAction implements RequestHandler { + + private final RuleService service; + + public ShowAction(RuleService service) { + this.service = service; + } + + void define(WebService.NewController controller) { + WebService.NewAction action = controller + .createAction("show") + .setDescription("Returns detailed information about a rule") + .setSince("4.4") + .setHandler(this); + + action + .createParam("key") + .setDescription("Rule key") + .setRequired(true) + .setExampleValue("javascript:EmptyBlock"); + } + + @Override + public void handle(Request request, Response response) { + + } +} diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/ws/package-info.java b/sonar-server/src/main/java/org/sonar/server/rule2/ws/package-info.java new file mode 100644 index 00000000000..8fcf3f3f2f5 --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/rule2/ws/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ +@ParametersAreNonnullByDefault +package org.sonar.server.rule2.ws; + +import javax.annotation.ParametersAreNonnullByDefault; |