From 4b5bc19bb3046bf0cb5917412b5f0fb50efcb0cd Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Tue, 22 Mar 2016 18:08:41 +0100 Subject: [PATCH] SONAR-6717 Drop support of plugin extension issue action --- it/it-plugins/issue-action-plugin/pom.xml | 40 -------------- .../src/main/java/ActionDefinition.java | 52 ------------------- .../src/main/java/IssueActionPlugin.java | 33 ------------ .../org/sonar/l10n/issueaction.properties | 21 -------- it/it-plugins/pom.xml | 1 - .../src/test/java/it/Category2Suite.java | 1 - .../test/java/it/issue/IssueActionTest.java | 21 -------- .../org/sonar/server/issue/ActionService.java | 33 ------------ .../sonar/server/issue/ActionServiceTest.java | 16 ------ .../org/sonar/api/issue/action/Action.java | 2 + .../org/sonar/api/issue/action/Actions.java | 2 + 11 files changed, 4 insertions(+), 218 deletions(-) delete mode 100644 it/it-plugins/issue-action-plugin/pom.xml delete mode 100644 it/it-plugins/issue-action-plugin/src/main/java/ActionDefinition.java delete mode 100644 it/it-plugins/issue-action-plugin/src/main/java/IssueActionPlugin.java delete mode 100644 it/it-plugins/issue-action-plugin/src/main/resources/org/sonar/l10n/issueaction.properties diff --git a/it/it-plugins/issue-action-plugin/pom.xml b/it/it-plugins/issue-action-plugin/pom.xml deleted file mode 100644 index e5569299ff8..00000000000 --- a/it/it-plugins/issue-action-plugin/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - 4.0.0 - - - org.sonarsource.sonarqube - it-plugins - 5.5-SNAPSHOT - - - issue-action-plugin - sonar-plugin - Plugins :: Issue Action - 1.0-SNAPSHOT - - - - org.sonarsource.sonarqube - sonar-plugin-api - ${apiVersion} - provided - - - - - - - org.sonarsource.sonar-packaging-maven-plugin - sonar-packaging-maven-plugin - 1.15 - true - - IssueActionPlugin - issueaction - - - - - diff --git a/it/it-plugins/issue-action-plugin/src/main/java/ActionDefinition.java b/it/it-plugins/issue-action-plugin/src/main/java/ActionDefinition.java deleted file mode 100644 index 445eb7a1919..00000000000 --- a/it/it-plugins/issue-action-plugin/src/main/java/ActionDefinition.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program 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. - * - * This program 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. - */ -import org.sonar.api.ServerExtension; -import org.sonar.api.issue.Issue; -import org.sonar.api.issue.action.Actions; -import org.sonar.api.issue.action.Function; -import org.sonar.api.issue.condition.HasIssuePropertyCondition; -import org.sonar.api.issue.condition.HasResolution; -import org.sonar.api.issue.condition.NotCondition; - -public class ActionDefinition implements ServerExtension { - - public static final String FAKE_PROPERTY = "fake"; - - private final Actions actions; - - public ActionDefinition(Actions actions) { - this.actions = actions; - } - - public void start() { - actions.add("fake") - .setConditions( - new HasResolution(Issue.RESOLUTION_FIXED), - new NotCondition(new HasIssuePropertyCondition(FAKE_PROPERTY)) - ) - .setFunctions(new Function() { - @Override - public void execute(Context context) { - context.setAttribute(FAKE_PROPERTY, "fake action"); - context.addComment("New Comment from fake action"); - } - }); - } -} diff --git a/it/it-plugins/issue-action-plugin/src/main/java/IssueActionPlugin.java b/it/it-plugins/issue-action-plugin/src/main/java/IssueActionPlugin.java deleted file mode 100644 index 51f7e2bca53..00000000000 --- a/it/it-plugins/issue-action-plugin/src/main/java/IssueActionPlugin.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program 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. - * - * This program 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. - */ -import org.sonar.api.SonarPlugin; - -import java.util.Arrays; -import java.util.List; - -public class IssueActionPlugin extends SonarPlugin { - - public List getExtensions() { - return Arrays.asList( - ActionDefinition.class - ); - } - -} diff --git a/it/it-plugins/issue-action-plugin/src/main/resources/org/sonar/l10n/issueaction.properties b/it/it-plugins/issue-action-plugin/src/main/resources/org/sonar/l10n/issueaction.properties deleted file mode 100644 index f507ceed575..00000000000 --- a/it/it-plugins/issue-action-plugin/src/main/resources/org/sonar/l10n/issueaction.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# 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. -# - -issue.action.fake.formlink=Fake diff --git a/it/it-plugins/pom.xml b/it/it-plugins/pom.xml index dfaf77516f2..71023da0185 100644 --- a/it/it-plugins/pom.xml +++ b/it/it-plugins/pom.xml @@ -36,7 +36,6 @@ dashboard-plugin extension-lifecycle-plugin global-property-change-plugin - issue-action-plugin l10n-fr-pack license-plugin oauth2-auth-plugin diff --git a/it/it-tests/src/test/java/it/Category2Suite.java b/it/it-tests/src/test/java/it/Category2Suite.java index 7a2eee1527a..e6dd0cb3cdb 100644 --- a/it/it-tests/src/test/java/it/Category2Suite.java +++ b/it/it-tests/src/test/java/it/Category2Suite.java @@ -93,7 +93,6 @@ public class Category2Suite { .addPlugin(xooPlugin()) // issue - .addPlugin(pluginArtifact("issue-action-plugin")) .addPlugin(pluginArtifact("issue-filter-plugin")) // 1 second. Required for notification test. diff --git a/it/it-tests/src/test/java/it/issue/IssueActionTest.java b/it/it-tests/src/test/java/it/issue/IssueActionTest.java index 49322a7d1e9..65098ac1126 100644 --- a/it/it-tests/src/test/java/it/issue/IssueActionTest.java +++ b/it/it-tests/src/test/java/it/issue/IssueActionTest.java @@ -220,27 +220,6 @@ public class IssueActionTest extends AbstractIssueTest { assertThat(reloaded.creationDate()).isEqualTo(issue.creationDate()); } - /** - * SONAR-4315 - */ - @Test - public void apply_action_from_plugin() { - // The condition on the action defined by the plugin is that the status must be resolved - adminIssueClient().doTransition(issue.key(), "resolve"); - Assertions.assertThat(adminIssueClient().actions(issue.key())).contains("fake"); - - adminIssueClient().doAction(issue.key(), "fake"); - - // reload issue - Issue reloaded = searchIssue(issue.key(), true); - - assertThat(reloaded.comments()).hasSize(1); - assertThat(reloaded.comments().get(0).htmlText()).isEqualTo("New Comment from fake action"); - - // The action is no more available when already executed (because an issue attribute is used to check if the action is available or not) - Assertions.assertThat(adminIssueClient().actions(issue.key())).doesNotContain("fake"); - } - /** * SONAR-4315 */ diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ActionService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ActionService.java index df5c21c026c..0b2539893e3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ActionService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ActionService.java @@ -40,7 +40,6 @@ import org.sonar.server.user.UserSession; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; -import static com.google.common.collect.FluentIterable.from; import static com.google.common.collect.Iterables.find; import static com.google.common.collect.Lists.newArrayList; import static org.sonar.api.web.UserRole.ISSUE_ADMIN; @@ -97,20 +96,10 @@ public class ActionService { availableActions.add("set_severity"); } } - for (String action : loadPluginActions(issue)) { - availableActions.add(action); - } } return availableActions; } - private List loadPluginActions(final Issue issue) { - return from(actions.list()) - .filter(new SupportIssue(issue)) - .transform(ActionToKey.INSTANCE) - .toList(); - } - public Issue execute(String issueKey, String actionKey) { checkArgument(!Strings.isNullOrEmpty(actionKey), "Missing action"); @@ -177,28 +166,6 @@ public class ActionService { } } - private static class SupportIssue implements Predicate { - private final Issue issue; - - public SupportIssue(Issue issue) { - this.issue = issue; - } - - @Override - public boolean apply(@Nonnull Action action) { - return action.supports(issue); - } - } - - private enum ActionToKey implements com.google.common.base.Function { - INSTANCE; - - @Override - public String apply(@Nonnull Action action) { - return action.key(); - } - } - private static class MatchActionKey implements Predicate { private final String actionKey; diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java index b93a0aa0079..8857fd70985 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java @@ -152,22 +152,6 @@ public class ActionServiceTest { actionService.execute(ISSUE_KEY, PLUGIN_ACTION); } - @Test - public void return_plugin_actions() { - actions.add(PLUGIN_ACTION).setConditions(new AlwaysMatch()); - actions.add("tweet").setConditions(new NeverMatch()); - assertThat(actionService.listAvailableActions(issue.toDefaultIssue())).contains(PLUGIN_ACTION); - } - - @Test - public void return_plugin_actions_on_resolved_issue() { - actions.add(PLUGIN_ACTION).setConditions(new AlwaysMatch()); - actions.add("tweet").setConditions(new NeverMatch()); - issue = IssueTesting.newDto(newXooX1().setId(10), newFileDto(project), project).setKee(ISSUE_KEY).setResolution(RESOLUTION_FIXED); - - assertThat(actionService.listAvailableActions(issue.toDefaultIssue())).contains(PLUGIN_ACTION); - } - @Test public void return_provided_actions_without_set_severity_when_not_issue_admin() { assertThat(actionService.listAvailableActions(issue.toDefaultIssue())).containsOnly("comment", "assign", "set_tags", "set_type", "assign_to_me", "plan"); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Action.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Action.java index 443f633944f..9112f6cd637 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Action.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Action.java @@ -30,7 +30,9 @@ import static com.google.common.collect.Lists.newArrayList; /** * @since 3.6 + * @deprecated in 5.5. Webapp cannot be customized anymore to define actions on issues */ +@Deprecated public class Action { private final String key; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java index c7f2d51aed0..29dd04cd835 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java @@ -25,7 +25,9 @@ import org.sonar.api.server.ServerSide; /** * @since 3.6 + * @deprecated in 5.5. Webapp cannot be customized anymore to define actions on issues */ +@Deprecated @ServerSide public class Actions { -- 2.39.5