From: Antoine Vinot Date: Thu, 29 Sep 2022 08:11:41 +0000 (+0200) Subject: SONAR-17389 - Prevent project creation with existing key but different case X-Git-Tag: 9.7.0.61563~146 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6f85804537da5fb66a091458dfdef4bd12da2572;p=sonarqube.git SONAR-17389 - Prevent project creation with existing key but different case --- diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java index afaba3af0e2..b11d2801afd 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java @@ -241,6 +241,10 @@ public class ComponentDao implements Dao { return Optional.ofNullable(mapper(session).selectByKey(key)); } + public Optional selectByKeyCaseInsensitive(DbSession session, String key) { + return Optional.ofNullable(mapper(session).selectByKeyCaseInsensitive(key)); + } + public Optional selectByKeyAndBranch(DbSession session, String key, String branch) { return Optional.ofNullable(mapper(session).selectBranchByKeyAndBranchKey(key, generateBranchKey(key, branch), branch)); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java index 2d827bee828..e62a69a23b7 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java @@ -31,7 +31,10 @@ import org.apache.ibatis.session.RowBounds; public interface ComponentMapper { @CheckForNull - ComponentDto selectByKey(String key); + ComponentDto selectByKey(@Param("key") String key); + + @CheckForNull + ComponentDto selectByKeyCaseInsensitive(@Param("key") String key); @CheckForNull ComponentDto selectBranchByKeyAndBranchKey(@Param("key") String key, @Param("dbKey") String dbKey, @Param("branch") String branch); @@ -40,7 +43,7 @@ public interface ComponentMapper { ComponentDto selectPrByKeyAndBranchKey(@Param("key") String key, @Param("dbKey") String dbKey, @Param("branch") String branch); @CheckForNull - ComponentDto selectByUuid(String uuid); + ComponentDto selectByUuid(@Param("uuid") String uuid); /** * Return sub project of component keys diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml index 05d2e777fe1..aed19c345e9 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml @@ -32,6 +32,14 @@ p.kee=#{key,jdbcType=VARCHAR} + +