aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-db-dao/src/main/java/org')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java8
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupDao.java64
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupDto.java39
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupMapper.java41
6 files changed, 156 insertions, 0 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 ccc02ce1b88..c3598e3b832 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
@@ -81,6 +81,7 @@ import org.sonar.db.rule.RuleDao;
import org.sonar.db.rule.RuleRepositoryDao;
import org.sonar.db.scannercache.ScannerAnalysisCacheDao;
import org.sonar.db.schemamigration.SchemaMigrationDao;
+import org.sonar.db.scim.ScimGroupDao;
import org.sonar.db.scim.ScimUserDao;
import org.sonar.db.source.FileSourceDao;
import org.sonar.db.user.GroupDao;
@@ -163,6 +164,7 @@ public class DaoModule extends Module {
SamlMessageIdDao.class,
ScannerAnalysisCacheDao.class,
SchemaMigrationDao.class,
+ ScimGroupDao.class,
ScimUserDao.class,
SnapshotDao.class,
SessionTokensDao.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 0caa22c4ac8..906edafaee2 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
@@ -81,6 +81,7 @@ import org.sonar.db.rule.RuleDao;
import org.sonar.db.rule.RuleRepositoryDao;
import org.sonar.db.scannercache.ScannerAnalysisCacheDao;
import org.sonar.db.schemamigration.SchemaMigrationDao;
+import org.sonar.db.scim.ScimGroupDao;
import org.sonar.db.scim.ScimUserDao;
import org.sonar.db.source.FileSourceDao;
import org.sonar.db.user.GroupDao;
@@ -174,6 +175,7 @@ public class DbClient {
private final ProjectBadgeTokenDao projectBadgeTokenDao;
private final ScannerAnalysisCacheDao scannerAnalysisCacheDao;
private final ScimUserDao scimUserDao;
+ private final ScimGroupDao scimGroupDao;
public DbClient(Database database, MyBatis myBatis, DBSessions dbSessions, Dao... daos) {
this.database = database;
@@ -257,6 +259,7 @@ public class DbClient {
applicationProjectsDao = getDao(map, ApplicationProjectsDao.class);
scannerAnalysisCacheDao = getDao(map, ScannerAnalysisCacheDao.class);
scimUserDao = getDao(map, ScimUserDao.class);
+ scimGroupDao = getDao(map, ScimGroupDao.class);
}
public DbSession openSession(boolean batch) {
@@ -568,4 +571,9 @@ public class DbClient {
public ScimUserDao scimUserDao() {
return scimUserDao;
}
+
+ public ScimGroupDao scimGroupDao() {
+ return scimGroupDao;
+ }
}
+
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 54647f71c9c..78dca8e791c 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
@@ -142,6 +142,7 @@ import org.sonar.db.rule.RuleRepositoryMapper;
import org.sonar.db.scannercache.ScannerAnalysisCacheMapper;
import org.sonar.db.schemamigration.SchemaMigrationDto;
import org.sonar.db.schemamigration.SchemaMigrationMapper;
+import org.sonar.db.scim.ScimGroupMapper;
import org.sonar.db.scim.ScimUserMapper;
import org.sonar.db.source.FileSourceMapper;
import org.sonar.db.user.GroupDto;
@@ -311,6 +312,7 @@ public class MyBatis {
SamlMessageIdMapper.class,
ScannerAnalysisCacheMapper.class,
SchemaMigrationMapper.class,
+ ScimGroupMapper.class,
ScimUserMapper.class,
SessionTokenMapper.class,
SnapshotMapper.class,
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupDao.java
new file mode 100644
index 00000000000..fad37c6c455
--- /dev/null
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupDao.java
@@ -0,0 +1,64 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.scim;
+
+import java.util.List;
+import java.util.Optional;
+import org.sonar.core.util.UuidFactory;
+import org.sonar.db.Dao;
+import org.sonar.db.DbSession;
+
+public class ScimGroupDao implements Dao {
+ private final UuidFactory uuidFactory;
+
+ public ScimGroupDao(UuidFactory uuidFactory) {
+ this.uuidFactory = uuidFactory;
+ }
+
+ public List<ScimGroupDto> findAll(DbSession dbSession) {
+ return mapper(dbSession).findAll();
+ }
+
+ public Optional<ScimGroupDto> findByScimUuid(DbSession dbSession, String scimGroupUuid) {
+ return Optional.ofNullable(mapper(dbSession).findByScimUuid(scimGroupUuid));
+ }
+
+ public Optional<ScimGroupDto> findByGroupUuid(DbSession dbSession, String groupUuid) {
+ return Optional.ofNullable(mapper(dbSession).findByGroupUuid(groupUuid));
+ }
+
+ public ScimGroupDto enableScimForGroup(DbSession dbSession, String groupUuid) {
+ ScimGroupDto scimGroupDto = new ScimGroupDto(uuidFactory.create(), groupUuid);
+ mapper(dbSession).insert(scimGroupDto);
+ return scimGroupDto;
+ }
+
+ public void deleteByGroupUuid(DbSession dbSession, String groupUuid) {
+ mapper(dbSession).deleteByGroupUuid(groupUuid);
+ }
+
+ public void deleteByScimUuid(DbSession dbSession, String scimUuid) {
+ mapper(dbSession).deleteByScimUuid(scimUuid);
+ }
+
+ private static ScimGroupMapper mapper(DbSession session) {
+ return session.getMapper(ScimGroupMapper.class);
+ }
+}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupDto.java
new file mode 100644
index 00000000000..961c53a3529
--- /dev/null
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupDto.java
@@ -0,0 +1,39 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.scim;
+
+public class ScimGroupDto {
+
+ private final String scimGroupUuid;
+ private final String groupUuid;
+
+ public ScimGroupDto(String scimGroupUuid, String groupUuid) {
+ this.scimGroupUuid = scimGroupUuid;
+ this.groupUuid = groupUuid;
+ }
+
+ public String getScimGroupUuid() {
+ return scimGroupUuid;
+ }
+
+ public String getGroupUuid() {
+ return groupUuid;
+ }
+}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupMapper.java
new file mode 100644
index 00000000000..538181eeae2
--- /dev/null
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/scim/ScimGroupMapper.java
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.scim;
+
+import java.util.List;
+import javax.annotation.CheckForNull;
+import org.apache.ibatis.annotations.Param;
+
+public interface ScimGroupMapper {
+
+ List<ScimGroupDto> findAll();
+
+ @CheckForNull
+ ScimGroupDto findByScimUuid(@Param("scimGroupUuid") String scimGroupUuid);
+
+ @CheckForNull
+ ScimGroupDto findByGroupUuid(@Param("groupUuid") String groupUuid);
+
+ void insert(@Param("scimGroupDto") ScimGroupDto scimGroupDto);
+
+ void deleteByGroupUuid(@Param("groupUuid") String groupUuid);
+
+ void deleteByScimUuid(@Param("scimUuid") String scimUuid);
+}