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.

BitbucketServerProjectCreatorFactory.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 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.common.almsettings.bitbucketserver;
  21. import java.util.Map;
  22. import java.util.Optional;
  23. import org.sonar.alm.client.bitbucketserver.BitbucketServerRestClient;
  24. import org.sonar.db.DbClient;
  25. import org.sonar.db.DbSession;
  26. import org.sonar.db.alm.setting.ALM;
  27. import org.sonar.db.alm.setting.AlmSettingDto;
  28. import org.sonar.server.common.almintegration.ProjectKeyGenerator;
  29. import org.sonar.server.common.almsettings.DevOpsProjectCreator;
  30. import org.sonar.server.common.almsettings.DevOpsProjectCreatorFactory;
  31. import org.sonar.server.common.almsettings.DevOpsProjectDescriptor;
  32. import org.sonar.server.common.project.ProjectCreator;
  33. import org.sonar.server.user.UserSession;
  34. public class BitbucketServerProjectCreatorFactory implements DevOpsProjectCreatorFactory {
  35. private final DbClient dbClient;
  36. private final UserSession userSession;
  37. private final BitbucketServerRestClient bitbucketServerRestClient;
  38. private final ProjectCreator projectCreator;
  39. private final ProjectKeyGenerator projectKeyGenerator;
  40. public BitbucketServerProjectCreatorFactory(DbClient dbClient, UserSession userSession,
  41. BitbucketServerRestClient bitbucketServerRestClient,
  42. ProjectCreator projectCreator, ProjectKeyGenerator projectKeyGenerator) {
  43. this.dbClient = dbClient;
  44. this.userSession = userSession;
  45. this.bitbucketServerRestClient = bitbucketServerRestClient;
  46. this.projectCreator = projectCreator;
  47. this.projectKeyGenerator = projectKeyGenerator;
  48. }
  49. @Override
  50. public Optional<DevOpsProjectCreator> getDevOpsProjectCreator(DbSession dbSession, Map<String, String> characteristics) {
  51. return Optional.empty();
  52. }
  53. @Override
  54. public Optional<DevOpsProjectCreator> getDevOpsProjectCreator(AlmSettingDto almSettingDto,
  55. DevOpsProjectDescriptor devOpsProjectDescriptor) {
  56. if (almSettingDto.getAlm() != ALM.BITBUCKET) {
  57. return Optional.empty();
  58. }
  59. return Optional.of(
  60. new BitbucketServerProjectCreator(
  61. almSettingDto,
  62. bitbucketServerRestClient,
  63. dbClient,
  64. devOpsProjectDescriptor,
  65. userSession,
  66. projectCreator,
  67. projectKeyGenerator));
  68. }
  69. }