use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class SetSeverityAction method setType.
private void setType(DbSession session, String issueKey, String severity) {
DefaultIssue issue = issueFinder.getByKey(session, issueKey).toDefaultIssue();
userSession.checkComponentUuidPermission(ISSUE_ADMIN, issue.projectUuid());
IssueChangeContext context = IssueChangeContext.createUser(new Date(), userSession.getLogin());
if (issueFieldsSetter.setManualSeverity(issue, severity, context)) {
issueUpdater.saveIssue(session, issue, context, null);
}
}
use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class SetTypeAction method setType.
private void setType(DbSession session, String issueKey, RuleType ruleType) {
DefaultIssue issue = issueFinder.getByKey(session, issueKey).toDefaultIssue();
userSession.checkComponentUuidPermission(ISSUE_ADMIN, issue.projectUuid());
IssueChangeContext context = IssueChangeContext.createUser(new Date(), userSession.getLogin());
if (issueFieldsSetter.setType(issue, ruleType, context)) {
issueUpdater.saveIssue(session, issue, context, null);
}
}
use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class IssueService method assign.
public void assign(String issueKey, @Nullable String assignee) {
userSession.checkLoggedIn();
DbSession session = dbClient.openSession(false);
try {
DefaultIssue issue = issueFinder.getByKey(session, issueKey).toDefaultIssue();
User user = null;
if (!Strings.isNullOrEmpty(assignee)) {
user = userFinder.findByLogin(assignee);
checkRequest(user != null, "Unknown user: %s", assignee);
}
IssueChangeContext context = IssueChangeContext.createUser(new Date(), userSession.getLogin());
if (issueFieldsSetter.assign(issue, user, context)) {
issueUpdater.saveIssue(session, issue, context, null);
}
} finally {
session.close();
}
}
use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class IssueService method setTags.
public Collection<String> setTags(String issueKey, Collection<String> tags) {
userSession.checkLoggedIn();
DbSession session = dbClient.openSession(false);
try {
DefaultIssue issue = issueFinder.getByKey(session, issueKey).toDefaultIssue();
IssueChangeContext context = IssueChangeContext.createUser(new Date(), userSession.getLogin());
if (issueFieldsSetter.setTags(issue, tags, context)) {
issueUpdater.saveIssue(session, issue, context, null);
}
return issue.tags();
} finally {
session.close();
}
}
use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class MovedIssueVisitorTest method onIssue_update_component_and_module_fields_to_component_and_flag_issue_has_changed.
@Test
public void onIssue_update_component_and_module_fields_to_component_and_flag_issue_has_changed() {
MovedFilesRepository.OriginalFile originalFile = new MovedFilesRepository.OriginalFile(6451, "original uuid", "original key");
DefaultIssue issue = mockIssue(originalFile.getUuid());
when(movedFilesRepository.getOriginalFile(FILE)).thenReturn(Optional.of(originalFile));
underTest.onIssue(FILE, issue);
verify(issue).setComponentUuid(FILE.getUuid());
verify(issue).setComponentKey(FILE.getKey());
verify(issue).setModuleUuid(null);
verify(issue).setModuleUuidPath(null);
verify(issue).setChanged(true);
ArgumentCaptor<IssueChangeContext> issueChangeContextCaptor = ArgumentCaptor.forClass(IssueChangeContext.class);
verify(issue).setFieldChange(issueChangeContextCaptor.capture(), eq("file"), eq(originalFile.getUuid()), eq(FILE.getUuid()));
assertThat(issueChangeContextCaptor.getValue().date()).isEqualTo(new Date(ANALYSIS_DATE));
assertThat(issueChangeContextCaptor.getValue().login()).isNull();
assertThat(issueChangeContextCaptor.getValue().scan()).isFalse();
}
Aggregations