aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src/main/java/org/sonar
diff options
context:
space:
mode:
authorJacek <jacek.poreda@sonarsource.com>2020-12-21 11:29:10 +0100
committersonartech <sonartech@sonarsource.com>2020-12-22 20:09:38 +0000
commit967d9ad59cdf8f5c0f0dde3646f4dee950ec05bc (patch)
treebdc2f8bd7d326bf7e16fd14e67d021a397653428 /server/sonar-db-dao/src/main/java/org/sonar
parentd0c752f6fda84f9cd488532bd2bab6b9ec743950 (diff)
downloadsonarqube-967d9ad59cdf8f5c0f0dde3646f4dee950ec05bc.tar.gz
sonarqube-967d9ad59cdf8f5c0f0dde3646f4dee950ec05bc.zip
SONAR-13999 drop OrganizationAlmBinding class and related
Diffstat (limited to 'server/sonar-db-dao/src/main/java/org/sonar')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java14
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/alm/ALM.java35
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDao.java106
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDto.java132
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallMapper.java53
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmTesting.java29
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingDao.java97
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingDto.java138
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingMapper.java46
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java5
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationMapper.java3
13 files changed, 0 insertions, 666 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java
index 9baeac01d08..84799ca2387 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java
@@ -23,8 +23,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.sonar.core.platform.Module;
-import org.sonar.db.alm.AlmAppInstallDao;
-import org.sonar.db.alm.OrganizationAlmBindingDao;
import org.sonar.db.alm.pat.AlmPatDao;
import org.sonar.db.alm.setting.AlmSettingDao;
import org.sonar.db.alm.setting.ProjectAlmSettingDao;
@@ -121,7 +119,6 @@ public class DaoModule extends Module {
GroupDao.class,
GroupMembershipDao.class,
GroupPermissionDao.class,
- AlmAppInstallDao.class,
AlmSettingDao.class,
AlmPatDao.class,
ProjectAlmSettingDao.class,
@@ -134,7 +131,6 @@ public class DaoModule extends Module {
MetricDao.class,
NewCodePeriodDao.class,
NotificationQueueDao.class,
- OrganizationAlmBindingDao.class,
OrganizationDao.class,
PermissionTemplateCharacteristicDao.class,
PermissionTemplateDao.class,
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java
index b63d1085963..30f0536b259 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java
@@ -21,8 +21,6 @@ package org.sonar.db;
import java.util.IdentityHashMap;
import java.util.Map;
-import org.sonar.db.alm.AlmAppInstallDao;
-import org.sonar.db.alm.OrganizationAlmBindingDao;
import org.sonar.db.alm.pat.AlmPatDao;
import org.sonar.db.alm.setting.AlmSettingDao;
import org.sonar.db.alm.setting.ProjectAlmSettingDao;
@@ -103,7 +101,6 @@ public class DbClient {
private final QualityProfileDao qualityProfileDao;
private final QualityProfileExportDao qualityProfileExportDao;
private final PropertiesDao propertiesDao;
- private final AlmAppInstallDao almAppInstallDao;
private final AlmSettingDao almSettingDao;
private final AlmPatDao almPatDao;
private final ProjectAlmSettingDao projectAlmSettingDao;
@@ -159,7 +156,6 @@ public class DbClient {
private final WebhookDao webhookDao;
private final WebhookDeliveryDao webhookDeliveryDao;
private final ProjectMappingsDao projectMappingsDao;
- private final OrganizationAlmBindingDao organizationAlmBindingDao;
private final NewCodePeriodDao newCodePeriodDao;
private final ProjectDao projectDao;
private final SessionTokensDao sessionTokensDao;
@@ -176,7 +172,6 @@ public class DbClient {
for (Dao dao : daos) {
map.put(dao.getClass(), dao);
}
- almAppInstallDao = getDao(map, AlmAppInstallDao.class);
almSettingDao = getDao(map, AlmSettingDao.class);
almPatDao = getDao(map, AlmPatDao.class);
projectAlmSettingDao = getDao(map, ProjectAlmSettingDao.class);
@@ -237,7 +232,6 @@ public class DbClient {
webhookDao = getDao(map, WebhookDao.class);
webhookDeliveryDao = getDao(map, WebhookDeliveryDao.class);
projectMappingsDao = getDao(map, ProjectMappingsDao.class);
- organizationAlmBindingDao = getDao(map, OrganizationAlmBindingDao.class);
internalComponentPropertiesDao = getDao(map, InternalComponentPropertiesDao.class);
newCodePeriodDao = getDao(map, NewCodePeriodDao.class);
projectDao = getDao(map, ProjectDao.class);
@@ -255,10 +249,6 @@ public class DbClient {
return database;
}
- public AlmAppInstallDao almAppInstallDao() {
- return almAppInstallDao;
- }
-
public AlmSettingDao almSettingDao() {
return almSettingDao;
}
@@ -517,10 +507,6 @@ public class DbClient {
return projectMappingsDao;
}
- public OrganizationAlmBindingDao organizationAlmBindingDao() {
- return organizationAlmBindingDao;
- }
-
public InternalComponentPropertiesDao internalComponentPropertiesDao() {
return internalComponentPropertiesDao;
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
index c578a6b5028..42a3f7ae35f 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
@@ -34,8 +34,6 @@ import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.ibatis.session.TransactionIsolationLevel;
import org.sonar.api.Startable;
-import org.sonar.db.alm.AlmAppInstallMapper;
-import org.sonar.db.alm.OrganizationAlmBindingMapper;
import org.sonar.db.alm.pat.AlmPatMapper;
import org.sonar.db.alm.setting.AlmSettingMapper;
import org.sonar.db.alm.setting.ProjectAlmSettingMapper;
@@ -225,7 +223,6 @@ public class MyBatis implements Startable {
// keep them sorted alphabetically
Class<?>[] mappers = {
ActiveRuleMapper.class,
- AlmAppInstallMapper.class,
AlmPatMapper.class,
AlmSettingMapper.class,
AnalysisPropertiesMapper.class,
@@ -260,7 +257,6 @@ public class MyBatis implements Startable {
MetricMapper.class,
NewCodePeriodMapper.class,
NotificationQueueMapper.class,
- OrganizationAlmBindingMapper.class,
OrganizationMapper.class,
PermissionTemplateCharacteristicMapper.class,
PermissionTemplateMapper.class,
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/ALM.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/ALM.java
deleted file mode 100644
index 12dc7fd0d03..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/ALM.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.alm;
-
-import java.util.Locale;
-
-public enum ALM {
- BITBUCKETCLOUD,
- GITHUB;
-
- public static ALM fromId(String almId) {
- return ALM.valueOf(almId.toUpperCase(Locale.ENGLISH));
- }
-
- public String getId() {
- return this.name().toLowerCase(Locale.ENGLISH);
- }
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDao.java
deleted file mode 100644
index c56a80a7404..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDao.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.alm;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-import javax.annotation.Nullable;
-import org.sonar.api.utils.System2;
-import org.sonar.core.util.UuidFactory;
-import org.sonar.db.Dao;
-import org.sonar.db.DbSession;
-import org.sonar.db.organization.OrganizationDto;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.Objects.requireNonNull;
-import static org.apache.commons.lang.StringUtils.isNotEmpty;
-import static org.sonar.db.DatabaseUtils.executeLargeInputs;
-
-/**
- * Store instances of installed app in external ALM like GitHub or Bitbucket Cloud.
- */
-public class AlmAppInstallDao implements Dao {
-
- private final System2 system2;
- private final UuidFactory uuidFactory;
-
- public AlmAppInstallDao(System2 system2, UuidFactory uuidFactory) {
- this.system2 = system2;
- this.uuidFactory = uuidFactory;
- }
-
- public Optional<AlmAppInstallDto> selectByUuid(DbSession dbSession, String uuid) {
- AlmAppInstallMapper mapper = getMapper(dbSession);
- return Optional.ofNullable(mapper.selectByUuid(uuid));
- }
-
- public Optional<AlmAppInstallDto> selectByOrganizationAlmId(DbSession dbSession, ALM alm, String organizationAlmId) {
- checkAlm(alm);
- checkOrganizationAlmId(organizationAlmId);
-
- AlmAppInstallMapper mapper = getMapper(dbSession);
- return Optional.ofNullable(mapper.selectByOrganizationAlmId(alm.getId(), organizationAlmId));
- }
-
- public Optional<AlmAppInstallDto> selectByOrganization(DbSession dbSession, OrganizationDto organization) {
- AlmAppInstallMapper mapper = getMapper(dbSession);
- return Optional.ofNullable(mapper.selectByOrganizationUuid(organization.getUuid()));
- }
-
- public List<AlmAppInstallDto> selectByOrganizations(DbSession dbSession, List<OrganizationDto> organizations) {
- Set<String> organizationUuids = organizations.stream().map(OrganizationDto::getUuid).collect(Collectors.toSet());
- return executeLargeInputs(organizationUuids, uuids -> getMapper(dbSession).selectByOrganizationUuids(uuids));
- }
-
- public void insertOrUpdate(DbSession dbSession, ALM alm, String organizationAlmId, @Nullable Boolean isOwnerUser, String installId, @Nullable String userExternalId) {
- checkAlm(alm);
- checkOrganizationAlmId(organizationAlmId);
- checkArgument(isNotEmpty(installId), "installId can't be null nor empty");
-
- AlmAppInstallMapper mapper = getMapper(dbSession);
- long now = system2.now();
-
- if (mapper.update(alm.getId(), organizationAlmId, isOwnerUser, installId, userExternalId, now) == 0) {
- mapper.insert(uuidFactory.create(), alm.getId(), organizationAlmId, isOwnerUser, installId, userExternalId, now);
- }
- }
-
- public void delete(DbSession dbSession, ALM alm, String organizationAlmId) {
- checkAlm(alm);
- checkOrganizationAlmId(organizationAlmId);
-
- AlmAppInstallMapper mapper = getMapper(dbSession);
- mapper.delete(alm.getId(), organizationAlmId);
- }
-
- private static void checkAlm(@Nullable ALM alm) {
- requireNonNull(alm, "alm can't be null");
- }
-
- private static void checkOrganizationAlmId(@Nullable String organizationAlmId) {
- checkArgument(isNotEmpty(organizationAlmId), "organizationAlmId can't be null nor empty");
- }
-
- private static AlmAppInstallMapper getMapper(DbSession dbSession) {
- return dbSession.getMapper(AlmAppInstallMapper.class);
- }
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDto.java
deleted file mode 100644
index 486a0b68078..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDto.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.alm;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-public class AlmAppInstallDto {
-
- /**
- * Technical unique identifier, can't be null
- */
- private String uuid;
- /**
- * Identifier of the ALM, like 'bitbucketcloud' or 'github', can't be null.
- * Note that the db column is named alm_id.
- *
- * @see ALM for the list of available values
- */
- private String rawAlm;
- /**
- * ALM specific identifier of the organization, like team or user uuid for Bitbucket Cloud or organization id for Github, can't be null.
- * Note that the column is badly named owner_id, in the first place it was only possible to install personal organizations.
- * The column name has been kept to prevent doing a db migration.
- */
- private String organizationAlmId;
- /**
- * ALM specific identifier of the app installation, can't be null
- */
- private String installId;
- /**
- * Is owner a user, can be null
- */
- private Boolean isOwnerUser;
- /**
- * The user ID provided by the ALM of the user who has installed the ALM installation. Can be null as some ALM doesn't provide this info. Max size is 255.
- */
- private String userExternalId;
-
- private long createdAt;
- private long updatedAt;
-
- public String getUuid() {
- return uuid;
- }
-
- public AlmAppInstallDto setUuid(String uuid) {
- this.uuid = uuid;
- return this;
- }
-
- public ALM getAlm() {
- return ALM.fromId(rawAlm);
- }
-
- public AlmAppInstallDto setAlm(ALM alm) {
- this.rawAlm = alm.getId();
- return this;
- }
-
- public String getOrganizationAlmId() {
- return organizationAlmId;
- }
-
- public AlmAppInstallDto setOrganizationAlmId(String organizationAlmId) {
- this.organizationAlmId = organizationAlmId;
- return this;
- }
-
- public String getInstallId() {
- return installId;
- }
-
- public AlmAppInstallDto setInstallId(String installId) {
- this.installId = installId;
- return this;
- }
-
- public boolean isOwnerUser() {
- return isOwnerUser;
- }
-
- public AlmAppInstallDto setIsOwnerUser(boolean isOwnerUser) {
- this.isOwnerUser = isOwnerUser;
- return this;
- }
-
- @CheckForNull
- public String getUserExternalId() {
- return userExternalId;
- }
-
- public AlmAppInstallDto setUserExternalId(@Nullable String userExternalId) {
- this.userExternalId = userExternalId;
- return this;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- AlmAppInstallDto setCreatedAt(long createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- public long getUpdatedAt() {
- return updatedAt;
- }
-
- AlmAppInstallDto setUpdatedAt(long updatedAt) {
- this.updatedAt = updatedAt;
- return this;
- }
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallMapper.java
deleted file mode 100644
index 0d83728b238..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallMapper.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.alm;
-
-import java.util.Collection;
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import org.apache.ibatis.annotations.Param;
-
-public interface AlmAppInstallMapper {
-
- @CheckForNull
- AlmAppInstallDto selectByOrganizationAlmId(@Param("alm") String alm, @Param("organizationAlmId") String organizationAlmId);
-
- @CheckForNull
- AlmAppInstallDto selectByInstallationId(@Param("alm") String alm, @Param("installId") String installId);
-
- @CheckForNull
- AlmAppInstallDto selectByUuid(@Param("uuid") String uuid);
-
- @CheckForNull
- AlmAppInstallDto selectByOrganizationUuid(@Param("organizationUuid") String organizationUuid);
-
- List<AlmAppInstallDto> selectUnboundByUserExternalId(@Param("userExternalId") String userExternalId);
-
- void insert(@Param("uuid") String uuid, @Param("alm") String alm, @Param("organizationAlmId") String organizationAlmId,
- @Nullable @Param("isOwnerUser") Boolean isOwnerUser, @Param("installId") String installId, @Nullable @Param("userExternalId") String userExternalId, @Param("now") long now);
-
- int update(@Param("alm") String alm, @Param("organizationAlmId") String organizationAlmId,
- @Nullable @Param("isOwnerUser") Boolean isOwnerUser, @Param("installId") String installId, @Nullable @Param("userExternalId") String userExternalId, @Param("now") long now);
-
- void delete(@Param("alm") String alm, @Param("organizationAlmId") String organizationAlmId);
-
- List<AlmAppInstallDto> selectByOrganizationUuids(@Param("organizationUuids") Collection<String> organizationUuids);
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmTesting.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmTesting.java
deleted file mode 100644
index 0f142ff9a14..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmTesting.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.alm;
-
-public class AlmTesting {
-
- private AlmTesting() {
- // only statics
- }
-
-
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingDao.java
deleted file mode 100644
index 421ec3a45e7..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingDao.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.alm;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Optional;
-import org.sonar.api.utils.System2;
-import org.sonar.core.util.UuidFactory;
-import org.sonar.db.Dao;
-import org.sonar.db.DbSession;
-import org.sonar.db.organization.OrganizationDto;
-
-import static java.util.Optional.ofNullable;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
-import static org.sonar.db.DatabaseUtils.executeLargeInputs;
-
-public class OrganizationAlmBindingDao implements Dao {
-
- private final System2 system2;
- private final UuidFactory uuidFactory;
-
- public OrganizationAlmBindingDao(System2 system2, UuidFactory uuidFactory) {
- this.system2 = system2;
- this.uuidFactory = uuidFactory;
- }
-
- public Optional<OrganizationAlmBindingDto> selectByOrganization(DbSession dbSession, OrganizationDto organization) {
- return selectByOrganizationUuid(dbSession, organization.getUuid());
- }
-
- public Optional<OrganizationAlmBindingDto> selectByOrganizationUuid(DbSession dbSession, String organizationUuid) {
- return ofNullable(getMapper(dbSession).selectByOrganizationUuid(organizationUuid));
- }
-
- public List<OrganizationAlmBindingDto> selectByOrganizations(DbSession dbSession, Collection<OrganizationDto> organizations) {
- return selectByOrganizationUuids(dbSession, organizations.stream().map(OrganizationDto::getUuid).collect(toSet()));
- }
-
- public List<OrganizationAlmBindingDto> selectByOrganizationUuids(DbSession dbSession, Collection<String> organizationUuids) {
- return executeLargeInputs(organizationUuids, uuids -> getMapper(dbSession).selectByOrganizationUuids(uuids));
- }
-
- public Optional<OrganizationAlmBindingDto> selectByAlmAppInstall(DbSession dbSession, AlmAppInstallDto almAppInstall) {
- return ofNullable(getMapper(dbSession).selectByInstallationUuid(almAppInstall.getUuid()));
- }
-
- public List<OrganizationAlmBindingDto> selectByOrganizationAlmIds(DbSession dbSession, ALM alm, Collection<String> organizationAlmIds) {
- return executeLargeInputs(organizationAlmIds, o -> getMapper(dbSession).selectByOrganizationAlmIds(alm.getId(), o));
- }
-
- public void insert(DbSession dbSession, OrganizationDto organization, AlmAppInstallDto almAppInstall, String url, String userUuid, boolean membersSync) {
- long now = system2.now();
- getMapper(dbSession).insert(new OrganizationAlmBindingDto()
- .setUuid(uuidFactory.create())
- .setOrganizationUuid(organization.getUuid())
- .setAlmAppInstallUuid(almAppInstall.getUuid())
- .setAlmId(almAppInstall.getAlm())
- .setUrl(url)
- .setUserUuid(userUuid)
- .setMembersSyncEnabled(membersSync)
- .setCreatedAt(now));
- }
-
- public void deleteByOrganization(DbSession dbSession, OrganizationDto organization) {
- getMapper(dbSession).deleteByOrganizationUuid(organization.getUuid());
- }
-
- public void deleteByAlmAppInstall(DbSession dbSession, AlmAppInstallDto almAppInstall) {
- getMapper(dbSession).deleteByAlmAppInstallUuid(almAppInstall.getUuid());
- }
-
- public void updateMembersSync(DbSession dbSession, OrganizationAlmBindingDto orgAlmBinding, boolean enabled) {
- getMapper(dbSession).updateMembersSync(orgAlmBinding.getUuid(), enabled);
- }
-
- private static OrganizationAlmBindingMapper getMapper(DbSession dbSession) {
- return dbSession.getMapper(OrganizationAlmBindingMapper.class);
- }
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingDto.java
deleted file mode 100644
index 7f851286934..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingDto.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.alm;
-
-import java.util.Arrays;
-
-/**
- * This DTO is used to link an {@link org.sonar.db.organization.OrganizationDto} to a {@link AlmAppInstallDto}
- */
-public class OrganizationAlmBindingDto {
-
- /**
- * Not empty. Max size is 40. Obviously it is unique.
- */
- private String uuid;
- /**
- * The UUID of the organization. Can't be null. Max size is 40.
- * It's unique, as an organization is only linked to one installation (at least for the moment).
- */
- private String organizationUuid;
- /**
- * The UUID of ALM installation. Can't be null. Max size is 40.
- * It's unique, as an installation is related to only one organization.
- */
- private String almAppInstallUuid;
- /**
- * The id of the ALM. Can't be null. Max size is 40.
- */
- private String rawAlmId;
- /**
- * The url of the ALM organization. Can't be null. Max size is 2000.
- */
- private String url;
- /**
- * The UUID of the user who has created the link between the organization and the ALM installation. Can't be null. Max size is 255.
- */
- private String userUuid;
- /**
- * If the members of the org are automatically sync with the ALM org
- */
- private boolean membersSyncEnabled;
- /**
- * Technical creation date
- */
- private long createdAt;
-
- public String getUuid() {
- return uuid;
- }
-
- OrganizationAlmBindingDto setUuid(String uuid) {
- this.uuid = uuid;
- return this;
- }
-
- public String getOrganizationUuid() {
- return organizationUuid;
- }
-
- public OrganizationAlmBindingDto setOrganizationUuid(String organizationUuid) {
- this.organizationUuid = organizationUuid;
- return this;
- }
-
- public String getAlmAppInstallUuid() {
- return almAppInstallUuid;
- }
-
- public OrganizationAlmBindingDto setAlmAppInstallUuid(String almAppInstallUuid) {
- this.almAppInstallUuid = almAppInstallUuid;
- return this;
- }
-
- public ALM getAlm() {
- return Arrays.stream(ALM.values())
- .filter(a -> a.getId().equals(rawAlmId))
- .findAny()
- .orElseThrow(() -> new IllegalStateException("ALM id " + rawAlmId + " is invalid"));
- }
-
- public OrganizationAlmBindingDto setAlmId(ALM alm) {
- this.rawAlmId = alm.getId();
- return this;
- }
-
- public String getUrl() {
- return url;
- }
-
- public OrganizationAlmBindingDto setUrl(String url) {
- this.url = url;
- return this;
- }
-
- public String getUserUuid() {
- return userUuid;
- }
-
- public OrganizationAlmBindingDto setUserUuid(String userUuid) {
- this.userUuid = userUuid;
- return this;
- }
-
- public boolean isMembersSyncEnable() {
- return membersSyncEnabled;
- }
-
- public OrganizationAlmBindingDto setMembersSyncEnabled(boolean membersSyncEnabled) {
- this.membersSyncEnabled = membersSyncEnabled;
- return this;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- OrganizationAlmBindingDto setCreatedAt(long createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingMapper.java
deleted file mode 100644
index 1ef4b91850a..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingMapper.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.alm;
-
-import java.util.Collection;
-import java.util.List;
-import javax.annotation.CheckForNull;
-import org.apache.ibatis.annotations.Param;
-
-public interface OrganizationAlmBindingMapper {
-
- @CheckForNull
- OrganizationAlmBindingDto selectByOrganizationUuid(@Param("organizationUuid") String organizationUuid);
-
- List<OrganizationAlmBindingDto> selectByOrganizationUuids(@Param("organizationUuids") Collection<String> organizationUuids);
-
- @CheckForNull
- OrganizationAlmBindingDto selectByInstallationUuid(@Param("installationUuid") String installationUuid);
-
- List<OrganizationAlmBindingDto> selectByOrganizationAlmIds(@Param("alm") String alm, @Param("organizationAlmIds") List<String> organizationAlmId);
-
- void insert(@Param("dto") OrganizationAlmBindingDto dto);
-
- void deleteByOrganizationUuid(@Param("organizationUuid") String organizationUuid);
-
- void deleteByAlmAppInstallUuid(@Param("almAppInstallUuid") String almAppInstallUuid);
-
- void updateMembersSync(@Param("uuid") String uuid, @Param("membersSyncEnabled") boolean membersSyncEnabled);
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java
index 8a71d78a42e..af5e2bed102 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java
@@ -27,7 +27,6 @@ import org.sonar.api.utils.System2;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
import org.sonar.db.Pagination;
-import org.sonar.db.alm.ALM;
import org.sonar.db.component.BranchType;
import org.sonar.db.permission.template.DefaultTemplates;
import org.sonar.db.property.InternalPropertiesDao;
@@ -97,10 +96,6 @@ public class OrganizationDao implements Dao {
return getMapper(dbSession).selectByPermission(userUuid, permission);
}
- public Optional<OrganizationDto> selectByOrganizationAlmId(DbSession dbSession, ALM alm, String organizationAlmId) {
- return Optional.ofNullable(getMapper(dbSession).selectByOrganizationAlmId(alm.getId(), organizationAlmId));
- }
-
public List<String> selectAllUuids(DbSession dbSession) {
return getMapper(dbSession).selectAllUuids();
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationMapper.java
index defe27ba197..24708e10d2d 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationMapper.java
@@ -40,9 +40,6 @@ public interface OrganizationMapper {
@CheckForNull
OrganizationDto selectByUuid(@Param("uuid") String uuid);
- @CheckForNull
- OrganizationDto selectByOrganizationAlmId(@Param("alm") String alm, @Param("organizationAlmId") String organizationAlmId);
-
List<OrganizationDto> selectByUuids(@Param("uuids") List<String> uuids);
List<OrganizationDto> selectByPermission(@Param("userUuid") String userUuid, @Param("permission") String permission);