Search in sources :

Example 1 with RowNotFoundException

use of org.sonar.db.RowNotFoundException in project sonarqube by SonarSource.

the class ReportAnalysisFailureNotificationExecutionListener method onEnd.

@Override
public void onEnd(CeTask ceTask, CeActivityDto.Status status, Duration duration, @Nullable CeTaskResult taskResult, @Nullable Throwable error) {
    if (status == CeActivityDto.Status.SUCCESS) {
        return;
    }
    String projectUuid = ceTask.getComponent().map(CeTask.Component::getUuid).orElse(null);
    if (!CeTaskTypes.REPORT.equals(ceTask.getType()) || projectUuid == null) {
        return;
    }
    if (notificationService.hasProjectSubscribersForTypes(projectUuid, singleton(ReportAnalysisFailureNotification.class))) {
        try (DbSession dbSession = dbClient.openSession(false)) {
            ComponentDto projectDto = dbClient.componentDao().selectOrFailByUuid(dbSession, projectUuid);
            checkScopeAndQualifier(projectDto);
            CeActivityDto ceActivityDto = dbClient.ceActivityDao().selectByUuid(dbSession, ceTask.getUuid()).orElseThrow(() -> new RowNotFoundException(format("CeActivity with uuid '%s' not found", ceTask.getUuid())));
            ReportAnalysisFailureNotificationBuilder taskFailureNotification = buildNotification(ceActivityDto, projectDto, error);
            ReportAnalysisFailureNotification notification = taskFailureNotificationSerializer.toNotification(taskFailureNotification);
            notificationService.deliverEmails(singleton(notification));
            // compatibility with old API
            notificationService.deliver(notification);
        }
    }
}
Also used : DbSession(org.sonar.db.DbSession) ReportAnalysisFailureNotificationBuilder(org.sonar.ce.task.projectanalysis.notification.ReportAnalysisFailureNotificationBuilder) CeActivityDto(org.sonar.db.ce.CeActivityDto) RowNotFoundException(org.sonar.db.RowNotFoundException) ComponentDto(org.sonar.db.component.ComponentDto) CeTask(org.sonar.ce.task.CeTask) ReportAnalysisFailureNotification(org.sonar.ce.task.projectanalysis.notification.ReportAnalysisFailureNotification)

Aggregations

CeTask (org.sonar.ce.task.CeTask)1 ReportAnalysisFailureNotification (org.sonar.ce.task.projectanalysis.notification.ReportAnalysisFailureNotification)1 ReportAnalysisFailureNotificationBuilder (org.sonar.ce.task.projectanalysis.notification.ReportAnalysisFailureNotificationBuilder)1 DbSession (org.sonar.db.DbSession)1 RowNotFoundException (org.sonar.db.RowNotFoundException)1 CeActivityDto (org.sonar.db.ce.CeActivityDto)1 ComponentDto (org.sonar.db.component.ComponentDto)1