From 888b5bc305ac0483d4691e0dcd0c8c82a24b2eea Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Sun, 2 Dec 2018 15:53:17 +0100 Subject: [PATCH] SONARCLOUD-220 add WS api/autoscan/github_repository --- .../java/org/sonar/db/alm/AlmAppInstallDao.java | 7 +++++++ .../java/org/sonar/db/alm/AlmAppInstallMapper.java | 3 +++ .../org/sonar/db/alm/AlmAppInstallMapper.xml | 12 +++++++++++- .../org/sonar/db/alm/AlmAppInstallDaoTest.java | 14 ++++++++++++++ .../CredentialsExternalAuthentication.java | 4 ++-- 5 files changed, 37 insertions(+), 3 deletions(-) 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 index 63a6846f8a4..6629c36a226 100644 --- 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 @@ -26,6 +26,7 @@ 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; @@ -62,6 +63,12 @@ public class AlmAppInstallDao implements Dao { return Optional.ofNullable(mapper.selectByInstallationId(alm.getId(), installationId)); } + public Optional selectByOrganization(DbSession dbSession, ALM alm, OrganizationDto organization) { + AlmAppInstallMapper mapper = getMapper(dbSession); + return Optional.ofNullable(mapper.selectByOrganizationUuid(alm.getId(), organization.getUuid())); + } + + public List selectUnboundByUserExternalId(DbSession dbSession, String userExternalId) { return getMapper(dbSession).selectUnboundByUserExternalId(userExternalId); } 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 index 11668864c4e..637626a24f9 100644 --- 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 @@ -35,6 +35,9 @@ public interface AlmAppInstallMapper { @CheckForNull AlmAppInstallDto selectByUuid(@Param("uuid") String uuid); + @CheckForNull + AlmAppInstallDto selectByOrganizationUuid(@Param("almId") String almId, @Param("organizationUuid") String organizationUuid); + List selectUnboundByUserExternalId(@Param("userExternalId") String userExternalId); void insert(@Param("uuid") String uuid, @Param("almId") String almId, @Param("ownerId") String ownerId, diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/AlmAppInstallMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/AlmAppInstallMapper.xml index fbfb720b866..b29b7ec7268 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/AlmAppInstallMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/AlmAppInstallMapper.xml @@ -40,11 +40,21 @@ uuid = #{uuid, jdbcType=VARCHAR} + +