You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IssueQueryFactory.java 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2023 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.server.issue.index;
  21. import com.google.common.base.Joiner;
  22. import com.google.common.collect.ImmutableList;
  23. import java.time.Clock;
  24. import java.time.DateTimeException;
  25. import java.time.OffsetDateTime;
  26. import java.time.Period;
  27. import java.time.ZoneId;
  28. import java.util.ArrayList;
  29. import java.util.Arrays;
  30. import java.util.Collection;
  31. import java.util.Collections;
  32. import java.util.Date;
  33. import java.util.HashSet;
  34. import java.util.List;
  35. import java.util.Locale;
  36. import java.util.Map;
  37. import java.util.Objects;
  38. import java.util.Optional;
  39. import java.util.Set;
  40. import java.util.stream.Collectors;
  41. import javax.annotation.Nullable;
  42. import org.apache.commons.lang.BooleanUtils;
  43. import org.jetbrains.annotations.NotNull;
  44. import org.slf4j.Logger;
  45. import org.slf4j.LoggerFactory;
  46. import org.sonar.api.resources.Qualifiers;
  47. import org.sonar.api.rule.RuleKey;
  48. import org.sonar.api.rules.RuleType;
  49. import org.sonar.api.server.ServerSide;
  50. import org.sonar.db.DbClient;
  51. import org.sonar.db.DbSession;
  52. import org.sonar.db.component.BranchDto;
  53. import org.sonar.db.component.ComponentDto;
  54. import org.sonar.db.component.SnapshotDto;
  55. import org.sonar.db.rule.RuleDto;
  56. import org.sonar.server.issue.SearchRequest;
  57. import org.sonar.server.issue.index.IssueQuery.PeriodStart;
  58. import org.sonar.server.user.UserSession;
  59. import static com.google.common.base.Preconditions.checkArgument;
  60. import static com.google.common.base.Strings.isNullOrEmpty;
  61. import static com.google.common.collect.Collections2.transform;
  62. import static java.lang.String.format;
  63. import static java.util.Collections.singleton;
  64. import static java.util.Collections.singletonList;
  65. import static org.sonar.api.issue.Issue.STATUSES;
  66. import static org.sonar.api.issue.Issue.STATUS_REVIEWED;
  67. import static org.sonar.api.issue.Issue.STATUS_TO_REVIEW;
  68. import static org.sonar.api.measures.CoreMetrics.ANALYSIS_FROM_SONARQUBE_9_4_KEY;
  69. import static org.sonar.api.utils.DateUtils.longToDate;
  70. import static org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime;
  71. import static org.sonar.api.utils.DateUtils.parseStartingDateOrDateTime;
  72. import static org.sonar.api.web.UserRole.USER;
  73. import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
  74. import static org.sonar.db.newcodeperiod.NewCodePeriodType.REFERENCE_BRANCH;
  75. import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
  76. import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_UUIDS;
  77. import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_AFTER;
  78. import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_IN_LAST;
  79. import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IN_NEW_CODE_PERIOD;
  80. /**
  81. * This component is used to create an IssueQuery, in order to transform the component and component roots keys into uuid.
  82. */
  83. @ServerSide
  84. public class IssueQueryFactory {
  85. private static final Logger LOGGER = LoggerFactory.getLogger(IssueQueryFactory.class);
  86. public static final String UNKNOWN = "<UNKNOWN>";
  87. public static final List<String> ISSUE_STATUSES = STATUSES.stream()
  88. .filter(s -> !s.equals(STATUS_TO_REVIEW))
  89. .filter(s -> !s.equals(STATUS_REVIEWED))
  90. .collect(ImmutableList.toImmutableList());
  91. public static final Set<String> ISSUE_TYPE_NAMES = Arrays.stream(RuleType.values())
  92. .filter(t -> t != RuleType.SECURITY_HOTSPOT)
  93. .map(Enum::name)
  94. .collect(Collectors.toSet());
  95. private static final ComponentDto UNKNOWN_COMPONENT = new ComponentDto().setUuid(UNKNOWN).setBranchUuid(UNKNOWN);
  96. private static final Set<String> QUALIFIERS_WITHOUT_LEAK_PERIOD = new HashSet<>(Arrays.asList(Qualifiers.APP, Qualifiers.VIEW, Qualifiers.SUBVIEW));
  97. private final DbClient dbClient;
  98. private final Clock clock;
  99. private final UserSession userSession;
  100. public IssueQueryFactory(DbClient dbClient, Clock clock, UserSession userSession) {
  101. this.dbClient = dbClient;
  102. this.clock = clock;
  103. this.userSession = userSession;
  104. }
  105. public IssueQuery create(SearchRequest request) {
  106. try (DbSession dbSession = dbClient.openSession(false)) {
  107. final ZoneId timeZone = parseTimeZone(request.getTimeZone()).orElse(clock.getZone());
  108. Collection<RuleDto> ruleDtos = ruleKeysToRuleId(dbSession, request.getRules());
  109. Collection<String> ruleUuids = ruleDtos.stream().map(RuleDto::getUuid).collect(Collectors.toSet());
  110. if (request.getRules() != null && request.getRules().stream().collect(Collectors.toSet()).size() != ruleDtos.size()) {
  111. ruleUuids.add("non-existing-uuid");
  112. }
  113. IssueQuery.Builder builder = IssueQuery.builder()
  114. .issueKeys(request.getIssues())
  115. .severities(request.getSeverities())
  116. .statuses(request.getStatuses())
  117. .resolutions(request.getResolutions())
  118. .resolved(request.getResolved())
  119. .rules(ruleDtos)
  120. .ruleUuids(ruleUuids)
  121. .assigneeUuids(request.getAssigneeUuids())
  122. .authors(request.getAuthors())
  123. .scopes(request.getScopes())
  124. .languages(request.getLanguages())
  125. .tags(request.getTags())
  126. .types(request.getTypes())
  127. .pciDss32(request.getPciDss32())
  128. .pciDss40(request.getPciDss40())
  129. .owaspAsvs40(request.getOwaspAsvs40())
  130. .owaspAsvsLevel(request.getOwaspAsvsLevel())
  131. .owaspTop10(request.getOwaspTop10())
  132. .owaspTop10For2021(request.getOwaspTop10For2021())
  133. .sansTop25(request.getSansTop25())
  134. .cwe(request.getCwe())
  135. .sonarsourceSecurity(request.getSonarsourceSecurity())
  136. .assigned(request.getAssigned())
  137. .createdAt(parseStartingDateOrDateTime(request.getCreatedAt(), timeZone))
  138. .createdBefore(parseEndingDateOrDateTime(request.getCreatedBefore(), timeZone))
  139. .facetMode(request.getFacetMode())
  140. .timeZone(timeZone)
  141. .codeVariants(request.getCodeVariants());
  142. List<ComponentDto> allComponents = new ArrayList<>();
  143. boolean effectiveOnComponentOnly = mergeDeprecatedComponentParameters(dbSession, request, allComponents);
  144. addComponentParameters(builder, dbSession, effectiveOnComponentOnly, allComponents, request);
  145. setCreatedAfterFromRequest(dbSession, builder, request, allComponents, timeZone);
  146. String sort = request.getSort();
  147. if (!isNullOrEmpty(sort)) {
  148. builder.sort(sort);
  149. builder.asc(request.getAsc());
  150. }
  151. return builder.build();
  152. }
  153. }
  154. private static Optional<ZoneId> parseTimeZone(@Nullable String timeZone) {
  155. if (timeZone == null) {
  156. return Optional.empty();
  157. }
  158. try {
  159. return Optional.of(ZoneId.of(timeZone));
  160. } catch (DateTimeException e) {
  161. LOGGER.warn("TimeZone '" + timeZone + "' cannot be parsed as a valid zone ID");
  162. return Optional.empty();
  163. }
  164. }
  165. private void setCreatedAfterFromDates(IssueQuery.Builder builder, @Nullable Date createdAfter, @Nullable String createdInLast, boolean createdAfterInclusive) {
  166. Date actualCreatedAfter = createdAfter;
  167. if (createdInLast != null) {
  168. actualCreatedAfter = Date.from(
  169. OffsetDateTime.now(clock)
  170. .minus(Period.parse("P" + createdInLast.toUpperCase(Locale.ENGLISH)))
  171. .toInstant());
  172. }
  173. builder.createdAfter(actualCreatedAfter, createdAfterInclusive);
  174. }
  175. private void setCreatedAfterFromRequest(DbSession dbSession, IssueQuery.Builder builder, SearchRequest request, List<ComponentDto> componentUuids, ZoneId timeZone) {
  176. Date createdAfter = parseStartingDateOrDateTime(request.getCreatedAfter(), timeZone);
  177. String createdInLast = request.getCreatedInLast();
  178. if (notInNewCodePeriod(request)) {
  179. checkArgument(createdAfter == null || createdInLast == null, format("Parameters %s and %s cannot be set simultaneously", PARAM_CREATED_AFTER, PARAM_CREATED_IN_LAST));
  180. setCreatedAfterFromDates(builder, createdAfter, createdInLast, true);
  181. } else {
  182. // If the filter is on leak period
  183. checkArgument(createdAfter == null, "Parameters '%s' and '%s' cannot be set simultaneously", PARAM_CREATED_AFTER, PARAM_IN_NEW_CODE_PERIOD);
  184. checkArgument(createdInLast == null,
  185. format("Parameters '%s' and '%s' cannot be set simultaneously", PARAM_CREATED_IN_LAST, PARAM_IN_NEW_CODE_PERIOD));
  186. checkArgument(componentUuids.size() == 1, "One and only one component must be provided when searching in new code period");
  187. ComponentDto component = componentUuids.iterator().next();
  188. if (!QUALIFIERS_WITHOUT_LEAK_PERIOD.contains(component.qualifier()) && request.getPullRequest() == null) {
  189. Optional<SnapshotDto> snapshot = getLastAnalysis(dbSession, component);
  190. if (!snapshot.isEmpty() && isLastAnalysisFromReAnalyzedReferenceBranch(dbSession, snapshot.get())) {
  191. builder.newCodeOnReference(true);
  192. return;
  193. }
  194. // if last analysis has no period date, then no issue should be considered new.
  195. Date createdAfterFromSnapshot = findCreatedAfterFromComponentUuid(snapshot);
  196. setCreatedAfterFromDates(builder, createdAfterFromSnapshot, null, false);
  197. }
  198. }
  199. }
  200. private static boolean notInNewCodePeriod(SearchRequest request) {
  201. Boolean inNewCodePeriod = request.getInNewCodePeriod();
  202. inNewCodePeriod = Boolean.TRUE.equals(inNewCodePeriod);
  203. return !inNewCodePeriod;
  204. }
  205. private Date findCreatedAfterFromComponentUuid(Optional<SnapshotDto> snapshot) {
  206. return snapshot.map(s -> longToDate(s.getPeriodDate())).orElseGet(() -> new Date(clock.millis()));
  207. }
  208. private static boolean isLastAnalysisUsingReferenceBranch(SnapshotDto snapshot) {
  209. return !isNullOrEmpty(snapshot.getPeriodMode()) && snapshot.getPeriodMode().equals(REFERENCE_BRANCH.name());
  210. }
  211. private boolean isLastAnalysisFromSonarQube94Onwards(DbSession dbSession, String componentUuid) {
  212. return dbClient.liveMeasureDao().selectMeasure(dbSession, componentUuid, ANALYSIS_FROM_SONARQUBE_9_4_KEY).isPresent();
  213. }
  214. private Optional<SnapshotDto> getLastAnalysis(DbSession dbSession, ComponentDto component) {
  215. return dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.uuid());
  216. }
  217. private List<SnapshotDto> getLastAnalysis(DbSession dbSession, Set<String> projectUuids) {
  218. return dbClient.snapshotDao().selectLastAnalysesByRootComponentUuids(dbSession, projectUuids);
  219. }
  220. private boolean mergeDeprecatedComponentParameters(DbSession session, SearchRequest request, List<ComponentDto> allComponents) {
  221. Boolean onComponentOnly = request.getOnComponentOnly();
  222. Collection<String> componentKeys = request.getComponentKeys();
  223. Collection<String> componentUuids = request.getComponentUuids();
  224. String branch = request.getBranch();
  225. String pullRequest = request.getPullRequest();
  226. boolean effectiveOnComponentOnly = false;
  227. checkArgument(atMostOneNonNullElement(componentKeys, componentUuids),
  228. "At most one of the following parameters can be provided: %s and %s", PARAM_COMPONENT_KEYS, PARAM_COMPONENT_UUIDS);
  229. if (componentKeys != null) {
  230. allComponents.addAll(getComponentsFromKeys(session, componentKeys, branch, pullRequest));
  231. effectiveOnComponentOnly = BooleanUtils.isTrue(onComponentOnly);
  232. } else if (componentUuids != null) {
  233. allComponents.addAll(getComponentsFromUuids(session, componentUuids));
  234. effectiveOnComponentOnly = BooleanUtils.isTrue(onComponentOnly);
  235. }
  236. return effectiveOnComponentOnly;
  237. }
  238. private static boolean atMostOneNonNullElement(Object... objects) {
  239. return Arrays.stream(objects)
  240. .filter(Objects::nonNull)
  241. .count() <= 1;
  242. }
  243. private void addComponentParameters(IssueQuery.Builder builder, DbSession session, boolean onComponentOnly, List<ComponentDto> components,
  244. SearchRequest request) {
  245. builder.onComponentOnly(onComponentOnly);
  246. if (onComponentOnly) {
  247. builder.componentUuids(components.stream().map(ComponentDto::uuid).toList());
  248. setBranch(builder, components.get(0), request.getBranch(), request.getPullRequest(), session);
  249. return;
  250. }
  251. List<String> projectKeys = request.getProjectKeys();
  252. if (projectKeys != null) {
  253. List<ComponentDto> branchComponents = getComponentsFromKeys(session, projectKeys, request.getBranch(), request.getPullRequest());
  254. Set<String> projectUuids = retrieveProjectUuidsFromComponents(session, branchComponents);
  255. builder.projectUuids(projectUuids);
  256. setBranch(builder, branchComponents.get(0), request.getBranch(), request.getPullRequest(), session);
  257. }
  258. builder.directories(request.getDirectories());
  259. builder.files(request.getFiles());
  260. addComponentsBasedOnQualifier(builder, session, components, request);
  261. }
  262. @NotNull
  263. private Set<String> retrieveProjectUuidsFromComponents(DbSession session, List<ComponentDto> branchComponents) {
  264. Set<String> branchUuids = branchComponents.stream().map(ComponentDto::branchUuid).collect(Collectors.toSet());
  265. return dbClient.branchDao().selectByUuids(session, branchUuids).stream()
  266. .map(BranchDto::getProjectUuid)
  267. .collect(Collectors.toSet());
  268. }
  269. private void addComponentsBasedOnQualifier(IssueQuery.Builder builder, DbSession dbSession, List<ComponentDto> components, SearchRequest request) {
  270. if (components.isEmpty()) {
  271. return;
  272. }
  273. if (components.stream().map(ComponentDto::uuid).anyMatch(uuid -> uuid.equals(UNKNOWN))) {
  274. builder.componentUuids(singleton(UNKNOWN));
  275. return;
  276. }
  277. Set<String> qualifiers = components.stream().map(ComponentDto::qualifier).collect(Collectors.toSet());
  278. checkArgument(qualifiers.size() == 1, "All components must have the same qualifier, found %s", String.join(",", qualifiers));
  279. setBranch(builder, components.get(0), request.getBranch(), request.getPullRequest(), dbSession);
  280. String qualifier = qualifiers.iterator().next();
  281. switch (qualifier) {
  282. case Qualifiers.VIEW, Qualifiers.SUBVIEW:
  283. addViewsOrSubViews(builder, components);
  284. break;
  285. case Qualifiers.APP:
  286. addApplications(builder, dbSession, components, request);
  287. addProjectUuidsForApplication(builder, dbSession, request);
  288. break;
  289. case Qualifiers.PROJECT:
  290. builder.projectUuids(retrieveProjectUuidsFromComponents(dbSession, components));
  291. break;
  292. case Qualifiers.DIRECTORY:
  293. addDirectories(builder, components);
  294. break;
  295. case Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE:
  296. builder.componentUuids(components.stream().map(ComponentDto::uuid).toList());
  297. break;
  298. default:
  299. throw new IllegalArgumentException("Unable to set search root context for components " + Joiner.on(',').join(components));
  300. }
  301. }
  302. private BranchDto findComponentBranch(DbSession dbSession, ComponentDto componentDto) {
  303. Optional<BranchDto> optionalBranch = dbClient.branchDao().selectByUuid(dbSession, componentDto.branchUuid());
  304. checkArgument(optionalBranch.isPresent(), "All components must belong to a branch. This error may indicate corrupted data.");
  305. return optionalBranch.get();
  306. }
  307. private void addProjectUuidsForApplication(IssueQuery.Builder builder, DbSession session, SearchRequest request) {
  308. List<String> projectKeys = request.getProjectKeys();
  309. if (projectKeys != null) {
  310. // On application, branch should only be applied on the application, not on projects
  311. List<ComponentDto> appBranchComponents = getComponentsFromKeys(session, projectKeys, null, null);
  312. Set<String> appUuids = retrieveProjectUuidsFromComponents(session, appBranchComponents);
  313. builder.projectUuids(appUuids);
  314. }
  315. }
  316. private void addViewsOrSubViews(IssueQuery.Builder builder, Collection<ComponentDto> viewOrSubViewUuids) {
  317. List<String> filteredViewUuids = viewOrSubViewUuids.stream()
  318. .filter(uuid -> userSession.hasComponentPermission(USER, uuid))
  319. .map(ComponentDto::uuid)
  320. .collect(Collectors.toCollection(ArrayList::new));
  321. if (filteredViewUuids.isEmpty()) {
  322. filteredViewUuids.add(UNKNOWN);
  323. }
  324. builder.viewUuids(filteredViewUuids);
  325. }
  326. private void addApplications(IssueQuery.Builder builder, DbSession dbSession, List<ComponentDto> appBranchComponents, SearchRequest request) {
  327. Set<String> authorizedAppBranchUuids = appBranchComponents.stream()
  328. .filter(app -> userSession.hasComponentPermission(USER, app) && userSession.hasChildProjectsPermission(USER, app))
  329. .map(ComponentDto::uuid)
  330. .collect(Collectors.toSet());
  331. builder.viewUuids(authorizedAppBranchUuids.isEmpty() ? singleton(UNKNOWN) : authorizedAppBranchUuids);
  332. addCreatedAfterByProjects(builder, dbSession, request, authorizedAppBranchUuids);
  333. }
  334. private void addCreatedAfterByProjects(IssueQuery.Builder builder, DbSession dbSession, SearchRequest request, Set<String> appBranchUuids) {
  335. if (notInNewCodePeriod(request) || request.getPullRequest() != null) {
  336. return;
  337. }
  338. Set<String> projectBranchUuids = appBranchUuids.stream()
  339. .flatMap(app -> dbClient.componentDao().selectProjectBranchUuidsFromView(dbSession, app, app).stream())
  340. .collect(Collectors.toSet());
  341. List<SnapshotDto> snapshots = getLastAnalysis(dbSession, projectBranchUuids);
  342. Set<String> newCodeReferenceByProjects = snapshots
  343. .stream()
  344. .filter(s -> isLastAnalysisFromReAnalyzedReferenceBranch(dbSession, s))
  345. .map(SnapshotDto::getRootComponentUuid)
  346. .collect(Collectors.toSet());
  347. Map<String, PeriodStart> leakByProjects = snapshots
  348. .stream()
  349. .filter(s -> s.getPeriodDate() != null && !isLastAnalysisFromReAnalyzedReferenceBranch(dbSession, s))
  350. .collect(uniqueIndex(SnapshotDto::getRootComponentUuid, s -> new PeriodStart(longToDate(s.getPeriodDate()), false)));
  351. builder.createdAfterByProjectUuids(leakByProjects);
  352. builder.newCodeOnReferenceByProjectUuids(newCodeReferenceByProjects);
  353. }
  354. private boolean isLastAnalysisFromReAnalyzedReferenceBranch(DbSession dbSession, SnapshotDto snapshot) {
  355. return isLastAnalysisUsingReferenceBranch(snapshot) &&
  356. isLastAnalysisFromSonarQube94Onwards(dbSession, snapshot.getRootComponentUuid());
  357. }
  358. private static void addDirectories(IssueQuery.Builder builder, List<ComponentDto> directories) {
  359. Set<String> paths = directories.stream().map(ComponentDto::path).collect(Collectors.toSet());
  360. builder.directories(paths);
  361. }
  362. private List<ComponentDto> getComponentsFromKeys(DbSession dbSession, Collection<String> componentKeys, @Nullable String branch, @Nullable String pullRequest) {
  363. List<ComponentDto> componentDtos = dbClient.componentDao().selectByKeys(dbSession, componentKeys, branch, pullRequest);
  364. if (!componentKeys.isEmpty() && componentDtos.isEmpty()) {
  365. return singletonList(UNKNOWN_COMPONENT);
  366. }
  367. return componentDtos;
  368. }
  369. private List<ComponentDto> getComponentsFromUuids(DbSession dbSession, Collection<String> componentUuids) {
  370. List<ComponentDto> componentDtos = dbClient.componentDao().selectByUuids(dbSession, componentUuids);
  371. if (!componentUuids.isEmpty() && componentDtos.isEmpty()) {
  372. return singletonList(UNKNOWN_COMPONENT);
  373. }
  374. return componentDtos;
  375. }
  376. private Collection<RuleDto> ruleKeysToRuleId(DbSession dbSession, @Nullable Collection<String> rules) {
  377. if (rules != null) {
  378. return dbClient.ruleDao().selectByKeys(dbSession, transform(rules, RuleKey::parse));
  379. }
  380. return Collections.emptyList();
  381. }
  382. private void setBranch(IssueQuery.Builder builder, ComponentDto component, @Nullable String branch, @Nullable String pullRequest,
  383. DbSession session) {
  384. builder.branchUuid(branch == null && pullRequest == null ? null : component.branchUuid());
  385. if (UNKNOWN_COMPONENT.equals(component) || (pullRequest == null && branch == null)) {
  386. builder.mainBranch(true);
  387. } else {
  388. BranchDto branchDto = findComponentBranch(session, component);
  389. builder.mainBranch(branchDto.isMain());
  390. }
  391. }
  392. }