use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class DoTransitionAction method doTransition.
private SearchResponseData doTransition(DbSession session, IssueDto issueDto, String transitionKey) {
DefaultIssue defaultIssue = issueDto.toDefaultIssue();
IssueChangeContext context = IssueChangeContext.createUser(new Date(system2.now()), userSession.getUuid());
transitionService.checkTransitionPermission(transitionKey, defaultIssue);
if (transitionService.doTransition(defaultIssue, context, transitionKey)) {
return issueUpdater.saveIssueAndPreloadSearchResponseData(session, defaultIssue, context, true);
}
return new SearchResponseData(issueDto);
}
use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class SetSeverityAction method setType.
private SearchResponseData setType(DbSession session, String issueKey, String severity) {
IssueDto issueDto = issueFinder.getByKey(session, issueKey);
DefaultIssue issue = issueDto.toDefaultIssue();
userSession.checkComponentUuidPermission(ISSUE_ADMIN, issue.projectUuid());
IssueChangeContext context = IssueChangeContext.createUser(new Date(), userSession.getUuid());
if (issueFieldsSetter.setManualSeverity(issue, severity, context)) {
return issueUpdater.saveIssueAndPreloadSearchResponseData(session, issue, context, true);
}
return new SearchResponseData(issueDto);
}
use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class SetTypeAction method setType.
private SearchResponseData setType(DbSession session, String issueKey, RuleType ruleType) {
IssueDto issueDto = issueFinder.getByKey(session, issueKey);
DefaultIssue issue = issueDto.toDefaultIssue();
userSession.checkComponentUuidPermission(ISSUE_ADMIN, issue.projectUuid());
IssueChangeContext context = IssueChangeContext.createUser(new Date(system2.now()), userSession.getUuid());
if (issueFieldsSetter.setType(issue, ruleType, context)) {
return issueUpdater.saveIssueAndPreloadSearchResponseData(session, issue, context, true);
}
return new SearchResponseData(issueDto);
}
use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class ProjectTrackerBaseLazyInput method migrateIssuesToTheRoot.
private Collection<? extends DefaultIssue> migrateIssuesToTheRoot(List<DefaultIssue> issuesOnModule, String modulePath) {
for (DefaultIssue i : issuesOnModule) {
// changes the issue's component uuid, add a change and set issue as changed to enforce it is persisted to DB
IssueChangeContext context = IssueChangeContext.createUser(new Date(analysisMetadataHolder.getAnalysisDate()), null);
if (StringUtils.isNotBlank(modulePath)) {
issueUpdater.setMessage(i, "[" + modulePath + "] " + i.getMessage(), context);
}
issueUpdater.setIssueMoved(i, component.getUuid(), context);
// other fields (such as module, modulePath, componentKey) are read-only and set/reset for consistency only
i.setComponentKey(component.getKey());
i.setModuleUuid(null);
i.setModuleUuidPath(null);
}
return issuesOnModule;
}
use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class AssignAction method assign.
private void assign(String hotspotKey, String login, @Nullable String comment) {
try (DbSession dbSession = dbClient.openSession(false)) {
IssueDto hotspotDto = hotspotWsSupport.loadHotspot(dbSession, hotspotKey);
checkIfHotspotToReview(hotspotDto);
hotspotWsSupport.loadAndCheckProject(dbSession, hotspotDto, UserRole.USER);
UserDto assignee = isNullOrEmpty(login) ? null : getAssignee(dbSession, login);
IssueChangeContext context = hotspotWsSupport.newIssueChangeContext();
DefaultIssue defaultIssue = hotspotDto.toDefaultIssue();
if (comment != null) {
issueFieldsSetter.addComment(defaultIssue, comment, context);
}
if (assignee != null) {
checkAssigneeProjectPermission(dbSession, assignee, hotspotDto.getProjectUuid());
}
if (issueFieldsSetter.assign(defaultIssue, assignee, context)) {
issueUpdater.saveIssueAndPreloadSearchResponseData(dbSession, defaultIssue, context, false);
}
}
}
Aggregations