import org.sonar.api.issue.Issue;
import org.sonar.api.issue.IssueComment;
import org.sonar.api.issue.internal.DefaultIssueComment;
+import org.sonar.api.resources.Language;
+import org.sonar.api.resources.Languages;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;
import org.sonar.api.server.ws.Request;
private final UserFinder userFinder;
private final I18n i18n;
private final Durations durations;
+ private final Languages languages;
public SearchAction(DbClient dbClient, IssueChangeDao issueChangeDao, IssueService service, IssueActionsWriter actionsWriter, IssueQueryService issueQueryService,
- RuleService ruleService, ActionPlanService actionPlanService, UserFinder userFinder, I18n i18n, Durations durations) {
+ RuleService ruleService, ActionPlanService actionPlanService, UserFinder userFinder, I18n i18n, Durations durations, Languages languages) {
super(SEARCH_ACTION);
this.dbClient = dbClient;
this.issueChangeDao = issueChangeDao;
this.userFinder = userFinder;
this.i18n = i18n;
this.durations = durations;
+ this.languages = languages;
}
@Override
writeRules(json, !request.mandatoryParamAsBoolean(IssueFilterParameters.HIDE_RULES) ? ruleService.getByKeys(ruleKeys) : Collections.<Rule>emptyList());
writeUsers(json, usersByLogin);
writeActionPlans(json, actionPlanByKeys.values());
+ writeLanguages(json);
// TODO remove legacy paging. Handled by the SearchRequestHandler
writeLegacyPaging(context, json, result);
json.endArray();
}
+ private void writeLanguages(JsonWriter json) {
+ json.name("languages").beginArray();
+ for (Language language: languages.all()) {
+ json.beginObject()
+ .prop("key", language.getKey())
+ .prop("name", language.getName())
+ .endObject();
+ }
+ json.endArray();
+ }
+
private void writeActionPlans(JsonWriter json, Collection<ActionPlan> plans) {
if (!plans.isEmpty()) {
json.name("actionPlans").beginArray();
import org.sonar.api.issue.internal.DefaultIssue;
import org.sonar.api.issue.internal.DefaultIssueComment;
import org.sonar.api.issue.internal.FieldDiffs;
+import org.sonar.api.resources.Languages;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
import org.sonar.api.user.User;
new IssueActionsWriter(issueService, actionService), actionPlanService, userFinder, debtModel, ruleService, i18n, durations),
new SearchAction(mock(DbClient.class), mock(IssueChangeDao.class), mock(IssueService.class), mock(IssueActionsWriter.class), mock(IssueQueryService.class),
mock(RuleService.class),
- mock(ActionPlanService.class), mock(UserFinder.class), mock(I18n.class), mock(Durations.class))));
+ mock(ActionPlanService.class), mock(UserFinder.class), mock(I18n.class), mock(Durations.class), mock(Languages.class))));
}
@Test
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.i18n.I18n;
+import org.sonar.api.resources.Languages;
import org.sonar.api.server.ws.RailsHandler;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.user.UserFinder;
debtModelService, mock(RuleService.class), i18n, durations);
SearchAction searchAction = new SearchAction(mock(DbClient.class), mock(IssueChangeDao.class), mock(IssueService.class), mock(IssueActionsWriter.class),
mock(IssueQueryService.class), mock(RuleService.class),
- mock(ActionPlanService.class), mock(UserFinder.class), mock(I18n.class), mock(Durations.class));
+ mock(ActionPlanService.class), mock(UserFinder.class), mock(I18n.class), mock(Durations.class), mock(Languages.class));
tester = new WsTester(new IssuesWs(showAction, searchAction));
}