aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/main
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-06-03 10:31:16 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-02 16:06:08 +0200
commitbf4118d6a9ceb9ad24274cdc6537d4a607121815 (patch)
tree8f758ccb7a205da3eae96b05b74f79cade8ceae0 /sonar-plugin-api/src/main
parent2f948758eebec934beb54701792cf2d558319251 (diff)
downloadsonarqube-bf4118d6a9ceb9ad24274cdc6537d4a607121815.tar.gz
sonarqube-bf4118d6a9ceb9ad24274cdc6537d4a607121815.zip
SONAR-6623 extract issue tracking algorithm from batch
Diffstat (limited to 'sonar-plugin-api/src/main')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/Issue.java10
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java592
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssueComment.java130
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java195
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/IssueChangeContext.java65
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/package-info.java27
6 files changed, 4 insertions, 1015 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/Issue.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/Issue.java
index 36c7ce4768c..4385daefcd8 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/Issue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/Issue.java
@@ -20,17 +20,15 @@
package org.sonar.api.issue;
import com.google.common.collect.ImmutableList;
-import org.sonar.api.batch.BatchSide;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.utils.Duration;
-
-import javax.annotation.CheckForNull;
-
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
+import javax.annotation.CheckForNull;
+import org.sonar.api.batch.BatchSide;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.api.utils.Duration;
/**
* @since 3.6
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java
deleted file mode 100644
index dac3f9e99e0..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java
+++ /dev/null
@@ -1,592 +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.
- */
-package org.sonar.api.issue.internal;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Maps;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.apache.commons.lang.time.DateUtils;
-import org.sonar.api.issue.Issue;
-import org.sonar.api.issue.IssueComment;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rule.Severity;
-import org.sonar.api.utils.Duration;
-
-/**
- * PLUGINS MUST NOT BE USED THIS CLASS, EXCEPT FOR UNIT TESTING.
- *
- * @since 3.6
- */
-public class DefaultIssue implements Issue {
-
- private String key;
-
- private String componentUuid;
- private String componentKey;
-
- private String moduleUuid;
- private String moduleUuidPath;
-
- private String projectUuid;
- private String projectKey;
-
- private RuleKey ruleKey;
- private String language;
- private String severity;
- private boolean manualSeverity = false;
- private String message;
- private Integer line;
- private Double effortToFix;
- private Duration debt;
- private String status;
- private String resolution;
- private String reporter;
- private String assignee;
- private String checksum;
- private Map<String, String> attributes = null;
- private String authorLogin = null;
- private String actionPlanKey;
- private List<IssueComment> comments = null;
- private Set<String> tags = null;
-
- // FUNCTIONAL DATES
- private Date creationDate;
- private Date updateDate;
- private Date closeDate;
-
- // FOLLOWING FIELDS ARE AVAILABLE ONLY DURING SCAN
-
- // Current changes
- private FieldDiffs currentChange = null;
-
- // all changes
- private List<FieldDiffs> changes = null;
-
- // true if the the issue did not exist in the previous scan.
- private boolean isNew = true;
-
- // True if the the issue did exist in the previous scan but not in the current one. That means
- // that this issue should be closed.
- private boolean endOfLife = false;
-
- private boolean onDisabledRule = false;
-
- // true if some fields have been changed since the previous scan
- private boolean isChanged = false;
-
- // true if notifications have to be sent
- private boolean sendNotifications = false;
-
- // Date when issue was loaded from db (only when isNew=false)
- private Long selectedAt;
-
- @Override
- public String key() {
- return key;
- }
-
- public DefaultIssue setKey(String key) {
- this.key = key;
- return this;
- }
-
- /**
- * Can be null on Views or Devs
- */
- @Override
- @CheckForNull
- public String componentUuid() {
- return componentUuid;
- }
-
- public DefaultIssue setComponentUuid(@CheckForNull String componentUuid) {
- this.componentUuid = componentUuid;
- return this;
- }
-
- @Override
- public String componentKey() {
- return componentKey;
- }
-
- public DefaultIssue setComponentKey(String s) {
- this.componentKey = s;
- return this;
- }
-
- @CheckForNull
- public String moduleUuid() {
- return moduleUuid;
- }
-
- public DefaultIssue setModuleUuid(@Nullable String moduleUuid) {
- this.moduleUuid = moduleUuid;
- return this;
- }
-
- @CheckForNull
- public String moduleUuidPath() {
- return moduleUuidPath;
- }
-
- public DefaultIssue setModuleUuidPath(@Nullable String moduleUuidPath) {
- this.moduleUuidPath = moduleUuidPath;
- return this;
- }
-
- /**
- * Can be null on Views or Devs
- */
- @Override
- @CheckForNull
- public String projectUuid() {
- return projectUuid;
- }
-
- public DefaultIssue setProjectUuid(@Nullable String projectUuid) {
- this.projectUuid = projectUuid;
- return this;
- }
-
- @Override
- public String projectKey() {
- return projectKey;
- }
-
- public DefaultIssue setProjectKey(String projectKey) {
- this.projectKey = projectKey;
- return this;
- }
-
- @Override
- public RuleKey ruleKey() {
- return ruleKey;
- }
-
- public DefaultIssue setRuleKey(RuleKey k) {
- this.ruleKey = k;
- return this;
- }
-
- @Override
- public String language() {
- return language;
- }
-
- public DefaultIssue setLanguage(String l) {
- this.language = l;
- return this;
- }
-
- @Override
- public String severity() {
- return severity;
- }
-
- public DefaultIssue setSeverity(@Nullable String s) {
- Preconditions.checkArgument(s == null || Severity.ALL.contains(s), "Not a valid severity: " + s);
- this.severity = s;
- return this;
- }
-
- public boolean manualSeverity() {
- return manualSeverity;
- }
-
- public DefaultIssue setManualSeverity(boolean b) {
- this.manualSeverity = b;
- return this;
- }
-
- @Override
- @CheckForNull
- public String message() {
- return message;
- }
-
- public DefaultIssue setMessage(@Nullable String s) {
- this.message = StringUtils.abbreviate(StringUtils.trim(s), MESSAGE_MAX_SIZE);
- return this;
- }
-
- @Override
- @CheckForNull
- public Integer line() {
- return line;
- }
-
- public DefaultIssue setLine(@Nullable Integer l) {
- Preconditions.checkArgument(l == null || l > 0, "Line must be null or greater than zero (got " + l + ")");
- this.line = l;
- return this;
- }
-
- @Override
- @CheckForNull
- public Double effortToFix() {
- return effortToFix;
- }
-
- public DefaultIssue setEffortToFix(@Nullable Double d) {
- Preconditions.checkArgument(d == null || d >= 0, "Effort to fix must be greater than or equal 0 (got " + d + ")");
- this.effortToFix = d;
- return this;
- }
-
- /**
- * Elapsed time to fix the issue
- */
- @Override
- @CheckForNull
- public Duration debt() {
- return debt;
- }
-
- @CheckForNull
- public Long debtInMinutes() {
- return debt != null ? debt.toMinutes() : null;
- }
-
- public DefaultIssue setDebt(@Nullable Duration t) {
- this.debt = t;
- return this;
- }
-
- @Override
- public String status() {
- return status;
- }
-
- public DefaultIssue setStatus(String s) {
- Preconditions.checkArgument(!Strings.isNullOrEmpty(s), "Status must be set");
- this.status = s;
- return this;
- }
-
- @Override
- @CheckForNull
- public String resolution() {
- return resolution;
- }
-
- public DefaultIssue setResolution(@Nullable String s) {
- this.resolution = s;
- return this;
- }
-
- @Override
- @CheckForNull
- public String reporter() {
- return reporter;
- }
-
- public DefaultIssue setReporter(@Nullable String s) {
- this.reporter = s;
- return this;
- }
-
- @Override
- @CheckForNull
- public String assignee() {
- return assignee;
- }
-
- public DefaultIssue setAssignee(@Nullable String s) {
- this.assignee = s;
- return this;
- }
-
- @Override
- public Date creationDate() {
- return creationDate;
- }
-
- public DefaultIssue setCreationDate(Date d) {
- // d is not marked as Nullable but we still allow null parameter for unit testing.
- this.creationDate = (d != null ? DateUtils.truncate(d, Calendar.SECOND) : null);
- return this;
- }
-
- @Override
- @CheckForNull
- public Date updateDate() {
- return updateDate;
- }
-
- public DefaultIssue setUpdateDate(@Nullable Date d) {
- this.updateDate = (d != null ? DateUtils.truncate(d, Calendar.SECOND) : null);
- return this;
- }
-
- @Override
- @CheckForNull
- public Date closeDate() {
- return closeDate;
- }
-
- public DefaultIssue setCloseDate(@Nullable Date d) {
- this.closeDate = (d != null ? DateUtils.truncate(d, Calendar.SECOND) : null);
- return this;
- }
-
- @CheckForNull
- public String checksum() {
- return checksum;
- }
-
- public DefaultIssue setChecksum(@Nullable String s) {
- this.checksum = s;
- return this;
- }
-
- @Override
- public boolean isNew() {
- return isNew;
- }
-
- public DefaultIssue setNew(boolean b) {
- isNew = b;
- return this;
- }
-
- /**
- * True when one of the following conditions is true :
- * <ul>
- * <li>the related component has been deleted or renamed</li>
- * <li>the rule has been deleted (eg. on plugin uninstall)</li>
- * <li>the rule has been disabled in the Quality profile</li>
- * </ul>
- */
- public boolean isEndOfLife() {
- return endOfLife;
- }
-
- public DefaultIssue setEndOfLife(boolean b) {
- endOfLife = b;
- return this;
- }
-
- public boolean isOnDisabledRule() {
- return onDisabledRule;
- }
-
- public DefaultIssue setOnDisabledRule(boolean b) {
- onDisabledRule = b;
- return this;
- }
-
- public boolean isChanged() {
- return isChanged;
- }
-
- public DefaultIssue setChanged(boolean b) {
- isChanged = b;
- return this;
- }
-
- public boolean mustSendNotifications() {
- return sendNotifications;
- }
-
- public DefaultIssue setSendNotifications(boolean b) {
- sendNotifications = b;
- return this;
- }
-
- @Override
- @CheckForNull
- public String attribute(String key) {
- return attributes == null ? null : attributes.get(key);
- }
-
- public DefaultIssue setAttribute(String key, @Nullable String value) {
- if (attributes == null) {
- attributes = Maps.newHashMap();
- }
- if (value == null) {
- attributes.remove(key);
- } else {
- attributes.put(key, value);
- }
- return this;
- }
-
- @Override
- public Map<String, String> attributes() {
- return attributes == null ? Collections.<String, String>emptyMap() : ImmutableMap.copyOf(attributes);
- }
-
- public DefaultIssue setAttributes(@Nullable Map<String, String> map) {
- if (map != null) {
- if (attributes == null) {
- attributes = Maps.newHashMap();
- }
- attributes.putAll(map);
- }
- return this;
- }
-
- @Override
- @CheckForNull
- public String authorLogin() {
- return authorLogin;
- }
-
- public DefaultIssue setAuthorLogin(@Nullable String s) {
- this.authorLogin = s;
- return this;
- }
-
- @Override
- @CheckForNull
- public String actionPlanKey() {
- return actionPlanKey;
- }
-
- public DefaultIssue setActionPlanKey(@Nullable String actionPlanKey) {
- this.actionPlanKey = actionPlanKey;
- return this;
- }
-
- public DefaultIssue setFieldChange(IssueChangeContext context, String field, @Nullable Serializable oldValue, @Nullable Serializable newValue) {
- if (!Objects.equal(oldValue, newValue)) {
- if (currentChange == null) {
- currentChange = new FieldDiffs();
- currentChange.setUserLogin(context.login());
- currentChange.setCreationDate(context.date());
- }
- currentChange.setDiff(field, oldValue, newValue);
- }
- addChange(currentChange);
- return this;
- }
-
- public DefaultIssue setCurrentChange(FieldDiffs currentChange) {
- this.currentChange = currentChange;
- addChange(currentChange);
- return this;
- }
-
- @CheckForNull
- public FieldDiffs currentChange() {
- return currentChange;
- }
-
- public DefaultIssue addChange(FieldDiffs change) {
- if (changes == null) {
- changes = new ArrayList<>();
- }
- changes.add(change);
- return this;
- }
-
- public DefaultIssue setChanges(List<FieldDiffs> changes) {
- this.changes = changes;
- return this;
- }
-
- public List<FieldDiffs> changes() {
- if (changes == null) {
- return Collections.emptyList();
- }
- return ImmutableList.copyOf(changes);
- }
-
- public DefaultIssue addComment(DefaultIssueComment comment) {
- if (comments == null) {
- comments = new ArrayList<>();
- }
- comments.add(comment);
- return this;
- }
-
- @Override
- public List<IssueComment> comments() {
- if (comments == null) {
- return Collections.emptyList();
- }
- return ImmutableList.copyOf(comments);
- }
-
- @CheckForNull
- public Long selectedAt() {
- return selectedAt;
- }
-
- public DefaultIssue setSelectedAt(@Nullable Long d) {
- this.selectedAt = d;
- return this;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- DefaultIssue that = (DefaultIssue) o;
- return !(key != null ? !key.equals(that.key) : (that.key != null));
- }
-
- @Override
- public int hashCode() {
- return key != null ? key.hashCode() : 0;
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
- }
-
- @Override
- public Collection<String> tags() {
- if (tags == null) {
- return ImmutableSet.of();
- } else {
- return ImmutableSet.copyOf(tags);
- }
- }
-
- public DefaultIssue setTags(Collection<String> tags) {
- this.tags = new LinkedHashSet<>(tags);
- return this;
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssueComment.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssueComment.java
deleted file mode 100644
index 205f13ebb3d..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssueComment.java
+++ /dev/null
@@ -1,130 +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.
- */
-package org.sonar.api.issue.internal;
-
-import org.sonar.api.issue.IssueComment;
-import org.sonar.api.utils.internal.Uuids;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * PLUGINS MUST NOT BE USED THIS CLASS, EXCEPT FOR UNIT TESTING.
- *
- * @since 3.6
- */
-public class DefaultIssueComment implements Serializable, IssueComment {
-
- private String issueKey;
- private String userLogin;
- private Date createdAt;
- private Date updatedAt;
- private String key;
- private String markdownText;
- private boolean isNew;
-
- public static DefaultIssueComment create(String issueKey, @Nullable String login, String markdownText) {
- DefaultIssueComment comment = new DefaultIssueComment();
- comment.setIssueKey(issueKey);
- comment.setKey(Uuids.create());
- Date now = new Date();
- comment.setUserLogin(login);
- comment.setMarkdownText(markdownText);
- comment.setCreatedAt(now).setUpdatedAt(now);
- comment.setNew(true);
- return comment;
- }
-
- @Override
- public String markdownText() {
- return markdownText;
- }
-
- public DefaultIssueComment setMarkdownText(String s) {
- this.markdownText = s;
- return this;
- }
-
- @Override
- public String issueKey() {
- return issueKey;
- }
-
- public DefaultIssueComment setIssueKey(String s) {
- this.issueKey = s;
- return this;
- }
-
- @Override
- public String key() {
- return key;
- }
-
- public DefaultIssueComment setKey(String key) {
- this.key = key;
- return this;
- }
-
- /**
- * The user who created the comment. Null if it was automatically generated during project scan.
- */
- @Override
- @CheckForNull
- public String userLogin() {
- return userLogin;
- }
-
- public DefaultIssueComment setUserLogin(@Nullable String userLogin) {
- this.userLogin = userLogin;
- return this;
- }
-
- @Override
- public Date createdAt() {
- return createdAt;
- }
-
- public DefaultIssueComment setCreatedAt(Date createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- @Override
- public Date updatedAt() {
- return updatedAt;
- }
-
- public DefaultIssueComment setUpdatedAt(@Nullable Date updatedAt) {
- this.updatedAt = updatedAt;
- return this;
- }
-
- public boolean isNew() {
- return isNew;
- }
-
- public DefaultIssueComment setNew(boolean b) {
- isNew = b;
- return this;
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java
deleted file mode 100644
index 15298414088..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java
+++ /dev/null
@@ -1,195 +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.
- */
-package org.sonar.api.issue.internal;
-
-import com.google.common.base.Splitter;
-import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
-import java.io.Serializable;
-import java.util.Date;
-import java.util.Map;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-/**
- * PLUGINS MUST NOT USE THIS CLASS, EXCEPT FOR UNIT TESTING.
- *
- * @since 3.6
- */
-public class FieldDiffs implements Serializable {
-
- public static final Splitter FIELDS_SPLITTER = Splitter.on(',').omitEmptyStrings();
-
- private String issueKey;
- private String userLogin;
- private Date creationDate;
-
- private final Map<String, Diff> diffs = Maps.newLinkedHashMap();
-
- public Map<String, Diff> diffs() {
- return diffs;
- }
-
- public Diff get(String field) {
- return diffs.get(field);
- }
-
- @CheckForNull
- public String userLogin() {
- return userLogin;
- }
-
- public FieldDiffs setUserLogin(@Nullable String s) {
- this.userLogin = s;
- return this;
- }
-
- public Date creationDate() {
- return creationDate;
- }
-
- public FieldDiffs setCreationDate(Date creationDate) {
- this.creationDate = creationDate;
- return this;
- }
-
- public String issueKey() {
- return issueKey;
- }
-
- public FieldDiffs setIssueKey(String issueKey) {
- this.issueKey = issueKey;
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public FieldDiffs setDiff(String field, @Nullable Serializable oldValue, @Nullable Serializable newValue) {
- Diff diff = diffs.get(field);
- if (diff == null) {
- diff = new Diff(oldValue, newValue);
- diffs.put(field, diff);
- } else {
- diff.setNewValue(newValue);
- }
- return this;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- boolean notFirst = false;
- for (Map.Entry<String, Diff> entry : diffs.entrySet()) {
- if (notFirst) {
- sb.append(',');
- } else {
- notFirst = true;
- }
- sb.append(entry.getKey());
- sb.append('=');
- sb.append(entry.getValue().toString());
- }
- return sb.toString();
- }
-
- public static FieldDiffs parse(@Nullable String s) {
- FieldDiffs diffs = new FieldDiffs();
- if (!Strings.isNullOrEmpty(s)) {
- Iterable<String> fields = FIELDS_SPLITTER.split(s);
- for (String field : fields) {
- String[] keyValues = field.split("=");
- if (keyValues.length == 2) {
- String[] values = keyValues[1].split("\\|");
- String oldValue = "";
- String newValue = "";
- if(values.length == 1) {
- newValue = Strings.nullToEmpty(values[0]);
- } else if(values.length == 2) {
- oldValue = Strings.nullToEmpty(values[0]);
- newValue = Strings.nullToEmpty(values[1]);
- }
- diffs.setDiff(keyValues[0], oldValue, newValue);
- } else {
- diffs.setDiff(keyValues[0], "", "");
- }
- }
- }
- return diffs;
- }
-
- public static class Diff<T extends Serializable> implements Serializable {
- private T oldValue;
- private T newValue;
-
- public Diff(@Nullable T oldValue, @Nullable T newValue) {
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
-
- @CheckForNull
- public T oldValue() {
- return oldValue;
- }
-
- @CheckForNull
- public Long oldValueLong() {
- return toLong(oldValue);
- }
-
- @CheckForNull
- public T newValue() {
- return newValue;
- }
-
- @CheckForNull
- public Long newValueLong() {
- return toLong(newValue);
- }
-
- void setNewValue(T t) {
- this.newValue = t;
- }
-
- @CheckForNull
- private static Long toLong(@Nullable Serializable value) {
- if (value != null && !"".equals(value)) {
- try {
- return Long.valueOf((String) value);
- } catch (ClassCastException e) {
- return (Long) value;
- }
- }
- return null;
- }
-
- @Override
- public String toString() {
- //TODO escape , and | characters
- StringBuilder sb = new StringBuilder();
- if(newValue != null) {
- if(oldValue != null) {
- sb.append(oldValue.toString());
- sb.append('|');
- }
- sb.append(newValue.toString());
- }
- return sb.toString();
- }
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/IssueChangeContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/IssueChangeContext.java
deleted file mode 100644
index 1598ad153dc..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/IssueChangeContext.java
+++ /dev/null
@@ -1,65 +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.
- */
-package org.sonar.api.issue.internal;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * PLUGINS MUST NOT BE USED THIS CLASS, EXCEPT FOR UNIT TESTING.
- *
- * @since 3.6
- */
-public class IssueChangeContext implements Serializable {
-
- private final String login;
- private final Date date;
- private final boolean scan;
-
- private IssueChangeContext(@Nullable String login, Date date, boolean scan) {
- this.login = login;
- this.date = date;
- this.scan = scan;
- }
-
- @CheckForNull
- public String login() {
- return login;
- }
-
- public Date date() {
- return date;
- }
-
- public boolean scan() {
- return scan;
- }
-
- public static IssueChangeContext createScan(Date date) {
- return new IssueChangeContext(null, date, true);
- }
-
- public static IssueChangeContext createUser(Date date, @Nullable String login) {
- return new IssueChangeContext(login, date, false);
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/package-info.java
deleted file mode 100644
index d95967fcd6b..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/package-info.java
+++ /dev/null
@@ -1,27 +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.
- */
-/**
- * This package contains classes that MUST NOT be used by plugins,
- * except for unit testing.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.api.issue.internal;
-
-import javax.annotation.ParametersAreNonnullByDefault;