summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-03-22 18:08:41 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-03-23 11:30:23 +0100
commit4b5bc19bb3046bf0cb5917412b5f0fb50efcb0cd (patch)
tree8a1ccf6726db6399a83bb044d600d63e1d6ac8bd
parent03f9acc15f3e96dc98a99f56c7d04ded183fb526 (diff)
downloadsonarqube-4b5bc19bb3046bf0cb5917412b5f0fb50efcb0cd.tar.gz
sonarqube-4b5bc19bb3046bf0cb5917412b5f0fb50efcb0cd.zip
SONAR-6717 Drop support of plugin extension issue action
-rw-r--r--it/it-plugins/issue-action-plugin/pom.xml40
-rw-r--r--it/it-plugins/issue-action-plugin/src/main/java/ActionDefinition.java52
-rw-r--r--it/it-plugins/issue-action-plugin/src/main/java/IssueActionPlugin.java33
-rw-r--r--it/it-plugins/issue-action-plugin/src/main/resources/org/sonar/l10n/issueaction.properties21
-rw-r--r--it/it-plugins/pom.xml1
-rw-r--r--it/it-tests/src/test/java/it/Category2Suite.java1
-rw-r--r--it/it-tests/src/test/java/it/issue/IssueActionTest.java21
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ActionService.java33
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java16
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Action.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java2
11 files changed, 4 insertions, 218 deletions
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 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.sonarsource.sonarqube</groupId>
- <artifactId>it-plugins</artifactId>
- <version>5.5-SNAPSHOT</version>
- </parent>
-
- <artifactId>issue-action-plugin</artifactId>
- <packaging>sonar-plugin</packaging>
- <name>Plugins :: Issue Action</name>
- <version>1.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.sonarsource.sonarqube</groupId>
- <artifactId>sonar-plugin-api</artifactId>
- <version>${apiVersion}</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
- <artifactId>sonar-packaging-maven-plugin</artifactId>
- <version>1.15</version>
- <extensions>true</extensions>
- <configuration>
- <pluginClass>IssueActionPlugin</pluginClass>
- <pluginKey>issueaction</pluginKey>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
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 @@
<module>dashboard-plugin</module>
<module>extension-lifecycle-plugin</module>
<module>global-property-change-plugin</module>
- <module>issue-action-plugin</module>
<module>l10n-fr-pack</module>
<module>license-plugin</module>
<module>oauth2-auth-plugin</module>
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
@@ -224,27 +224,6 @@ public class IssueActionTest extends AbstractIssueTest {
* 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
- */
- @Test
public void issue_attribute_are_kept_on_new_analysis() {
// The condition on the action defined by the plugin is that the status must be resolved
adminIssueClient().doTransition(issue.key(), "resolve");
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<String> 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<Action> {
- 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<Action, String> {
- INSTANCE;
-
- @Override
- public String apply(@Nonnull Action action) {
- return action.key();
- }
- }
-
private static class MatchActionKey implements Predicate<Action> {
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
@@ -153,22 +153,6 @@ public class ActionServiceTest {
}
@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 {