package org.sonar.plugins.core.issue;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Predicate;
import com.google.common.collect.*;
import org.apache.commons.lang.time.DateUtils;
import org.sonar.api.batch.*;
import org.sonar.batch.components.TimeMachineConfiguration;
import javax.annotation.Nullable;
-
import java.util.*;
-import static com.google.common.collect.Lists.newArrayList;
-
/**
* Computes metrics related to number of issues.
*
rulesBag.add(rulefinder.findByKey(issue.ruleKey().repository(), issue.ruleKey().rule()));
issuesPerSeverity.put(RulePriority.valueOf(issue.severity()), issue);
- if (Issue.STATUS_OPEN.equals(issue.status())){
+ if (Issue.STATUS_OPEN.equals(issue.status())) {
countOpen++;
}
- if (Issue.STATUS_REOPENED.equals(issue.status())){
+ if (Issue.STATUS_REOPENED.equals(issue.status())) {
countReopened++;
}
- if (Issue.STATUS_CONFIRMED.equals(issue.status())){
+ if (Issue.STATUS_CONFIRMED.equals(issue.status())) {
countConfirmed++;
}
}
String projectKey = notification.getFieldValue("projectKey");
String dateString = notification.getFieldValue("projectDate");
Date date = DateUtils.parseDateTime(dateString);
- String url = String.format("%s/issues/search?componentRoots=%s&createdAfter=%s", settings.getServerBaseURL(), URLEncoder.encode(projectKey), DateUtils.formatDate(date));
- sb.append("\n")
- .append("See it in SonarQube: ")
- .append(url)
- .append("\n");
+ String url = String.format("%s/issues/search?componentRoots=%s&createdAfter=%s",
+ settings.getServerBaseURL(), URLEncoder.encode(projectKey), DateUtils.formatDate(date));
+ sb.append("\n").append("See it in SonarQube: ").append(url).append("\n");
}
}
"\n" +
"See it in SonarQube: http://nemo.sonarsource.org/issues/search?componentRoots=org.apache%3Astruts&createdAfter=2010-05-18\n");
}
-
}
}
public boolean isOpen(){
- return ActionPlan.STATUS_OPEN.equals(super.status());
+ return ActionPlan.STATUS_OPEN.equals(status());
}
public boolean overDue(){
- return super.status() == ActionPlan.STATUS_OPEN && super.deadLine() != null && new Date().after(super.deadLine());
+ return isOpen() && deadLine() != null && new Date().after(deadLine());
}
}
IssueBuilder message(@Nullable String message);
- IssueBuilder severity(String severity);
+ IssueBuilder severity(@Nullable String severity);
- IssueBuilder reporter(String reporter);
+ IssueBuilder reporter(@Nullable String reporter);
IssueBuilder effortToFix(@Nullable Double d);
import org.sonar.core.issue.workflow.Transition;
import org.sonar.server.user.UserSession;
+import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
IssueQueryResult queryResult = loadIssue(issueKey);
DefaultIssue issue = (DefaultIssue) queryResult.first();
- // TODO check that assignee exists
- IssueChangeContext context = IssueChangeContext.createUser(new Date(), userSession.login());
- if (issueUpdater.assign(issue, assignee, context)) {
- issueStorage.save(issue);
- issueNotifications.sendChanges(issue, context, queryResult);
+ if (issue != null) {
+ // TODO check that assignee exists
+ IssueChangeContext context = IssueChangeContext.createUser(new Date(), userSession.login());
+ if (issueUpdater.assign(issue, assignee, context)) {
+ issueStorage.save(issue);
+ issueNotifications.sendChanges(issue, context, queryResult);
+ }
}
return issue;
}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.platform;
-
-import org.slf4j.LoggerFactory;
-import org.sonar.api.ServerComponent;
-import org.sonar.api.platform.NewUserHandler;
-
-/**
- * @since 3.2
- */
-public class NewUserNotifier implements ServerComponent {
-
- private NewUserHandler[] handlers;
-
- public NewUserNotifier(NewUserHandler[] handlers) {
- this.handlers = handlers;
- }
-
- public NewUserNotifier() {
- this(new NewUserHandler[0]);
- }
-
- public void onNewUser(NewUserHandler.Context context) {
- LoggerFactory.getLogger(NewUserNotifier.class).debug("User created: " + context.getLogin() + ". Notifying " + NewUserHandler.class.getSimpleName() + " handlers...");
- for (NewUserHandler handler : handlers) {
- handler.doOnNewUser(context);
- }
- }
-}
\ No newline at end of file
import org.sonar.server.text.RubyTextService;
import org.sonar.server.ui.*;
import org.sonar.server.user.DefaultRubyUserService;
+import org.sonar.server.user.NewUserNotifier;
import javax.servlet.ServletContext;
import org.sonar.server.plugins.*;
import org.sonar.server.rules.ProfilesConsole;
import org.sonar.server.rules.RulesConsole;
+import org.sonar.server.user.NewUserNotifier;
import org.sonar.updatecenter.common.PluginReferential;
import org.sonar.updatecenter.common.UpdateCenter;
import org.sonar.updatecenter.common.Version;
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 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.user;
+
+import org.slf4j.LoggerFactory;
+import org.sonar.api.ServerComponent;
+import org.sonar.api.platform.NewUserHandler;
+
+/**
+ * @since 3.2
+ */
+public class NewUserNotifier implements ServerComponent {
+
+ private NewUserHandler[] handlers;
+
+ public NewUserNotifier(NewUserHandler[] handlers) {
+ this.handlers = handlers;
+ }
+
+ public NewUserNotifier() {
+ this(new NewUserHandler[0]);
+ }
+
+ public void onNewUser(NewUserHandler.Context context) {
+ LoggerFactory.getLogger(NewUserNotifier.class).debug("User created: " + context.getLogin() + ". Notifying " + NewUserHandler.class.getSimpleName() + " handlers...");
+ for (NewUserHandler handler : handlers) {
+ handler.doOnNewUser(context);
+ }
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.platform;
-
-import org.junit.Test;
-import org.sonar.api.platform.NewUserHandler;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-public class NewUserNotifierTest {
-
- private NewUserHandler.Context context = NewUserHandler.Context.builder().setLogin("marius").setName("Marius").build();
-
- @Test
- public void do_not_fail_if_no_handlers() {
- NewUserNotifier notifier = new NewUserNotifier();
-
- notifier.onNewUser(context);
- }
-
- @Test
- public void execute_handlers_on_new_user() {
- NewUserHandler handler1 = mock(NewUserHandler.class);
- NewUserHandler handler2 = mock(NewUserHandler.class);
- NewUserNotifier notifier = new NewUserNotifier(new NewUserHandler[]{handler1, handler2});
-
-
- notifier.onNewUser(context);
-
- verify(handler1).doOnNewUser(context);
- verify(handler2).doOnNewUser(context);
- }
-}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 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.user;
+
+import org.junit.Test;
+import org.sonar.api.platform.NewUserHandler;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class NewUserNotifierTest {
+
+ NewUserHandler.Context context = NewUserHandler.Context.builder().setLogin("marius").setName("Marius").build();
+
+ @Test
+ public void do_not_fail_if_no_handlers() {
+ NewUserNotifier notifier = new NewUserNotifier();
+
+ notifier.onNewUser(context);
+ }
+
+ @Test
+ public void execute_handlers_on_new_user() {
+ NewUserHandler handler1 = mock(NewUserHandler.class);
+ NewUserHandler handler2 = mock(NewUserHandler.class);
+ NewUserNotifier notifier = new NewUserNotifier(new NewUserHandler[]{handler1, handler2});
+
+
+ notifier.onNewUser(context);
+
+ verify(handler1).doOnNewUser(context);
+ verify(handler2).doOnNewUser(context);
+ }
+}