aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-db-dao')
-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.java7
-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/component/ComponentDao.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java22
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java10
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java25
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java166
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDto.java217
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationHelper.java47
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationMapper.java82
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationQuery.java98
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationWithNclocDto.java63
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/organization/package-info.java24
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/permission/GroupPermissionDao.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java14
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java3
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesMapper.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/user/GroupDao.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java5
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDao.java28
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDto.java13
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookMapper.java8
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/component/ApplicationProjectsMapper.xml1
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml18
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml33
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/organization/OrganizationMapper.xml284
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml3
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/webhook/WebhookMapper.xml16
-rw-r--r--server/sonar-db-dao/src/schema/schema-sq.ddl71
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java6
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ApplicationProjectsDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java11
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java8
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java16
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/project/ProjectDaoTest.java39
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java64
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java42
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java25
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoTest.java22
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java72
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java21
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java54
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/qualityprofile/QualityProfileDbTester.java4
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleDbTester.java1
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java2
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java4
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/webhook/WebhookDbTester.java3
56 files changed, 117 insertions, 1573 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 f0908233f50..fd1b10d8755 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
@@ -52,7 +52,6 @@ import org.sonar.db.measure.custom.CustomMeasureDao;
import org.sonar.db.metric.MetricDao;
import org.sonar.db.newcodeperiod.NewCodePeriodDao;
import org.sonar.db.notification.NotificationQueueDao;
-import org.sonar.db.organization.OrganizationDao;
import org.sonar.db.permission.AuthorizationDao;
import org.sonar.db.permission.GroupPermissionDao;
import org.sonar.db.permission.UserPermissionDao;
@@ -131,7 +130,6 @@ public class DaoModule extends Module {
MetricDao.class,
NewCodePeriodDao.class,
NotificationQueueDao.class,
- OrganizationDao.class,
PermissionTemplateCharacteristicDao.class,
PermissionTemplateDao.class,
PluginDao.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 2be6d87d0c6..d856c50465a 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
@@ -50,7 +50,6 @@ import org.sonar.db.measure.custom.CustomMeasureDao;
import org.sonar.db.metric.MetricDao;
import org.sonar.db.newcodeperiod.NewCodePeriodDao;
import org.sonar.db.notification.NotificationQueueDao;
-import org.sonar.db.organization.OrganizationDao;
import org.sonar.db.permission.AuthorizationDao;
import org.sonar.db.permission.GroupPermissionDao;
import org.sonar.db.permission.UserPermissionDao;
@@ -97,7 +96,6 @@ public class DbClient {
private final SchemaMigrationDao schemaMigrationDao;
private final AuthorizationDao authorizationDao;
- private final OrganizationDao organizationDao;
private final QualityProfileDao qualityProfileDao;
private final QualityProfileExportDao qualityProfileExportDao;
private final PropertiesDao propertiesDao;
@@ -177,7 +175,6 @@ public class DbClient {
projectAlmSettingDao = getDao(map, ProjectAlmSettingDao.class);
schemaMigrationDao = getDao(map, SchemaMigrationDao.class);
authorizationDao = getDao(map, AuthorizationDao.class);
- organizationDao = getDao(map, OrganizationDao.class);
qualityProfileDao = getDao(map, QualityProfileDao.class);
qualityProfileExportDao = getDao(map, QualityProfileExportDao.class);
propertiesDao = getDao(map, PropertiesDao.class);
@@ -273,10 +270,6 @@ public class DbClient {
return authorizationDao;
}
- public OrganizationDao organizationDao() {
- return organizationDao;
- }
-
public IssueDao issueDao() {
return issueDao;
}
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 ed458686e36..f25e7820ece 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
@@ -83,8 +83,6 @@ import org.sonar.db.metric.MetricMapper;
import org.sonar.db.newcodeperiod.NewCodePeriodMapper;
import org.sonar.db.notification.NotificationQueueDto;
import org.sonar.db.notification.NotificationQueueMapper;
-import org.sonar.db.organization.OrganizationDto;
-import org.sonar.db.organization.OrganizationMapper;
import org.sonar.db.permission.AuthorizationMapper;
import org.sonar.db.permission.GroupPermissionDto;
import org.sonar.db.permission.GroupPermissionMapper;
@@ -191,7 +189,6 @@ public class MyBatis implements Startable {
confBuilder.loadAlias("Issue", IssueDto.class);
confBuilder.loadAlias("Measure", MeasureDto.class);
confBuilder.loadAlias("NotificationQueue", NotificationQueueDto.class);
- confBuilder.loadAlias("Organization", OrganizationDto.class);
confBuilder.loadAlias("PermissionTemplateCharacteristic", PermissionTemplateCharacteristicDto.class);
confBuilder.loadAlias("PermissionTemplateGroup", PermissionTemplateGroupDto.class);
confBuilder.loadAlias("PermissionTemplate", PermissionTemplateDto.class);
@@ -257,7 +254,6 @@ public class MyBatis implements Startable {
MetricMapper.class,
NewCodePeriodMapper.class,
NotificationQueueMapper.class,
- OrganizationMapper.class,
PermissionTemplateCharacteristicMapper.class,
PermissionTemplateMapper.class,
PluginMapper.class,
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 19c9e47da9b..5495ad09c36 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
@@ -359,8 +359,8 @@ public class ComponentDao implements Dao {
checkThatNotTooManyConditions(query.getComponentUuids(), "Too many component UUIDs in query");
}
- public List<ProjectNclocDistributionDto> selectPrivateProjectsWithNcloc(DbSession dbSession, String organizationUuid) {
- return mapper(dbSession).selectPrivateProjectsWithNcloc(organizationUuid);
+ public List<ProjectNclocDistributionDto> selectPrivateProjectsWithNcloc(DbSession dbSession) {
+ return mapper(dbSession).selectPrivateProjectsWithNcloc();
}
public boolean existAnyOfComponentsWithQualifiers(DbSession session, Collection<String> componentKeys, Set<String> qualifiers) {
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java
index 35d20994f99..0f491d7f96a 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java
@@ -23,6 +23,7 @@ import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import java.util.Date;
import java.util.List;
+import java.util.Objects;
import java.util.regex.Pattern;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
@@ -55,11 +56,6 @@ public class ComponentDto {
private static final Splitter UUID_PATH_SPLITTER = Splitter.on(UUID_PATH_SEPARATOR).omitEmptyStrings();
/**
- * The UUID of the organization the component belongs to. Can't be null in DB.
- */
- private String organizationUuid;
-
- /**
* Non-empty and unique functional key. Do not rename, used by MyBatis.
*/
private String kee;
@@ -156,19 +152,6 @@ public class ComponentDto {
return buildLikeValue(formatUuidPathFromParent(this), WildcardPosition.AFTER);
}
- // TODO remove after getting rid of organization code
- @Deprecated
- public String getOrganizationUuid() {
- return organizationUuid;
- }
-
- // TODO remove after getting rid of organization code
- @Deprecated
- public ComponentDto setOrganizationUuid(String organizationUuid) {
- this.organizationUuid = organizationUuid;
- return this;
- }
-
public String uuid() {
return uuid;
}
@@ -409,7 +392,7 @@ public class ComponentDto {
return false;
}
ComponentDto that = (ComponentDto) o;
- return uuid != null ? uuid.equals(that.uuid) : (that.uuid == null);
+ return Objects.equals(uuid, that.uuid);
}
@@ -444,7 +427,6 @@ public class ComponentDto {
public ComponentDto copy() {
ComponentDto copy = new ComponentDto();
copy.projectUuid = projectUuid;
- copy.organizationUuid = organizationUuid;
copy.kee = kee;
copy.uuid = uuid;
copy.uuidPath = uuidPath;
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 d7de5ca6127..aea46f11177 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
@@ -63,14 +63,6 @@ public interface ComponentMapper {
int countEnabledModulesByProjectUuid(@Param("projectUuid") String projectUuid);
- /**
- * Counts the number of components with the specified id belonging to the specified organization.
- *
- * @return 1 or 0. Either because the organization uuid is not the one of the component or because the component does
- * not exist.
- */
- int countComponentByOrganizationAndUuid(@Param("organizationUuid") String organizationUuid, @Param("componentUuid") String componentUuid);
-
List<ComponentDto> selectByQuery(@Param("query") ComponentQuery query, RowBounds rowBounds);
int countByQuery(@Param("query") ComponentQuery query);
@@ -149,7 +141,7 @@ public interface ComponentMapper {
List<KeyWithUuidDto> selectAllSiblingComponentKeysHavingOpenIssues(@Param("referenceBranchUuid") String referenceBranchUuid,
@Param("currentBranchUuid") String currentBranchUuid);
- List<ProjectNclocDistributionDto> selectPrivateProjectsWithNcloc(@Param("organizationUuid") String organizationUuid);
+ List<ProjectNclocDistributionDto> selectPrivateProjectsWithNcloc();
List<ComponentWithModuleUuidDto> selectEnabledComponentsWithModuleUuidFromProjectKey(String projectKey);
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java
index 262930ff75b..3f69fe402e8 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java
@@ -72,7 +72,7 @@ public class ProjectMeasuresIndexerIterator extends CloseableIterator<ProjectMea
CoreMetrics.NEW_LINES_KEY,
CoreMetrics.NEW_RELIABILITY_RATING_KEY);
- private static final String SQL_PROJECTS = "SELECT p.organization_uuid, p.uuid, p.kee, p.name, s.created_at, p.tags, p.qualifier " +
+ private static final String SQL_PROJECTS = "SELECT p.uuid, p.kee, p.name, s.created_at, p.tags, p.qualifier " +
"FROM projects p " +
"LEFT OUTER JOIN snapshots s ON s.component_uuid=p.uuid AND s.islast=? " +
"WHERE p.qualifier in (?, ?)";
@@ -110,14 +110,13 @@ public class ProjectMeasuresIndexerIterator extends CloseableIterator<ProjectMea
try (PreparedStatement stmt = createProjectsStatement(session, projectUuid);
ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
- String orgUuid = rs.getString(1);
- String uuid = rs.getString(2);
- String key = rs.getString(3);
- String name = rs.getString(4);
- Long analysisDate = DatabaseUtils.getLong(rs, 5);
- List<String> tags = readDbTags(DatabaseUtils.getString(rs, 6));
- String qualifier = rs.getString(7);
- Project project = new Project(orgUuid, uuid, key, name, qualifier, tags, analysisDate);
+ String uuid = rs.getString(1);
+ String key = rs.getString(2);
+ String name = rs.getString(3);
+ Long analysisDate = DatabaseUtils.getLong(rs, 4);
+ List<String> tags = readDbTags(DatabaseUtils.getString(rs, 5));
+ String qualifier = rs.getString(6);
+ Project project = new Project(uuid, key, name, qualifier, tags, analysisDate);
projects.add(project);
}
return projects;
@@ -228,7 +227,6 @@ public class ProjectMeasuresIndexerIterator extends CloseableIterator<ProjectMea
}
public static class Project {
- private final String organizationUuid;
private final String uuid;
private final String key;
private final String name;
@@ -236,8 +234,7 @@ public class ProjectMeasuresIndexerIterator extends CloseableIterator<ProjectMea
private final Long analysisDate;
private final List<String> tags;
- public Project(String organizationUuid, String uuid, String key, String name, String qualifier, List<String> tags, @Nullable Long analysisDate) {
- this.organizationUuid = organizationUuid;
+ public Project(String uuid, String key, String name, String qualifier, List<String> tags, @Nullable Long analysisDate) {
this.uuid = uuid;
this.key = key;
this.name = name;
@@ -246,10 +243,6 @@ public class ProjectMeasuresIndexerIterator extends CloseableIterator<ProjectMea
this.analysisDate = analysisDate;
}
- public String getOrganizationUuid() {
- return organizationUuid;
- }
-
public String getUuid() {
return uuid;
}
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
deleted file mode 100644
index a66a0b0b3d4..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.organization;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-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.component.BranchType;
-import org.sonar.db.permission.template.DefaultTemplates;
-import org.sonar.db.property.InternalPropertiesDao;
-import org.sonar.db.user.GroupDto;
-
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
-import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
-import static org.sonar.db.DatabaseUtils.executeLargeInputs;
-import static org.sonar.db.DatabaseUtils.executeLargeUpdates;
-
-public class OrganizationDao implements Dao {
- /**
- * The UUID of the default organization.
- * Can't be null unless SQ is strongly corrupted.
- */
- public static final String DEFAULT_ORGANIZATION = "organization.default";
-
- private final System2 system2;
- private final InternalPropertiesDao internalPropertiesDao;
-
- public OrganizationDao(System2 system2, InternalPropertiesDao internalPropertiesDao) {
- this.system2 = system2;
- this.internalPropertiesDao = internalPropertiesDao;
- }
-
- public void insert(DbSession dbSession, OrganizationDto organization, boolean newProjectPrivate) {
- checkDto(organization);
- long now = system2.now();
- organization.setCreatedAt(now);
- organization.setUpdatedAt(now);
- getMapper(dbSession).insert(organization, newProjectPrivate);
- }
-
- // TODO remove after getting rid of organization code
- public OrganizationDto getDefaultOrganization(DbSession dbSession) {
- Optional<String> uuid = internalPropertiesDao.selectByKey(dbSession, DEFAULT_ORGANIZATION);
- checkState(uuid.isPresent() && !uuid.get().isEmpty(), "No Default organization uuid configured");
- return getMapper(dbSession).selectByUuid(uuid.get());
- }
-
- public int countByQuery(DbSession dbSession, OrganizationQuery organizationQuery) {
- requireNonNull(organizationQuery, "organizationQuery can't be null");
- return getMapper(dbSession).countByQuery(organizationQuery);
- }
-
- public List<OrganizationDto> selectByQuery(DbSession dbSession, OrganizationQuery organizationQuery, Pagination pagination) {
- requireNonNull(organizationQuery, "organizationQuery can't be null");
- return getMapper(dbSession).selectByQuery(organizationQuery, pagination);
- }
-
- public Optional<OrganizationDto> selectByUuid(DbSession dbSession, String uuid) {
- checkUuid(uuid);
- return Optional.ofNullable(getMapper(dbSession).selectByUuid(uuid));
- }
-
- public Optional<OrganizationDto> selectByKey(DbSession dbSession, String key) {
- requireNonNull(key, "key can't be null");
- return Optional.ofNullable(getMapper(dbSession).selectByKey(key));
- }
-
- public List<OrganizationDto> selectByUuids(DbSession dbSession, Set<String> organizationUuids) {
- return executeLargeInputs(organizationUuids, getMapper(dbSession)::selectByUuids);
- }
-
- public List<OrganizationDto> selectByPermission(DbSession dbSession, String userUuid, String permission) {
- return getMapper(dbSession).selectByPermission(userUuid, permission);
- }
-
- public List<String> selectAllUuids(DbSession dbSession) {
- return getMapper(dbSession).selectAllUuids();
- }
-
- /**
- * Retrieve the default template of the specified organization if:
- * <ol>
- * <li>the specified organization exists</li>
- * <li>the project default permission template is defined</li>
- * </ol>
- */
- public Optional<DefaultTemplates> getDefaultTemplates(DbSession dbSession, String organizationUuid) {
- checkUuid(organizationUuid);
- return Optional.ofNullable(getMapper(dbSession).selectDefaultTemplatesByUuid(organizationUuid));
- }
-
- public void setDefaultTemplates(DbSession dbSession, String uuid, DefaultTemplates defaultTemplates) {
- checkUuid(uuid);
- checkDefaultTemplates(defaultTemplates);
- long now = system2.now();
- getMapper(dbSession).updateDefaultTemplates(uuid, defaultTemplates, now);
- }
-
- public Optional<String> getDefaultGroupUuid(DbSession dbSession, String organizationUuid) {
- checkUuid(organizationUuid);
- return Optional.ofNullable(getMapper(dbSession).selectDefaultGroupUuidByUuid(organizationUuid));
- }
-
- public void setDefaultGroupUuid(DbSession dbSession, String uuid, GroupDto defaultGroup) {
- checkUuid(uuid);
- String defaultGroupUuid = requireNonNull(defaultGroup, "Default group cannot be null").getUuid();
- getMapper(dbSession).updateDefaultGroupUuid(uuid, requireNonNull(defaultGroupUuid, "Default group uuid cannot be null"), system2.now());
- }
-
- public int update(DbSession dbSession, OrganizationDto organization) {
- checkDto(organization);
- organization.setUpdatedAt(system2.now());
- return getMapper(dbSession).update(organization);
- }
-
- public int deleteByUuid(DbSession dbSession, String uuid) {
- return getMapper(dbSession).deleteByUuid(uuid);
- }
-
- public List<OrganizationWithNclocDto> selectOrganizationsWithNcloc(DbSession dbSession, List<String> organizationUuids) {
- List<OrganizationWithNclocDto> result = new ArrayList<>();
- executeLargeUpdates(organizationUuids, chunk -> result.addAll(getMapper(dbSession).selectOrganizationsWithNcloc(NCLOC_KEY, chunk, BranchType.BRANCH)));
- return result;
- }
-
- private static void checkDto(OrganizationDto organization) {
- requireNonNull(organization, "OrganizationDto can't be null");
- }
-
- private static OrganizationMapper getMapper(DbSession dbSession) {
- return dbSession.getMapper(OrganizationMapper.class);
- }
-
- private static void checkUuid(String uuid) {
- requireNonNull(uuid, "uuid can't be null");
- }
-
- private static void checkDefaultTemplates(DefaultTemplates defaultTemplates) {
- requireNonNull(defaultTemplates, "defaultTemplates can't be null");
- requireNonNull(defaultTemplates.getProjectUuid());
- }
-
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDto.java
deleted file mode 100644
index f7276747182..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDto.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.organization;
-
-import java.util.Objects;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import org.sonar.api.server.authentication.UserIdentity;
-
-public class OrganizationDto {
-
- public enum Subscription {
- /**
- * Subscription of the default organization, only for SonarQube
- */
- SONARQUBE,
-
- /**
- * Organization that has not subscribed to a paid subscription, only for SonarCloud
- */
- FREE,
-
- /**
- * Organization that subscribed to paid plan subscription, only for SonarCloud
- */
- PAID
- }
-
- /** Technical unique identifier, can't be null */
- private String uuid;
-
- /**
- * Functional unique identifier, can't be null.
- *
- * On personal organization (created the first time the user authenticates), the key can have the following format :
- * - When {@link UserIdentity#getLogin()} is not null, it's a slug of the login
- * - When {@link UserIdentity#getLogin()} is null, it's a slug of the name appended to a random number
- *
- * Length is set to 255 (As login length is 255, the size must be at least 255).
- */
- private String key;
-
- /**
- * Name, can't be null.
- *
- * Length is set to 300, as it's generated from the key when no name is provided.
- */
- private String name;
-
- /** description can't be null */
- private String description;
- /** url can be null */
- private String url;
- /** avatar url can be null */
- private String avatarUrl;
-
- private Subscription subscription;
-
- private String defaultGroupUuid;
- private String defaultQualityGateUuid;
- private long createdAt;
- private long updatedAt;
-
- public String getUuid() {
- return uuid;
- }
-
- public OrganizationDto setUuid(String uuid) {
- this.uuid = uuid;
- return this;
- }
-
- public String getKey() {
- return key;
- }
-
- public OrganizationDto setKey(String key) {
- this.key = key;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public OrganizationDto setName(String name) {
- this.name = name;
- return this;
- }
-
- @CheckForNull
- public String getDescription() {
- return description;
- }
-
- public OrganizationDto setDescription(@Nullable String description) {
- this.description = description;
- return this;
- }
-
- @CheckForNull
- public String getUrl() {
- return url;
- }
-
- public OrganizationDto setUrl(@Nullable String url) {
- this.url = url;
- return this;
- }
-
- @CheckForNull
- public String getAvatarUrl() {
- return avatarUrl;
- }
-
- public OrganizationDto setAvatarUrl(@Nullable String avatarUrl) {
- this.avatarUrl = avatarUrl;
- return this;
- }
-
- @CheckForNull
- public String getDefaultGroupUuid() {
- return defaultGroupUuid;
- }
-
- public OrganizationDto setDefaultGroupUuid(@Nullable String defaultGroupUuid) {
- this.defaultGroupUuid = defaultGroupUuid;
- return this;
- }
-
- public Subscription getSubscription() {
- return subscription;
- }
-
- public OrganizationDto setSubscription(Subscription subscription) {
- this.subscription = subscription;
- return this;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public OrganizationDto setCreatedAt(long createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- public long getUpdatedAt() {
- return updatedAt;
- }
-
- public OrganizationDto setUpdatedAt(long updatedAt) {
- this.updatedAt = updatedAt;
- return this;
- }
-
- public String getDefaultQualityGateUuid() {
- return defaultQualityGateUuid;
- }
-
- public OrganizationDto setDefaultQualityGateUuid(String defaultQualityGateUuid) {
- this.defaultQualityGateUuid = defaultQualityGateUuid;
- return this;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- OrganizationDto that = (OrganizationDto) o;
- return Objects.equals(uuid, that.uuid);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(uuid);
- }
-
- @Override
- public String toString() {
- return "OrganizationDto{" +
- "uuid='" + uuid + '\'' +
- ", key='" + key + '\'' +
- ", name='" + name + '\'' +
- ", description='" + description + '\'' +
- ", url='" + url + '\'' +
- ", avatarUrl='" + avatarUrl + '\'' +
- ", defaultQualityGateUuid=" + defaultQualityGateUuid +
- ", subscription=" + subscription +
- ", createdAt=" + createdAt +
- ", updatedAt=" + updatedAt +
- '}';
- }
-
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationHelper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationHelper.java
deleted file mode 100644
index 78f2dbd836a..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationHelper.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.organization;
-
-import java.util.List;
-import java.util.stream.Collectors;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.permission.GlobalPermission;
-
-public class OrganizationHelper {
-
- private static final String ADMIN_PERMISSION = GlobalPermission.ADMINISTER.getKey();
-
- private final DbClient dbClient;
-
- public OrganizationHelper(DbClient dbClient) {
- this.dbClient = dbClient;
- }
-
- public List<OrganizationDto> selectOrganizationsWithLastAdmin(DbSession dbSession, String userUuid) {
- return dbClient.organizationDao().selectByPermission(dbSession, userUuid, ADMIN_PERMISSION).stream()
- .filter(org -> isLastAdmin(dbSession, userUuid))
- .collect(Collectors.toList());
- }
-
- private boolean isLastAdmin(DbSession dbSession, String userUuid) {
- return dbClient.authorizationDao().countUsersWithGlobalPermissionExcludingUser(dbSession, ADMIN_PERMISSION, userUuid) == 0;
- }
-}
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
deleted file mode 100644
index 811c18d4b3c..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationMapper.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.organization;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import org.apache.ibatis.annotations.Param;
-import org.sonar.db.Pagination;
-import org.sonar.db.component.BranchType;
-import org.sonar.db.permission.template.DefaultTemplates;
-
-public interface OrganizationMapper {
- void insert(@Param("organization") OrganizationDto organization, @Param("newProjectPrivate") boolean newProjectPrivate);
-
- int countByQuery(@Param("query") OrganizationQuery organizationQuery);
-
- List<OrganizationDto> selectByQuery(@Param("query") OrganizationQuery organizationQuery,
- @Param("pagination") Pagination pagination);
-
- @CheckForNull
- OrganizationDto selectByKey(@Param("key") String key);
-
- @CheckForNull
- OrganizationDto selectByUuid(@Param("uuid") String uuid);
-
- List<OrganizationDto> selectByUuids(@Param("uuids") List<String> uuids);
-
- List<OrganizationDto> selectByPermission(@Param("userUuid") String userUuid, @Param("permission") String permission);
-
- List<String> selectAllUuids();
-
- DefaultTemplates selectDefaultTemplatesByUuid(@Param("uuid") String uuid);
-
- String selectDefaultGroupUuidByUuid(@Param("uuid") String uuid);
-
- boolean selectNewProjectPrivateByUuid(@Param("uuid") String uuid);
-
- /**
- * Update the organization with UUID specified by {@link OrganizationDto#getUuid()}.
- * <p>
- * This method ignores {@link OrganizationDto#getCreatedAt()} and {@link OrganizationDto#getKey()}
- * (they are not updated).
- * </p>
- */
- int update(@Param("organization") OrganizationDto organization);
-
- void updateDefaultTemplates(@Param("organizationUuid") String organizationUuid,
- @Param("defaultTemplates") DefaultTemplates defaultTemplates, @Param("now") long now);
-
- void updateDefaultGroupUuid(@Param("organizationUuid") String organizationUuid,
- @Param("defaultGroupUuid") String defaultGroupUuid, @Param("now") long now);
-
- void updateDefaultQualityGate(@Param("organizationUuid") String organizationUuid,
- @Param("defaultQualityGateUuid") String defaultQualityGateUuid, @Param("now") long now);
-
- void updateNewProjectPrivate(@Param("organizationUuid") String organizationUuid, @Param("newProjectPrivate") boolean newProjectPrivate, @Param("now") long now);
-
- int deleteByUuid(@Param("uuid") String uuid);
-
- List<OrganizationWithNclocDto> selectOrganizationsWithNcloc(
- @Param("ncloc") String ncloc,
- @Param("organizationUuids") List<String> organizationUuids,
- @Param("branchType") BranchType branchType);
-
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationQuery.java b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationQuery.java
deleted file mode 100644
index c7affdfd09d..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationQuery.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.organization;
-
-import java.util.Collection;
-import java.util.Objects;
-import java.util.Set;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
-
-public class OrganizationQuery {
- private static final OrganizationQuery NO_FILTER = newOrganizationQueryBuilder().build();
- private final Set<String> keys;
- private final boolean withAnalyses;
- @Nullable
- private final Long analyzedAfter;
-
- private OrganizationQuery(Builder builder) {
- this.keys = builder.keys;
- this.withAnalyses = builder.withAnalyses;
- this.analyzedAfter = builder.analyzedAfter;
- }
-
- @CheckForNull
- public Set<String> getKeys() {
- return keys;
- }
-
- public boolean isWithAnalyses() {
- return withAnalyses;
- }
-
- @CheckForNull
- public Long getAnalyzedAfter() {
- return analyzedAfter;
- }
-
- public static OrganizationQuery returnAll() {
- return NO_FILTER;
- }
-
- public static Builder newOrganizationQueryBuilder() {
- return new Builder();
- }
-
- public static class Builder {
- private Set<String> keys;
- private boolean withAnalyses = false;
- @Nullable
- private Long analyzedAfter;
-
- private Builder() {
- // use static factory method
- }
-
- public Builder setKeys(@Nullable Collection<String> keys) {
- if (keys != null && !keys.isEmpty()) {
- this.keys = keys.stream()
- .filter(Objects::nonNull)
- .collect(toSet(keys.size()));
- }
- return this;
- }
-
- public Builder setWithAnalyses() {
- this.withAnalyses = true;
- return this;
- }
-
- public Builder setAnalyzedAfter(long l) {
- this.analyzedAfter = l;
- return this;
- }
-
- public OrganizationQuery build() {
- return new OrganizationQuery(this);
- }
- }
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationWithNclocDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationWithNclocDto.java
deleted file mode 100644
index b88e4344157..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationWithNclocDto.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.organization;
-
-public class OrganizationWithNclocDto {
- private String id;
- private String kee;
- private String name;
- private long ncloc;
-
- public String getId() {
- return id;
- }
-
- public OrganizationWithNclocDto setId(String id) {
- this.id = id;
- return this;
- }
-
- public String getKee() {
- return kee;
- }
-
- public OrganizationWithNclocDto setKee(String kee) {
- this.kee = kee;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public OrganizationWithNclocDto setName(String name) {
- this.name = name;
- return this;
- }
-
- public long getNcloc() {
- return ncloc;
- }
-
- public OrganizationWithNclocDto setNcloc(long ncloc) {
- this.ncloc = ncloc;
- return this;
- }
-}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/package-info.java b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/package-info.java
deleted file mode 100644
index ab87187336d..00000000000
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.db.organization;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java
index 305e15d0e17..391eb8a230b 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java
@@ -49,7 +49,7 @@ public class AuthorizationDao implements Dao {
}
/**
- * Loads all the permissions granted to anonymous user for the specified organization
+ * Loads all the permissions granted to anonymous user
*/
public Set<String> selectGlobalPermissionsOfAnonymous(DbSession dbSession) {
return mapper(dbSession).selectGlobalPermissionsOfAnonymous();
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/GroupPermissionDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/permission/GroupPermissionDao.java
index 8723a9aeaeb..17287fc4bda 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/GroupPermissionDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/permission/GroupPermissionDao.java
@@ -38,7 +38,7 @@ public class GroupPermissionDao implements Dao {
private static final String ANYONE_GROUP_PARAMETER = "anyoneGroup";
/**
- * Returns the names of the groups that match the given query, for the given organization.
+ * Returns the names of the groups that match the given query.
* The virtual group "Anyone" may be returned as the value {@link DefaultGroups#ANYONE}.
* @return group names, sorted in alphabetical order
*/
@@ -55,7 +55,7 @@ public class GroupPermissionDao implements Dao {
}
/**
- * Select global or project permission of given groups and organization. Anyone virtual group is supported
+ * Select global or project permission of given groups. Anyone virtual group is supported
* through the value "zero" (0L) in {@code groupUuids}.
*/
public List<GroupPermissionDto> selectByGroupUuids(DbSession dbSession, List<String> groupUuids, @Nullable String projectUuid) {
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java
index 31baf8ec05a..76124fed9cb 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/project/ProjectDto.java
@@ -39,7 +39,6 @@ public class ProjectDto {
private String tags;
private long createdAt;
private long updatedAt;
- private String organizationUuid;
public ProjectDto() {
// nothing to do here
@@ -128,19 +127,6 @@ public class ProjectDto {
return this;
}
- // TODO remove after getting rid of organization code
- @Deprecated
- public String getOrganizationUuid() {
- return organizationUuid;
- }
-
- // TODO remove after getting rid of organization code
- @Deprecated
- public ProjectDto setOrganizationUuid(String organizationUuid) {
- this.organizationUuid = organizationUuid;
- return this;
- }
-
public String getName() {
return name;
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java
index 0d84a476b91..ed59a6de59f 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java
@@ -206,8 +206,7 @@ public class PropertiesDao implements Dao {
save(getMapper(session), property.getKey(), property.getUserUuid(), property.getComponentUuid(), property.getValue());
}
- private void save(PropertiesMapper mapper, String key,
- @Nullable String userUuid, @Nullable String componentUuid, @Nullable String value) {
+ private void save(PropertiesMapper mapper, String key, @Nullable String userUuid, @Nullable String componentUuid, @Nullable String value) {
checkKey(key);
long now = system2.now();
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesMapper.java
index c0e813e4b59..ba6e28ad7d1 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesMapper.java
@@ -65,8 +65,6 @@ public interface PropertiesMapper {
int delete(@Param("key") String key, @Nullable @Param("userUuid") String userUuid, @Nullable @Param("componentUuid") String componentUuid);
- int deleteById(long id);
-
int deleteProjectProperty(@Param("key") String key, @Param("componentUuid") String componentUuid);
int deleteProjectProperties(@Param("key") String key, @Param("value") String value);
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/user/GroupDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/user/GroupDao.java
index 038c275e0eb..a056fba97d6 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/user/GroupDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/user/GroupDao.java
@@ -47,7 +47,7 @@ public class GroupDao implements Dao {
/**
* @param dbSession
* @param name non-null group name
- * @return the group with the given organization key and name
+ * @return the group with the given name
*/
public Optional<GroupDto> selectByName(DbSession dbSession, String name) {
return Optional.ofNullable(mapper(dbSession).selectByName(name));
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java
index 092a4a6ea5a..874eec147aa 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java
@@ -35,7 +35,6 @@ import org.sonar.core.util.UuidFactory;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
import org.sonar.db.component.ComponentDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.project.ProjectDto;
import static java.util.Locale.ENGLISH;
@@ -121,10 +120,6 @@ public class UserDao implements Dao {
mapper(dbSession).deactivateUser(user.getLogin(), system2.now());
}
- public void cleanHomepage(DbSession dbSession, OrganizationDto organization) {
- mapper(dbSession).clearHomepages("ORGANIZATION", organization.getUuid(), system2.now());
- }
-
public void cleanHomepage(DbSession dbSession, ProjectDto project) {
mapper(dbSession).clearHomepages("PROJECT", project.getUuid(), system2.now());
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDao.java
index 716b6fb5762..8c892304793 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDao.java
@@ -24,20 +24,14 @@ import java.util.Optional;
import org.sonar.api.utils.System2;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.project.ProjectDto;
-import org.sonar.db.property.InternalPropertiesDao;
-
-import static com.google.common.base.Preconditions.checkState;
public class WebhookDao implements Dao {
private final System2 system2;
- private final InternalPropertiesDao internalPropertiesDao;
- public WebhookDao(System2 system2, InternalPropertiesDao internalPropertiesDao) {
+ public WebhookDao(System2 system2) {
this.system2 = system2;
- this.internalPropertiesDao = internalPropertiesDao;
}
public List<WebhookDto> selectAll(DbSession dbSession) {
@@ -52,31 +46,11 @@ public class WebhookDao implements Dao {
return Optional.ofNullable(mapper(dbSession).selectByUuid(uuid));
}
- // TODO remove
- @Deprecated
- public List<WebhookDto> selectByOrganization(DbSession dbSession, OrganizationDto organizationDto) {
- return mapper(dbSession).selectForOrganizationUuidOrderedByName(organizationDto.getUuid());
- }
-
- // TODO remove
- @Deprecated
- public List<WebhookDto> selectByOrganizationUuid(DbSession dbSession, String organizationUuid) {
- return mapper(dbSession).selectForOrganizationUuidOrderedByName(organizationUuid);
- }
-
public List<WebhookDto> selectByProject(DbSession dbSession, ProjectDto projectDto) {
return mapper(dbSession).selectForProjectUuidOrderedByName(projectDto.getUuid());
}
public void insert(DbSession dbSession, WebhookDto dto) {
- checkState(dto.getOrganizationUuid() == null || dto.getProjectUuid() == null,
- "A webhook can not be linked to both an organization and a project.");
-
- if (dto.getProjectUuid() == null && dto.getOrganizationUuid() == null) {
- Optional<String> uuid = internalPropertiesDao.selectByKey(dbSession, "organization.default");
- checkState(uuid.isPresent() && !uuid.get().isEmpty(), "No Default organization uuid configured");
- dto.setOrganizationUuid(uuid.get());
- }
mapper(dbSession).insert(dto.setCreatedAt(system2.now()).setUpdatedAt(system2.now()));
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDto.java
index c1b84672354..cc5d2181211 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDto.java
@@ -31,9 +31,6 @@ public class WebhookDto {
private String url;
@Nullable
- private String organizationUuid;
-
- @Nullable
private String projectUuid;
/**
@@ -60,11 +57,6 @@ public class WebhookDto {
return this;
}
- public WebhookDto setOrganizationUuid(@Nullable String organizationUuid) {
- this.organizationUuid = organizationUuid;
- return this;
- }
-
public WebhookDto setProjectUuid(@Nullable String projectUuid) {
this.projectUuid = projectUuid;
return this;
@@ -98,11 +90,6 @@ public class WebhookDto {
}
@Nullable
- public String getOrganizationUuid() {
- return organizationUuid;
- }
-
- @Nullable
public String getProjectUuid() {
return projectUuid;
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookMapper.java
index 2d2723976c0..d1d48898429 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookMapper.java
@@ -32,19 +32,13 @@ public interface WebhookMapper {
List<WebhookDto> selectGlobalWebhooksOrderedByName();
- // TODO remove
- @Deprecated
List<WebhookDto> selectForProjectUuidOrderedByName(@Param("projectUuid") String projectUuid);
- // TODO remove
- @Deprecated
- List<WebhookDto> selectForOrganizationUuidOrderedByName(@Param("organizationUuid") String organizationUuid);
-
void insert(WebhookDto dto);
void update(WebhookDto dto);
void delete(@Param("uuid") String uuid);
- void deleteForProjectUuid(@Param("projectUuid") String organizationUuid);
+ void deleteForProjectUuid(@Param("projectUuid") String projectUuid);
}
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ApplicationProjectsMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ApplicationProjectsMapper.xml
index 9b7533340f0..6a8f8a7011f 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ApplicationProjectsMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ApplicationProjectsMapper.xml
@@ -19,7 +19,6 @@
<sql id="projectColumns">
p.uuid as uuid,
- p.organization_uuid as organizationUuid,
p.kee as kee,
p.qualifier as qualifier,
p.name as name,
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 ad1b37560aa..7e9e3d814b0 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
@@ -3,7 +3,6 @@
<mapper namespace="org.sonar.db.component.ComponentMapper">
<sql id="componentColumns">
- p.organization_uuid as organizationUuid,
p.uuid as uuid,
p.uuid_path as uuidPath,
p.project_uuid as projectUuid,
@@ -67,7 +66,7 @@
select
<include refid="componentColumns"/>
from components root
- inner join components p on p.project_uuid=root.uuid and p.organization_uuid=root.organization_uuid
+ inner join components p on p.project_uuid=root.uuid
where
root.uuid=#{projectUuid,jdbcType=VARCHAR}
</select>
@@ -140,7 +139,6 @@
INNER JOIN components child ON
child.root_uuid=p.uuid
and child.enabled=${_true}
- and child.organization_uuid=p.organization_uuid
where
p.enabled=${_true}
and p.scope='PRJ'
@@ -160,7 +158,6 @@
<sql id="modulesTreeQuery">
INNER JOIN components module ON
module.project_uuid = p.project_uuid
- and module.organization_uuid = p.organization_uuid
and module.uuid = #{moduleUuid}
and module.scope='PRJ' AND module.enabled = ${_true}
where
@@ -189,7 +186,6 @@
FROM components root
INNER JOIN components p on
p.project_uuid=root.uuid
- and p.organization_uuid=root.organization_uuid
and p.enabled=${_true}
and p.scope='FIL'
INNER JOIN file_sources fs ON
@@ -242,15 +238,6 @@
and p.qualifier = 'BRC'
</select>
- <select id="countComponentByOrganizationAndUuid" resultType="int">
- select
- count(1)
- from components p
- where
- p.organization_uuid = #{organizationUuid,jdbcType=VARCHAR}
- and p.uuid = #{componentUuid,jdbcType=BIGINT}
- </select>
-
<select id="selectByQuery" resultType="Component">
select
<include refid="componentColumns"/>
@@ -516,7 +503,6 @@
<insert id="insert" parameterType="Component">
INSERT INTO components (
- organization_uuid,
kee,
uuid,
uuid_path,
@@ -550,7 +536,6 @@
b_qualifier
)
VALUES (
- #{organizationUuid,jdbcType=VARCHAR},
#{kee,jdbcType=VARCHAR},
#{uuid,jdbcType=VARCHAR},
#{uuidPath,jdbcType=VARCHAR},
@@ -719,7 +704,6 @@
and p.scope = 'PRJ'
and p.qualifier = 'TRK'
and p.copy_component_uuid is null
- and p.organization_uuid = #{organizationUuid, jdbcType=VARCHAR}
group by p.kee, p.name
order by ncloc desc
</select>
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml
index 2056461e95a..ac50941c927 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml
@@ -65,39 +65,6 @@
</if>
</sql>
- <sql id="issueForIndexingColumns">
- i.kee as "key",
- root.uuid as "projectUuid",
- i.updated_at as "updatedAt",
- i.assignee,
- i.gap,
- i.issue_attributes as "attributes",
- i.line,
- i.message,
- i.resolution,
- i.severity,
- i.manual_severity as "manualSeverity",
- i.checksum,
- i.status,
- i.effort,
- i.author_login as "authorLogin",
- i.issue_close_date as "issueCloseDate",
- i.issue_creation_date as "issueCreationDate",
- i.issue_update_date as "issueUpdateDate",
- r.is_external as "isExternal",
- r.plugin_name as "pluginName",
- r.plugin_rule_key as "pluginRuleKey",
- r.language,
- p.uuid as "projectUuid",
- p.module_uuid_path as "moduleUuidPath",
- p.path,
- p.scope,
- p.organization_uuid as "organizationUuid",
- i.tags,
- i.issue_type as "issueType"
- </sql>
-
-
<insert id="insert" parameterType="Issue" useGeneratedKeys="false">
INSERT INTO issues (kee, rule_uuid, severity, manual_severity,
message, line, locations, gap, effort, status, tags,
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/organization/OrganizationMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/organization/OrganizationMapper.xml
deleted file mode 100644
index 9a396e50ab9..00000000000
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/organization/OrganizationMapper.xml
+++ /dev/null
@@ -1,284 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
-
-<mapper namespace="org.sonar.db.organization.OrganizationMapper">
- <sql id="selectColumns">
- org.uuid as "uuid",
- org.kee as "key",
- org.name as "name",
- org.description as "description",
- org.default_quality_gate_uuid as "defaultQualityGateUuid",
- org.url as "url",
- org.avatar_url as "avatarUrl",
- org.subscription as "subscription",
- org.created_at as "createdAt",
- org.updated_at as "updatedAt"
- </sql>
-
- <sql id="defaultTemplatesColumns">
- org.default_perm_template_project as "projectUuid",
- org.default_perm_template_app as "applicationsUuid",
- org.default_perm_template_port as "portfoliosUuid"
- </sql>
-
- <select id="selectByUuid" resultType="Organization">
- select
- <include refid="selectColumns"/>
- from organizations org
- where
- org.uuid = #{uuid, jdbcType=VARCHAR}
- </select>
-
- <select id="selectDefaultTemplatesByUuid" resultType="org.sonar.db.permission.template.DefaultTemplates">
- select
- <include refid="defaultTemplatesColumns"/>
- from organizations org
- where
- org.uuid = #{uuid, jdbcType=VARCHAR}
- and org.default_perm_template_project is not null
- </select>
-
- <select id="selectByKey" resultType="Organization">
- select
- <include refid="selectColumns"/>
- from organizations org
- where
- org.kee = #{key, jdbcType=VARCHAR}
- </select>
-
- <select id="selectByUuids" resultType="Organization">
- select
- <include refid="selectColumns"/>
- from organizations org
- where
- org.uuid in
- <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">
- #{uuid, jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="countByQuery" resultType="int">
- select count(org.uuid)
- <include refid="sqlSelectByQuery" />
- </select>
-
- <select id="selectByQuery" parameterType="map" resultType="Organization">
- select
- <include refid="selectColumns"/>
- <include refid="sqlSelectByQuery" />
- order by
- org.created_at desc
- limit #{pagination.pageSize,jdbcType=INTEGER} offset #{pagination.offset,jdbcType=INTEGER}
- </select>
-
- <select id="selectByQuery" parameterType="map" resultType="Organization" databaseId="mssql">
- select * from (
- select row_number() over(order by org.created_at desc) as number,
- <include refid="selectColumns"/>
- <include refid="sqlSelectByQuery" />
- ) as query
- where
- query.number between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
- order by
- query.createdAt desc
- </select>
-
- <select id="selectByQuery" parameterType="map" resultType="Organization" databaseId="oracle">
- select * from (
- select rownum as rn, t.* from (
- select
- <include refid="selectColumns"/>
- <include refid="sqlSelectByQuery" />
- ORDER BY org.created_at desc
- ) t
- ) t
- where
- t.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
- </select>
-
- <sql id="sqlSelectByQuery">
- from organizations org
- <where>
- <if test="query.keys != null">
- org.kee in
- <foreach collection="query.keys" open="(" close=")" item="key" separator=",">
- #{key, jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.withAnalyses">
- and exists(
- select 1
- from snapshots s
- inner join components p on p.uuid = s.component_uuid
- where p.organization_uuid = org.uuid
- and p.enabled = ${_true}
- and s.islast = ${_true}
- )
- </if>
- <if test="query.analyzedAfter != null">
- and exists(
- select 1
- from snapshots s
- inner join components p on p.uuid = s.component_uuid
- where p.organization_uuid = org.uuid
- and p.enabled = ${_true}
- and s.islast = ${_true}
- and s.created_at &gt;= #{query.analyzedAfter,jdbcType=BIGINT}
- )
- </if>
- </where>
- </sql>
-
- <select id="selectByPermission" parameterType="map" resultType="Organization">
- select
- <include refid="selectColumns"/>
- from organizations org
- inner join user_roles ur on ur.user_uuid = #{userUuid,jdbcType=VARCHAR}
- and ur.component_uuid is null
- and ur.role = #{permission,jdbcType=VARCHAR}
- union
- select
- <include refid="selectColumns"/>
- from organizations org
- inner join group_roles g on g.component_uuid is null
- and g.role = #{permission,jdbcType=VARCHAR}
- inner join groups_users gu on
- gu.group_uuid = g.group_uuid
- and gu.user_uuid= #{userUuid,jdbcType=VARCHAR}
- </select>
-
- <select id="selectAllUuids" resultType="String">
- select uuid from organizations
- </select>
-
- <select id="selectDefaultGroupUuidByUuid" resultType="string">
- select org.default_group_uuid
- from organizations org
- where
- org.uuid = #{uuid, jdbcType=VARCHAR}
- </select>
-
- <select id="selectNewProjectPrivateByUuid" resultType="Boolean">
- select org.new_project_private
- from organizations org
- where
- org.uuid = #{uuid, jdbcType=VARCHAR}
- </select>
-
- <select id="selectOrganizationsWithNcloc" resultType="org.sonar.db.organization.OrganizationWithNclocDto">
- select o.uuid as id, o.kee as kee, o.name as name, t.ncloc as ncloc
- from organizations o
- left outer join (
- select orgUuid, sum(sumncloc.maxncloc) as ncloc from (
- select b.project_uuid, p.organization_uuid as orgUuid, max(lm.value) as maxncloc
- from live_measures lm
- inner join metrics m on m.uuid = lm.metric_uuid
- inner join components p on p.uuid = lm.component_uuid
- inner join project_branches b on b.uuid = p.uuid
- where
- m.name = #{ncloc, jdbcType=VARCHAR}
- and p.enabled = ${_true}
- and p.private = ${_true}
- and p.scope = 'PRJ'
- and p.qualifier = 'TRK'
- and p.copy_component_uuid is null
- and p.organization_uuid in <foreach collection="organizationUuids" open="(" close=")" item="uuid" separator=",">#{uuid, jdbcType=VARCHAR}</foreach>
- and b.branch_type = #{branchType, jdbcType=VARCHAR}
- group by b.project_uuid, p.organization_uuid
- ) sumncloc
- group by orgUuid
- ) t on t.orgUuid = o.uuid
- where
- o.uuid in <foreach collection="organizationUuids" open="(" close=")" item="uuid" separator=",">#{uuid, jdbcType=VARCHAR}</foreach>
- </select>
-
- <insert id="insert" parameterType="map" useGeneratedKeys="false">
- insert into organizations
- (
- uuid,
- kee,
- name,
- description,
- url,
- avatar_url,
- new_project_private,
- default_quality_gate_uuid,
- subscription,
- created_at,
- updated_at
- )
- values
- (
- #{organization.uuid, jdbcType=VARCHAR},
- #{organization.key, jdbcType=VARCHAR},
- #{organization.name, jdbcType=VARCHAR},
- #{organization.description, jdbcType=VARCHAR},
- #{organization.url, jdbcType=VARCHAR},
- #{organization.avatarUrl, jdbcType=VARCHAR},
- #{newProjectPrivate, jdbcType=BOOLEAN},
- #{organization.defaultQualityGateUuid, jdbcType=VARCHAR},
- #{organization.subscription, jdbcType=VARCHAR},
- #{organization.createdAt, jdbcType=BIGINT},
- #{organization.updatedAt, jdbcType=BIGINT}
- )
- </insert>
-
- <update id="update" parameterType="Organization">
- update organizations
- set
- kee = #{organization.key, jdbcType=VARCHAR},
- name = #{organization.name, jdbcType=VARCHAR},
- description = #{organization.description, jdbcType=VARCHAR},
- url = #{organization.url, jdbcType=VARCHAR},
- default_quality_gate_uuid = #{organization.defaultQualityGateUuid, jdbcType=VARCHAR},
- subscription = #{organization.subscription, jdbcType=VARCHAR},
- avatar_url = #{organization.avatarUrl, jdbcType=VARCHAR},
- updated_at = #{organization.updatedAt, jdbcType=BIGINT}
- where
- uuid = #{organization.uuid, jdbcType=VARCHAR}
- </update>
-
- <update id="updateDefaultTemplates">
- update organizations
- set
- default_perm_template_project = #{defaultTemplates.projectUuid, jdbcType=VARCHAR},
- default_perm_template_app = #{defaultTemplates.applicationsUuid, jdbcType=VARCHAR},
- default_perm_template_port = #{defaultTemplates.portfoliosUuid, jdbcType=VARCHAR},
- updated_at = #{now, jdbcType=BIGINT}
- where
- uuid = #{organizationUuid, jdbcType=VARCHAR}
- </update>
-
- <update id="updateDefaultGroupUuid">
- update organizations
- set
- default_group_uuid = #{defaultGroupUuid, jdbcType=VARCHAR},
- updated_at = #{now, jdbcType=BIGINT}
- where
- uuid = #{organizationUuid, jdbcType=VARCHAR}
- </update>
-
- <update id="updateDefaultQualityGate">
- update organizations
- set
- default_quality_gate_uuid = #{defaultQualityGateUuid, jdbcType=INTEGER},
- updated_at = #{now, jdbcType=BIGINT}
- where
- uuid = #{organizationUuid, jdbcType=VARCHAR}
- </update>
-
- <update id="updateNewProjectPrivate">
- update organizations
- set
- new_project_private = #{newProjectPrivate, jdbcType=INTEGER},
- updated_at = #{now, jdbcType=BIGINT}
- where
- uuid = #{organizationUuid, jdbcType=VARCHAR}
- </update>
-
- <delete id="deleteByUuid">
- delete from organizations
- where
- uuid = #{uuid, jdbcType=VARCHAR}
- </delete>
-</mapper>
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml
index 99a1bcfc86b..5f83e3d776e 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectMapper.xml
@@ -4,7 +4,6 @@
<sql id="projectColumns">
p.uuid as uuid,
- p.organization_uuid as organizationUuid,
p.kee as kee,
p.qualifier as qualifier,
p.name as name,
@@ -108,7 +107,6 @@
<insert id="insert" parameterType="Project">
INSERT INTO projects (
- organization_uuid,
kee,
qualifier,
uuid,
@@ -120,7 +118,6 @@
updated_at
)
VALUES (
- #{organizationUuid,jdbcType=VARCHAR},
#{kee,jdbcType=VARCHAR},
#{qualifier,jdbcType=VARCHAR},
#{uuid,jdbcType=VARCHAR},
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/webhook/WebhookMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/webhook/WebhookMapper.xml
index e1531e30aa1..7459d2b11e9 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/webhook/WebhookMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/webhook/WebhookMapper.xml
@@ -8,7 +8,6 @@
uuid,
name,
url,
- organization_uuid as organizationUuid,
project_uuid as projectUuid,
secret,
created_at as createdAt,
@@ -34,13 +33,6 @@
order by name asc
</select>
- <select id="selectForOrganizationUuidOrderedByName" parameterType="String" resultType="org.sonar.db.webhook.WebhookDto">
- select <include refid="sqlColumns" />
- from webhooks
- where organization_uuid = #{organizationUuid,jdbcType=VARCHAR}
- order by name asc
- </select>
-
<select id="selectForProjectUuidOrderedByName" parameterType="String" resultType="org.sonar.db.webhook.WebhookDto">
select <include refid="sqlColumns" />
from webhooks
@@ -53,7 +45,6 @@
uuid,
name,
url,
- organization_uuid,
project_uuid,
secret,
created_at,
@@ -62,7 +53,6 @@
#{uuid,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR},
#{url,jdbcType=VARCHAR},
- #{organizationUuid,jdbcType=VARCHAR},
#{projectUuid,jdbcType=VARCHAR},
#{secret,jdbcType=VARCHAR},
#{createdAt,jdbcType=BIGINT},
@@ -85,12 +75,6 @@
uuid = #{uuid,jdbcType=VARCHAR}
</delete>
- <delete id="deleteForOrganizationUuid" parameterType="String">
- delete from webhooks
- where
- organization_uuid = #{organizationUuid,jdbcType=VARCHAR}
- </delete>
-
<delete id="deleteForProjectUuid" parameterType="String">
delete from webhooks
where
diff --git a/server/sonar-db-dao/src/schema/schema-sq.ddl b/server/sonar-db-dao/src/schema/schema-sq.ddl
index c3278219308..f34734a7cf3 100644
--- a/server/sonar-db-dao/src/schema/schema-sq.ddl
+++ b/server/sonar-db-dao/src/schema/schema-sq.ddl
@@ -35,21 +35,6 @@ CREATE TABLE "ACTIVE_RULES"(
ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "PK_ACTIVE_RULES" PRIMARY KEY("UUID");
CREATE UNIQUE INDEX "UNIQ_PROFILE_RULE_UUIDS" ON "ACTIVE_RULES"("PROFILE_UUID", "RULE_UUID");
-CREATE TABLE "ALM_APP_INSTALLS"(
- "UUID" VARCHAR(40) NOT NULL,
- "ALM_ID" VARCHAR(40) NOT NULL,
- "OWNER_ID" VARCHAR(4000) NOT NULL,
- "INSTALL_ID" VARCHAR(4000) NOT NULL,
- "IS_OWNER_USER" BOOLEAN NOT NULL,
- "USER_EXTERNAL_ID" VARCHAR(255),
- "CREATED_AT" BIGINT NOT NULL,
- "UPDATED_AT" BIGINT NOT NULL
-);
-ALTER TABLE "ALM_APP_INSTALLS" ADD CONSTRAINT "PK_ALM_APP_INSTALLS" PRIMARY KEY("UUID");
-CREATE UNIQUE INDEX "ALM_APP_INSTALLS_OWNER" ON "ALM_APP_INSTALLS"("ALM_ID", "OWNER_ID");
-CREATE UNIQUE INDEX "ALM_APP_INSTALLS_INSTALL" ON "ALM_APP_INSTALLS"("ALM_ID", "INSTALL_ID");
-CREATE INDEX "ALM_APP_INSTALLS_EXTERNAL_ID" ON "ALM_APP_INSTALLS"("USER_EXTERNAL_ID");
-
CREATE TABLE "ALM_PATS"(
"UUID" VARCHAR(40) NOT NULL,
"PAT" VARCHAR(2000) NOT NULL,
@@ -203,7 +188,6 @@ CREATE INDEX "CTM_MESSAGE_TYPE" ON "CE_TASK_MESSAGE"("MESSAGE_TYPE");
CREATE TABLE "COMPONENTS"(
"UUID" VARCHAR(50) NOT NULL,
- "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
"KEE" VARCHAR(400),
"DEPRECATED_KEE" VARCHAR(400),
"NAME" VARCHAR(2000),
@@ -236,7 +220,6 @@ CREATE TABLE "COMPONENTS"(
"B_MODULE_UUID_PATH" VARCHAR(1500),
"CREATED_AT" TIMESTAMP
);
-CREATE INDEX "PROJECTS_ORGANIZATION" ON "COMPONENTS"("ORGANIZATION_UUID");
CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE");
CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID");
CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID");
@@ -528,56 +511,6 @@ ALTER TABLE "ORG_QPROFILES" ADD CONSTRAINT "PK_ORG_QPROFILES" PRIMARY KEY("UUID"
CREATE INDEX "QPROFILES_RP_UUID" ON "ORG_QPROFILES"("RULES_PROFILE_UUID");
CREATE INDEX "ORG_QPROFILES_PARENT_UUID" ON "ORG_QPROFILES"("PARENT_UUID");
-CREATE TABLE "ORG_QUALITY_GATES"(
- "UUID" VARCHAR(40) NOT NULL,
- "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
- "QUALITY_GATE_UUID" VARCHAR(40) NOT NULL
-);
-ALTER TABLE "ORG_QUALITY_GATES" ADD CONSTRAINT "PK_ORG_QUALITY_GATES" PRIMARY KEY("UUID");
-CREATE UNIQUE INDEX "UNIQ_ORG_QUALITY_GATES" ON "ORG_QUALITY_GATES"("ORGANIZATION_UUID", "QUALITY_GATE_UUID");
-
-CREATE TABLE "ORGANIZATION_ALM_BINDINGS"(
- "UUID" VARCHAR(40) NOT NULL,
- "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
- "ALM_APP_INSTALL_UUID" VARCHAR(40) NOT NULL,
- "ALM_ID" VARCHAR(40) NOT NULL,
- "URL" VARCHAR(2000) NOT NULL,
- "USER_UUID" VARCHAR(255) NOT NULL,
- "MEMBERS_SYNC_ENABLED" BOOLEAN,
- "CREATED_AT" BIGINT NOT NULL
-);
-ALTER TABLE "ORGANIZATION_ALM_BINDINGS" ADD CONSTRAINT "PK_ORGANIZATION_ALM_BINDINGS" PRIMARY KEY("UUID");
-CREATE UNIQUE INDEX "ORG_ALM_BINDINGS_ORG" ON "ORGANIZATION_ALM_BINDINGS"("ORGANIZATION_UUID");
-CREATE UNIQUE INDEX "ORG_ALM_BINDINGS_INSTALL" ON "ORGANIZATION_ALM_BINDINGS"("ALM_APP_INSTALL_UUID");
-
-CREATE TABLE "ORGANIZATION_MEMBERS"(
- "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
- "USER_UUID" VARCHAR(255) NOT NULL
-);
-ALTER TABLE "ORGANIZATION_MEMBERS" ADD CONSTRAINT "PK_ORGANIZATION_MEMBERS" PRIMARY KEY("USER_UUID", "ORGANIZATION_UUID");
-CREATE INDEX "ORG_MEMBERS_USER_UUID" ON "ORGANIZATION_MEMBERS"("USER_UUID");
-
-CREATE TABLE "ORGANIZATIONS"(
- "UUID" VARCHAR(40) NOT NULL,
- "KEE" VARCHAR(255) NOT NULL,
- "NAME" VARCHAR(255) NOT NULL,
- "DESCRIPTION" VARCHAR(256),
- "URL" VARCHAR(256),
- "AVATAR_URL" VARCHAR(256),
- "GUARDED" BOOLEAN,
- "DEFAULT_QUALITY_GATE_UUID" VARCHAR(40) NOT NULL,
- "DEFAULT_PERM_TEMPLATE_PROJECT" VARCHAR(40),
- "DEFAULT_PERM_TEMPLATE_APP" VARCHAR(40),
- "DEFAULT_PERM_TEMPLATE_PORT" VARCHAR(40),
- "NEW_PROJECT_PRIVATE" BOOLEAN NOT NULL,
- "SUBSCRIPTION" VARCHAR(40) NOT NULL,
- "CREATED_AT" BIGINT NOT NULL,
- "UPDATED_AT" BIGINT NOT NULL,
- "DEFAULT_GROUP_UUID" VARCHAR(40)
-);
-ALTER TABLE "ORGANIZATIONS" ADD CONSTRAINT "PK_ORGANIZATIONS" PRIMARY KEY("UUID");
-CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS"("KEE");
-
CREATE TABLE "PERM_TEMPLATES_GROUPS"(
"PERMISSION_REFERENCE" VARCHAR(64) NOT NULL,
"CREATED_AT" TIMESTAMP,
@@ -722,7 +655,6 @@ CREATE TABLE "PROJECTS"(
"UUID" VARCHAR(40) NOT NULL,
"KEE" VARCHAR(400) NOT NULL,
"QUALIFIER" VARCHAR(10) NOT NULL,
- "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
"NAME" VARCHAR(2000),
"DESCRIPTION" VARCHAR(2000),
"PRIVATE" BOOLEAN NOT NULL,
@@ -1011,7 +943,6 @@ CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES"("CE_TASK_UUID");
CREATE TABLE "WEBHOOKS"(
"UUID" VARCHAR(40) NOT NULL,
- "ORGANIZATION_UUID" VARCHAR(40),
"PROJECT_UUID" VARCHAR(40),
"NAME" VARCHAR(100) NOT NULL,
"URL" VARCHAR(2000) NOT NULL,
@@ -1020,5 +951,3 @@ CREATE TABLE "WEBHOOKS"(
"UPDATED_AT" BIGINT
);
ALTER TABLE "WEBHOOKS" ADD CONSTRAINT "PK_WEBHOOKS" PRIMARY KEY("UUID");
-CREATE INDEX "ORGANIZATION_WEBHOOK" ON "WEBHOOKS"("ORGANIZATION_UUID");
-CREATE INDEX "PROJECT_WEBHOOK" ON "WEBHOOKS"("PROJECT_UUID");
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
index 048fbb1017f..f772055ded1 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
@@ -261,7 +261,7 @@ public class CeQueueDaoTest {
@Test
public void test_delete_with_expected_status() {
insertPending(TASK_UUID_1, MAIN_COMPONENT_UUID_1);
- insertInProgress(TASK_UUID_2, MAIN_COMPONENT_UUID_1);
+ insertInProgress(TASK_UUID_2);
int deletedCount = underTest.deleteByUuid(db.getSession(), "UNKNOWN", null);
assertThat(deletedCount).isZero();
@@ -704,7 +704,6 @@ public class CeQueueDaoTest {
view.setQualifier("VW");
view.setDbKey(view_uuid + "_key");
view.setUuid(view_uuid);
- view.setOrganizationUuid("org_uuid");
view.setPrivate(false);
view.setRootUuid(view_uuid);
view.setUuidPath("uuid_path");
@@ -718,7 +717,6 @@ public class CeQueueDaoTest {
branch.setQualifier("TRK");
branch.setDbKey(uuid + "_key");
branch.setUuid(uuid);
- branch.setOrganizationUuid("org_uuid");
branch.setPrivate(false);
branch.setRootUuid(uuid);
branch.setUuidPath("uuid_path");
@@ -765,7 +763,7 @@ public class CeQueueDaoTest {
return dto;
}
- private CeQueueDto insertInProgress(String uuid, String componentUuid) {
+ private CeQueueDto insertInProgress(String uuid) {
CeQueueDto ceQueueDto = insertPending(uuid);
CeQueueTesting.makeInProgress(db.getSession(), "workerUuid", System2.INSTANCE.now(), ceQueueDto);
return underTest.selectByUuid(db.getSession(), uuid).get();
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ApplicationProjectsDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ApplicationProjectsDaoTest.java
index 64b3d78678d..2978143ebda 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ApplicationProjectsDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ApplicationProjectsDaoTest.java
@@ -126,7 +126,6 @@ public class ApplicationProjectsDaoTest {
"uuid", projectUuid,
"kee", projectUuid,
"qualifier", "TRK",
- "ORGANIZATION_UUID", "ORGANIZATION_UUID",
"private", true,
"updated_at", 1000L,
"created_at", 1000L);
@@ -137,7 +136,6 @@ public class ApplicationProjectsDaoTest {
"uuid", appUuid,
"kee", appUuid,
"qualifier", "APP",
- "ORGANIZATION_UUID", "ORGANIZATION_UUID",
"private", true,
"updated_at", 1000L,
"created_at", 1000L);
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
index 49e13ec3caf..3d0361eba79 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
@@ -120,7 +120,6 @@ public class ComponentDaoTest {
ComponentDto result = underTest.selectByUuid(dbSession, project.uuid()).get();
assertThat(result).isNotNull();
- assertThat(result.getOrganizationUuid()).isEqualTo(db.getDefaultOrganization().getUuid());
assertThat(result.uuid()).isEqualTo(project.uuid());
assertThat(result.getUuidPath()).isEqualTo(".");
assertThat(result.moduleUuid()).isNull();
@@ -198,7 +197,6 @@ public class ComponentDaoTest {
Optional<ComponentDto> optional = underTest.selectByKey(dbSession, file.getDbKey());
ComponentDto result = optional.get();
- assertThat(result.getOrganizationUuid()).isEqualTo(db.getDefaultOrganization().getUuid());
assertThat(result.uuid()).isEqualTo(file.uuid());
assertThat(result.getDbKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(result.path()).isEqualTo("src/RequestContext.java");
@@ -1246,9 +1244,9 @@ public class ComponentDaoTest {
@Test
public void updateBEnabledToFalse() {
- ComponentDto dto1 = newPrivateProjectDto(db.getDefaultOrganization(), "U1");
- ComponentDto dto2 = newPrivateProjectDto(db.getDefaultOrganization(), "U2");
- ComponentDto dto3 = newPrivateProjectDto(db.getDefaultOrganization(), "U3");
+ ComponentDto dto1 = newPrivateProjectDto("U1");
+ ComponentDto dto2 = newPrivateProjectDto("U2");
+ ComponentDto dto3 = newPrivateProjectDto("U3");
underTest.insert(dbSession, dto1, dto2, dto3);
underTest.updateBEnabledToFalse(dbSession, asList("U1", "U2"));
@@ -1708,7 +1706,6 @@ public class ComponentDaoTest {
List<ComponentDto> components = underTest.selectDescendants(dbSession, dbQuery);
assertThat(components).extracting("uuid").containsOnly("project-copy-uuid", "subview-uuid");
- assertThat(components).extracting("organizationUuid").containsOnly(db.getDefaultOrganization().getUuid());
}
@Test
@@ -1774,7 +1771,7 @@ public class ComponentDaoTest {
// public project - not returned
insertMeasure(11d, db.components().insertPublicProject(b -> b.setName("other")), metric);
- List<ProjectNclocDistributionDto> result = underTest.selectPrivateProjectsWithNcloc(db.getSession(), db.getDefaultOrganization().getUuid());
+ List<ProjectNclocDistributionDto> result = underTest.selectPrivateProjectsWithNcloc(db.getSession());
assertThat(result).extracting(ProjectNclocDistributionDto::getName).containsExactly("foo", "bar");
assertThat(result).extracting(ProjectNclocDistributionDto::getNcloc).containsExactly(30L, 10L);
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
index fa68680ce63..cbc62eff9b0 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
@@ -300,7 +300,7 @@ public class ComponentKeyUpdaterDaoTest {
@Test
public void bulk_update_key_updates_disabled_components() {
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(db.getDefaultOrganization(), "A").setDbKey("my_project"));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto("A").setDbKey("my_project"));
db.components().insertComponent(newModuleDto(project).setDbKey("my_project:module"));
db.components().insertComponent(newModuleDto(project).setDbKey("my_project:inactive_module").setEnabled(false));
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
index 75d9255cf6b..73e21debb12 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
@@ -183,7 +183,7 @@ public class IssueDaoTest {
.extracting(IssueDto::getKey)
.containsExactlyInAnyOrder(Arrays.stream(new IssueDto[] {openIssue1OnFile, openIssue2OnFile, openIssueOnModule}).map(IssueDto::getKey).toArray(String[]::new));
- ComponentDto notPersisted = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto notPersisted = ComponentTesting.newPrivateProjectDto();
assertThat(underTest.selectNonClosedByModuleOrProjectExcludingExternalsAndSecurityHotspots(db.getSession(), notPersisted)).isEmpty();
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
index 3da71f268de..76ebd5c01b4 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
@@ -278,7 +278,7 @@ public class LiveMeasureDaoTest {
@Test
public void selectTreeByQuery_with_empty_results() {
List<LiveMeasureDto> results = new ArrayList<>();
- underTest.selectTreeByQuery(db.getSession(), newPrivateProjectDto(db.getDefaultOrganization()),
+ underTest.selectTreeByQuery(db.getSession(), newPrivateProjectDto(),
MeasureTreeQuery.builder().setStrategy(MeasureTreeQuery.Strategy.LEAVES).build(),
context -> results.add(context.getResultObject()));
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java
index fb1ecc0691e..9ef680c18b9 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java
@@ -95,7 +95,7 @@ public class AuthorizationDaoTest {
* - anyone
*/
@Test
- public void selectOrganizationPermissions_for_logged_in_user() {
+ public void selectGlobalPermissions_for_logged_in_user() {
ComponentDto project = db.components().insertPrivateProject();
db.users().insertMember(group1, user);
db.users().insertPermissionOnUser(user, "perm1");
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java
index 67dace551e8..83f288cb5ec 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java
@@ -188,7 +188,7 @@ public class GroupPermissionDaoTest {
GroupDto group2 = db.users().insertGroup("Group-2");
GroupDto group3 = db.users().insertGroup("Group-3");
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
+ ComponentDto project = db.components().insertPrivateProject();
db.users().insertPermissionOnAnyone(SCAN);
db.users().insertPermissionOnAnyone(PROVISION_PROJECTS);
@@ -295,7 +295,7 @@ public class GroupPermissionDaoTest {
db.users().insertPermissionOnGroup(group1, SCAN);
GroupDto group2 = db.users().insertGroup("Group-2");
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()));
+ ComponentDto project = db.components().insertPrivateProject();
db.users().insertProjectPermissionOnGroup(group2, UserRole.ADMIN, project);
GroupDto group3 = db.users().insertGroup("Group-3");
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java
index f245f56bc99..236d26bb5f4 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java
@@ -79,7 +79,7 @@ public class UserPermissionDaoTest {
PermissionQuery query = PermissionQuery.builder().withAtLeastOnePermission().build();
expectPermissions(query, asList(user2.getUuid(), user1.getUuid()), global2, global3, global1);
- // default query returns all users, whatever their permissions nor organizations
+ // default query returns all users, whatever their permissions
// (that's a non-sense, but still this is required for api/permissions/groups
// when filtering users by name)
query = PermissionQuery.builder().build();
@@ -148,7 +148,7 @@ public class UserPermissionDaoTest {
expectPermissions(query, emptyList());
// permissions of unknown project
- query = PermissionQuery.builder().setComponent(newPrivateProjectDto(db.getDefaultOrganization())).withAtLeastOnePermission().build();
+ query = PermissionQuery.builder().setComponent(newPrivateProjectDto()).withAtLeastOnePermission().build();
expectPermissions(query, emptyList());
}
@@ -268,7 +268,7 @@ public class UserPermissionDaoTest {
assertThat(underTest.selectUserUuidsByQuery(dbSession, query)).isEmpty();
// on a project without permissions
- query = PermissionQuery.builder().setComponent(newPrivateProjectDto(db.getDefaultOrganization())).withAtLeastOnePermission().build();
+ query = PermissionQuery.builder().setComponent(newPrivateProjectDto()).withAtLeastOnePermission().build();
assertThat(underTest.selectUserUuidsByQuery(dbSession, query)).isEmpty();
// search all users whose name matches "mar", whatever the permissions
@@ -285,7 +285,7 @@ public class UserPermissionDaoTest {
}
@Test
- public void selectUserUuidsByQueryAndScope_with_organization_scope() {
+ public void selectUserUuidsByQueryAndScope_with_global_scope() {
UserDto user1 = insertUser(u -> u.setLogin("login1").setName("Marius").setEmail("email1@email.com"));
UserDto user2 = insertUser(u -> u.setLogin("login2").setName("Marie").setEmail("email2@email.com"));
ComponentDto project1 = db.components().insertPrivateProject();
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java
index 530e21421d4..7e41b324a70 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java
@@ -32,7 +32,6 @@ import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.user.GroupDto;
import org.sonar.db.user.UserDto;
@@ -392,19 +391,4 @@ public class PermissionTemplateDaoTest {
.extracting((row) -> row.get("templateUuid"), (row) -> row.get("userUuid"), (row) -> row.get("permission"))
.containsOnly(tuple(template.getUuid(), anotherUser.getUuid(), permission));
}
-
- private PermissionTemplateDto createTemplate(OrganizationDto organization) {
- UserDto user = db.users().insertUser();
- GroupDto group = db.users().insertGroup();
- db.users().insertMember(group, user);
- PermissionTemplateDto template = templateDb.insertTemplate();
- templateDb.addProjectCreatorToTemplate(template.getUuid(), SCAN_EXECUTION);
- templateDb.addProjectCreatorToTemplate(template.getUuid(), UserRole.ADMIN);
- templateDb.addUserToTemplate(template.getUuid(), user.getUuid(), UserRole.USER);
- templateDb.addUserToTemplate(template.getUuid(), user.getUuid(), UserRole.ADMIN);
- templateDb.addGroupToTemplate(template.getUuid(), group.getUuid(), UserRole.CODEVIEWER);
- templateDb.addGroupToTemplate(template.getUuid(), group.getUuid(), UserRole.ADMIN);
- templateDb.addGroupToTemplate(template.getUuid(), null, UserRole.ISSUE_ADMIN);
- return template;
- }
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/project/ProjectDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/project/ProjectDaoTest.java
index be81eda24ef..e89b99f3571 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/project/ProjectDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/project/ProjectDaoTest.java
@@ -52,7 +52,7 @@ public class ProjectDaoTest {
Optional<ProjectDto> projectByUuid = projectDao.selectByUuid(db.getSession(), "uuid_o1_p1");
assertThat(projectByUuid).isPresent();
- assertProject(projectByUuid.get(), "projectName_p1", "projectKee_o1_p1", "org_o1", "uuid_o1_p1", "desc_p1", "tag1,tag2", false);
+ assertProject(projectByUuid.get(), "projectName_p1", "projectKee_o1_p1", "uuid_o1_p1", "desc_p1", "tag1,tag2", false);
assertThat(projectByUuid.get().isPrivate()).isFalse();
}
@@ -64,7 +64,7 @@ public class ProjectDaoTest {
Optional<ProjectDto> projectByKee = projectDao.selectProjectByKey(db.getSession(), "projectKee_o1_p1");
assertThat(projectByKee).isPresent();
- assertProject(projectByKee.get(), "projectName_p1", "projectKee_o1_p1", "org_o1", "uuid_o1_p1", "desc_p1", "tag1,tag2", false);
+ assertProject(projectByKee.get(), "projectName_p1", "projectKee_o1_p1", "uuid_o1_p1", "desc_p1", "tag1,tag2", false);
}
@Test
@@ -91,12 +91,12 @@ public class ProjectDaoTest {
List<ProjectDto> projectsByOrg = projectDao.selectAll(db.getSession());
assertThat(projectsByOrg)
- .extracting(ProjectDto::getName, ProjectDto::getKey, ProjectDto::getOrganizationUuid, ProjectDto::getUuid, ProjectDto::getDescription,
+ .extracting(ProjectDto::getName, ProjectDto::getKey, ProjectDto::getUuid, ProjectDto::getDescription,
ProjectDto::getTagsString, ProjectDto::isPrivate)
.containsExactlyInAnyOrder(
- tuple("projectName_p1", "projectKee_o1_p1", "org_o1", "uuid_o1_p1", "desc_p1", "tag1,tag2", false),
- tuple("projectName_p2", "projectKee_o1_p2", "org_o1", "uuid_o1_p2", "desc_p2", "tag1,tag2", false),
- tuple("projectName_p1", "projectKee_o2_p1", "org_o2", "uuid_o2_p1", "desc_p1", "tag1,tag2", false));
+ tuple("projectName_p1", "projectKee_o1_p1", "uuid_o1_p1", "desc_p1", "tag1,tag2", false),
+ tuple("projectName_p2", "projectKee_o1_p2", "uuid_o1_p2", "desc_p2", "tag1,tag2", false),
+ tuple("projectName_p1", "projectKee_o2_p1", "uuid_o2_p1", "desc_p1", "tag1,tag2", false));
}
@Test
@@ -109,8 +109,8 @@ public class ProjectDaoTest {
List<ProjectDto> projectsByUuids = projectDao.selectByUuids(db.getSession(), new HashSet<>(Arrays.asList("uuid_o1_p1", "uuid_o1_p2")));
assertThat(projectsByUuids).hasSize(2);
- assertProject(projectsByUuids.get(0), "projectName_p1", "projectKee_o1_p1", "org_o1", "uuid_o1_p1", "desc_p1", null, false);
- assertProject(projectsByUuids.get(1), "projectName_p2", "projectKee_o1_p2", "org_o1", "uuid_o1_p2", "desc_p2", "tag1,tag2", false);
+ assertProject(projectsByUuids.get(0), "projectName_p1", "projectKee_o1_p1", "uuid_o1_p1", "desc_p1", null, false);
+ assertProject(projectsByUuids.get(1), "projectName_p2", "projectKee_o1_p2", "uuid_o1_p2", "desc_p2", "tag1,tag2", false);
dto1.setTags(Collections.singletonList("tag3"));
dto2.setTagsString("");
@@ -119,8 +119,8 @@ public class ProjectDaoTest {
projectsByUuids = projectDao.selectByUuids(db.getSession(), new HashSet<>(Arrays.asList("uuid_o1_p1", "uuid_o1_p2")));
assertThat(projectsByUuids).hasSize(2);
- assertProject(projectsByUuids.get(0), "projectName_p1", "projectKee_o1_p1", "org_o1", "uuid_o1_p1", "desc_p1", "tag3", false);
- assertProject(projectsByUuids.get(1), "projectName_p2", "projectKee_o1_p2", "org_o1", "uuid_o1_p2", "desc_p2", null, false);
+ assertProject(projectsByUuids.get(0), "projectName_p1", "projectKee_o1_p1", "uuid_o1_p1", "desc_p1", "tag3", false);
+ assertProject(projectsByUuids.get(1), "projectName_p2", "projectKee_o1_p2", "uuid_o1_p2", "desc_p2", null, false);
assertThat(projectsByUuids.get(0).getTags()).containsOnly("tag3");
}
@@ -135,16 +135,16 @@ public class ProjectDaoTest {
List<ProjectDto> projectsByUuids = projectDao.selectByUuids(db.getSession(), new HashSet<>(Arrays.asList("uuid_o1_p1", "uuid_o1_p2")));
assertThat(projectsByUuids).hasSize(2);
- assertProject(projectsByUuids.get(0), "projectName_p1", "projectKee_o1_p1", "org_o1", "uuid_o1_p1", "desc_p1", "tag1,tag2", true);
- assertProject(projectsByUuids.get(1), "projectName_p2", "projectKee_o1_p2", "org_o1", "uuid_o1_p2", "desc_p2", "tag1,tag2", false);
+ assertProject(projectsByUuids.get(0), "projectName_p1", "projectKee_o1_p1", "uuid_o1_p1", "desc_p1", "tag1,tag2", true);
+ assertProject(projectsByUuids.get(1), "projectName_p2", "projectKee_o1_p2", "uuid_o1_p2", "desc_p2", "tag1,tag2", false);
projectDao.updateVisibility(db.getSession(), dto1.getUuid(), false);
projectDao.updateVisibility(db.getSession(), dto2.getUuid(), true);
projectsByUuids = projectDao.selectByUuids(db.getSession(), new HashSet<>(Arrays.asList("uuid_o1_p1", "uuid_o1_p2")));
assertThat(projectsByUuids).hasSize(2);
- assertProject(projectsByUuids.get(0), "projectName_p1", "projectKee_o1_p1", "org_o1", "uuid_o1_p1", "desc_p1", "tag1,tag2", false);
- assertProject(projectsByUuids.get(1), "projectName_p2", "projectKee_o1_p2", "org_o1", "uuid_o1_p2", "desc_p2", "tag1,tag2", true);
+ assertProject(projectsByUuids.get(0), "projectName_p1", "projectKee_o1_p1", "uuid_o1_p1", "desc_p1", "tag1,tag2", false);
+ assertProject(projectsByUuids.get(1), "projectName_p2", "projectKee_o1_p2", "uuid_o1_p2", "desc_p2", "tag1,tag2", true);
}
@Test
@@ -159,8 +159,8 @@ public class ProjectDaoTest {
List<ProjectDto> projectsByUuids = projectDao.selectByUuids(db.getSession(), new HashSet<>(Arrays.asList("uuid_o1_p1", "uuid_o1_p2")));
assertThat(projectsByUuids).hasSize(2);
- assertProject(projectsByUuids.get(0), "projectName_p1", "projectKee_o1_p1", "org_o1", "uuid_o1_p1", "desc_p1", "tag1,tag2", false);
- assertProject(projectsByUuids.get(1), "projectName_p2", "projectKee_o1_p2", "org_o1", "uuid_o1_p2", "desc_p2", "tag1,tag2", false);
+ assertProject(projectsByUuids.get(0), "projectName_p1", "projectKee_o1_p1", "uuid_o1_p1", "desc_p1", "tag1,tag2", false);
+ assertProject(projectsByUuids.get(1), "projectName_p2", "projectKee_o1_p2", "uuid_o1_p2", "desc_p2", "tag1,tag2", false);
}
@Test
@@ -177,9 +177,9 @@ public class ProjectDaoTest {
assertThat(projectsByUuids).isEmpty();
}
- private void assertProject(ProjectDto dto, String name, String kee, String org, String uuid, String desc, @Nullable String tags, boolean isPrivate) {
- assertThat(dto).extracting("name", "kee", "key", "organizationUuid", "uuid", "description", "tagsString", "private")
- .containsExactly(name, kee, kee, org, uuid, desc, tags, isPrivate);
+ private void assertProject(ProjectDto dto, String name, String kee, String uuid, String desc, @Nullable String tags, boolean isPrivate) {
+ assertThat(dto).extracting("name", "kee", "key","uuid", "description", "tagsString", "private")
+ .containsExactly(name, kee, kee, uuid, desc, tags, isPrivate);
}
private ProjectDto createProject(String org, String name) {
@@ -187,7 +187,6 @@ public class ProjectDaoTest {
.setName("projectName_" + name)
.setKey("projectKee_" + org + "_" + name)
.setQualifier(Qualifiers.PROJECT)
- .setOrganizationUuid("org_" + org)
.setUuid("uuid_" + org + "_" + name)
.setTags(Arrays.asList("tag1", "tag2"))
.setDescription("desc_" + name)
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
index 689ada7edba..29521b96f0d 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
@@ -688,27 +688,27 @@ public class PropertiesDaoTest {
.hasNoComponentUuid()
.hasNoUserUuid()
.isEmpty()
- .hasCreatedAt(INITIAL_DATE + 2);
+ .hasCreatedAt(INITIAL_DATE);
assertThatPropertiesRow("global.empty")
.hasNoComponentUuid()
.hasNoUserUuid()
.isEmpty()
- .hasCreatedAt(INITIAL_DATE + 3);
+ .hasCreatedAt(INITIAL_DATE + 1);
assertThatPropertiesRow("global.text")
.hasNoComponentUuid()
.hasNoUserUuid()
.hasTextValue("some text")
- .hasCreatedAt(INITIAL_DATE + 4);
+ .hasCreatedAt(INITIAL_DATE + 2);
assertThatPropertiesRow("global.4000")
.hasNoComponentUuid()
.hasNoUserUuid()
.hasTextValue(VALUE_SIZE_4000)
- .hasCreatedAt(INITIAL_DATE + 5);
+ .hasCreatedAt(INITIAL_DATE + 3);
assertThatPropertiesRow("global.clob")
.hasNoComponentUuid()
.hasNoUserUuid()
.hasClobValue(VALUE_SIZE_4001)
- .hasCreatedAt(INITIAL_DATE + 6);
+ .hasCreatedAt(INITIAL_DATE + 4);
}
@Test
@@ -724,27 +724,27 @@ public class PropertiesDaoTest {
.hasComponentUuid(componentUuid)
.hasNoUserUuid()
.isEmpty()
- .hasCreatedAt(INITIAL_DATE + 2);
+ .hasCreatedAt(INITIAL_DATE);
assertThatPropertiesRow("component.empty")
.hasComponentUuid(componentUuid)
.hasNoUserUuid()
.isEmpty()
- .hasCreatedAt(INITIAL_DATE + 3);
+ .hasCreatedAt(INITIAL_DATE + 1);
assertThatPropertiesRow("component.text")
.hasComponentUuid(componentUuid)
.hasNoUserUuid()
.hasTextValue("some text")
- .hasCreatedAt(INITIAL_DATE + 4);
+ .hasCreatedAt(INITIAL_DATE + 2);
assertThatPropertiesRow("component.4000")
.hasComponentUuid(componentUuid)
.hasNoUserUuid()
.hasTextValue(VALUE_SIZE_4000)
- .hasCreatedAt(INITIAL_DATE + 5);
+ .hasCreatedAt(INITIAL_DATE + 3);
assertThatPropertiesRow("component.clob")
.hasComponentUuid(componentUuid)
.hasNoUserUuid()
.hasClobValue(VALUE_SIZE_4001)
- .hasCreatedAt(INITIAL_DATE + 6);
+ .hasCreatedAt(INITIAL_DATE + 4);
}
@Test
@@ -760,27 +760,27 @@ public class PropertiesDaoTest {
.hasNoComponentUuid()
.hasUserUuid(userUuid)
.isEmpty()
- .hasCreatedAt(INITIAL_DATE + 2);
+ .hasCreatedAt(INITIAL_DATE);
assertThatPropertiesRow("user.empty")
.hasNoComponentUuid()
.hasUserUuid(userUuid)
.isEmpty()
- .hasCreatedAt(INITIAL_DATE + 3);
+ .hasCreatedAt(INITIAL_DATE + 1);
assertThatPropertiesRow("user.text")
.hasNoComponentUuid()
.hasUserUuid(userUuid)
.hasTextValue("some text")
- .hasCreatedAt(INITIAL_DATE + 4);
+ .hasCreatedAt(INITIAL_DATE + 2);
assertThatPropertiesRow("user.4000")
.hasNoComponentUuid()
.hasUserUuid(userUuid)
.hasTextValue(VALUE_SIZE_4000)
- .hasCreatedAt(INITIAL_DATE + 5);
+ .hasCreatedAt(INITIAL_DATE + 3);
assertThatPropertiesRow("user.clob")
.hasNoComponentUuid()
.hasUserUuid(userUuid)
.hasClobValue(VALUE_SIZE_4001)
- .hasCreatedAt(INITIAL_DATE + 6);
+ .hasCreatedAt(INITIAL_DATE + 4);
}
@Test
@@ -796,7 +796,7 @@ public class PropertiesDaoTest {
PropertiesRowAssert propertiesRowAssert = assertThatPropertiesRow("global")
.hasNoComponentUuid()
.hasNoUserUuid()
- .hasCreatedAt(INITIAL_DATE + 3);
+ .hasCreatedAt(INITIAL_DATE + 1);
if (newValue == null || newValue.isEmpty()) {
propertiesRowAssert.isEmpty();
} else if (newValue.length() > 4000) {
@@ -819,7 +819,7 @@ public class PropertiesDaoTest {
PropertiesRowAssert propertiesRowAssert = assertThatPropertiesRow("global")
.hasComponentUuid(componentUuid)
.hasNoUserUuid()
- .hasCreatedAt(INITIAL_DATE + 3);
+ .hasCreatedAt(INITIAL_DATE + 1);
if (newValue == null || newValue.isEmpty()) {
propertiesRowAssert.isEmpty();
} else if (newValue.length() > 4000) {
@@ -843,7 +843,7 @@ public class PropertiesDaoTest {
PropertiesRowAssert propertiesRowAssert = assertThatPropertiesRow("global")
.hasNoComponentUuid()
.hasUserUuid(userUuid)
- .hasCreatedAt(INITIAL_DATE + 3);
+ .hasCreatedAt(INITIAL_DATE + 1);
if (newValue == null || newValue.isEmpty()) {
propertiesRowAssert.isEmpty();
} else if (newValue.length() > 4000) {
@@ -1082,27 +1082,27 @@ public class PropertiesDaoTest {
.hasNoComponentUuid()
.hasNoUserUuid()
.isEmpty()
- .hasCreatedAt(INITIAL_DATE + 2);
+ .hasCreatedAt(INITIAL_DATE);
assertThatPropertiesRow("empty_value_property")
.hasNoComponentUuid()
.hasNoUserUuid()
.isEmpty()
- .hasCreatedAt(INITIAL_DATE + 3);
+ .hasCreatedAt(INITIAL_DATE + 1);
assertThatPropertiesRow("text_value_property")
.hasNoComponentUuid()
.hasNoUserUuid()
.hasTextValue("dfdsfsd")
- .hasCreatedAt(INITIAL_DATE + 4);
+ .hasCreatedAt(INITIAL_DATE + 2);
assertThatPropertiesRow("4000_char_value_property")
.hasNoComponentUuid()
.hasNoUserUuid()
.hasTextValue(VALUE_SIZE_4000)
- .hasCreatedAt(INITIAL_DATE + 5);
+ .hasCreatedAt(INITIAL_DATE + 3);
assertThatPropertiesRow("clob_value_property")
.hasNoComponentUuid()
.hasNoUserUuid()
.hasClobValue(VALUE_SIZE_4001)
- .hasCreatedAt(INITIAL_DATE + 6);
+ .hasCreatedAt(INITIAL_DATE + 4);
}
@Test
@@ -1118,7 +1118,7 @@ public class PropertiesDaoTest {
.hasNoComponentUuid()
.hasNoUserUuid()
.hasTextValue("new value")
- .hasCreatedAt(INITIAL_DATE + 3);
+ .hasCreatedAt(INITIAL_DATE + 1);
}
private static Map<String, String> mapOf(String... values) {
@@ -1147,37 +1147,37 @@ public class PropertiesDaoTest {
.hasNoUserUuid()
.hasNoComponentUuid()
.hasTextValue("bar")
- .hasCreatedAt(INITIAL_DATE + 2);
+ .hasCreatedAt(INITIAL_DATE);
assertThatPropertiesRowByUuid(uuid2)
.hasKey("new_name")
.hasNoComponentUuid()
.hasNoUserUuid()
.hasTextValue("doc1")
- .hasCreatedAt(INITIAL_DATE + 3);
+ .hasCreatedAt(INITIAL_DATE + 1);
assertThatPropertiesRowByUuid(uuid3)
.hasKey("new_name")
.hasComponentUuid("15")
.hasNoUserUuid()
.hasTextValue("doc2")
- .hasCreatedAt(INITIAL_DATE + 4);
+ .hasCreatedAt(INITIAL_DATE + 2);
assertThatPropertiesRowByUuid(uuid4)
.hasKey("new_name")
.hasComponentUuid("16")
.hasNoUserUuid()
.hasTextValue("doc3")
- .hasCreatedAt(INITIAL_DATE + 5);
+ .hasCreatedAt(INITIAL_DATE + 3);
assertThatPropertiesRowByUuid(uuid5)
.hasKey("new_name")
.hasNoComponentUuid()
.hasUserUuid("100")
.hasTextValue("doc4")
- .hasCreatedAt(INITIAL_DATE + 6);
+ .hasCreatedAt(INITIAL_DATE + 4);
assertThatPropertiesRowByUuid(uuid6)
.hasKey("new_name")
.hasNoComponentUuid()
.hasUserUuid("101")
.hasTextValue("doc5")
- .hasCreatedAt(INITIAL_DATE + 7);
+ .hasCreatedAt(INITIAL_DATE + 5);
}
@Test
@@ -1185,7 +1185,7 @@ public class PropertiesDaoTest {
String uuid = insertProperty("foo", "bar", null, null);
assertThatPropertiesRowByUuid(uuid)
- .hasCreatedAt(INITIAL_DATE + 2);
+ .hasCreatedAt(INITIAL_DATE);
underTest.renamePropertyKey("foo", "foo");
@@ -1194,7 +1194,7 @@ public class PropertiesDaoTest {
.hasNoUserUuid()
.hasNoComponentUuid()
.hasTextValue("bar")
- .hasCreatedAt(INITIAL_DATE + 2);
+ .hasCreatedAt(INITIAL_DATE);
}
@Test
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
index 9b254616fb9..38e563b2b51 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
@@ -331,7 +331,7 @@ public class PurgeDaoTest {
@Test
public void deleteAnalyses_deletes_rows_in_events_and_event_component_changes() {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project);
SnapshotDto projectAnalysis1 = db.components().insertSnapshot(project);
SnapshotDto projectAnalysis2 = db.components().insertSnapshot(project);
@@ -644,8 +644,8 @@ public class PurgeDaoTest {
@Test
public void delete_row_in_ce_activity_when_deleting_project() {
- ComponentDto projectToBeDeleted = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
- ComponentDto anotherLivingProject = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto projectToBeDeleted = ComponentTesting.newPrivateProjectDto();
+ ComponentDto anotherLivingProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, projectToBeDeleted, anotherLivingProject);
// Insert 2 rows in CE_ACTIVITY : one for the project that will be deleted, and one on another project
@@ -663,10 +663,10 @@ public class PurgeDaoTest {
@Test
public void delete_row_in_ce_task_input_referring_to_a_row_in_ce_activity_when_deleting_project() {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto branch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherBranch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
- ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project, branch, anotherBranch, anotherProject);
CeActivityDto projectTask = insertCeActivity(project);
@@ -695,10 +695,10 @@ public class PurgeDaoTest {
@Test
public void delete_row_in_ce_scanner_context_referring_to_a_row_in_ce_activity_when_deleting_project() {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto branch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherBranch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
- ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project, branch, anotherBranch, anotherProject);
CeActivityDto projectTask = insertCeActivity(project);
@@ -727,10 +727,10 @@ public class PurgeDaoTest {
@Test
public void delete_row_in_ce_task_characteristics_referring_to_a_row_in_ce_activity_when_deleting_project() {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto branch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherBranch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
- ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project, branch, anotherBranch, anotherProject);
CeActivityDto projectTask = insertCeActivity(project);
@@ -759,10 +759,10 @@ public class PurgeDaoTest {
@Test
public void delete_row_in_ce_task_message_referring_to_a_row_in_ce_activity_when_deleting_project() {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto branch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherBranch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
- ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project, branch, anotherBranch, anotherProject);
CeActivityDto projectTask = insertCeActivity(project);
@@ -829,10 +829,10 @@ public class PurgeDaoTest {
@Test
public void delete_row_in_ce_task_input_referring_to_a_row_in_ce_queue_when_deleting_project() {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto branch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherBranch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
- ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project, branch, anotherBranch, anotherProject);
CeQueueDto projectTask = insertCeQueue(project);
@@ -861,10 +861,10 @@ public class PurgeDaoTest {
@Test
public void delete_row_in_ce_scanner_context_referring_to_a_row_in_ce_queue_when_deleting_project() {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto branch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherBranch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
- ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project, branch, anotherBranch, anotherProject);
CeQueueDto projectTask = insertCeQueue(project);
@@ -894,10 +894,10 @@ public class PurgeDaoTest {
@Test
public void delete_row_in_ce_task_characteristics_referring_to_a_row_in_ce_queue_when_deleting_project() {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto branch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherBranch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
- ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project, branch, anotherBranch, anotherProject);
CeQueueDto projectTask = insertCeQueue(project);
@@ -927,10 +927,10 @@ public class PurgeDaoTest {
@Test
public void delete_row_in_ce_task_message_referring_to_a_row_in_ce_queue_when_deleting_project() {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto branch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherBranch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
- ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project, branch, anotherBranch, anotherProject);
CeQueueDto projectTask = insertCeQueue(project);
@@ -960,10 +960,10 @@ public class PurgeDaoTest {
@Test
public void delete_row_in_events_and_event_component_changes_when_deleting_project() {
- ComponentDto project = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto branch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherBranch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
- ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
+ ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project, branch, anotherBranch, anotherProject);
SnapshotDto projectAnalysis1 = db.components().insertSnapshot(project);
SnapshotDto projectAnalysis2 = db.components().insertSnapshot(project);
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java
index f55f4b3f85a..36e09eb8f5b 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java
@@ -562,7 +562,7 @@ public class ActiveRuleDaoTest {
}
@Test
- public void deleteParamsByRuleParamOfAllOrganizations() {
+ public void deleteParamsByRuleParam() {
ActiveRuleDto activeRule1 = createFor(profile1, rule1).setSeverity(BLOCKER);
underTest.insert(dbSession, activeRule1);
ActiveRuleParamDto activeRuleParam1 = ActiveRuleParamDto.createFor(rule1Param1).setValue("foo");
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java
index ea1ae677937..f6a7eea6954 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java
@@ -34,7 +34,6 @@ import org.sonar.db.DatabaseUtils;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.project.ProjectDto;
import static java.util.Arrays.asList;
@@ -479,30 +478,6 @@ public class UserDaoTest {
}
@Test
- public void clean_users_homepage_when_deleting_organization() {
-
- UserDto userUnderTest = newUserDto().setHomepageType("ORGANIZATION").setHomepageParameter("dummy-organization-UUID");
- underTest.insert(session, userUnderTest);
-
- UserDto untouchedUser = newUserDto().setHomepageType("ORGANIZATION").setHomepageParameter("not-so-dummy-organization-UUID");
- underTest.insert(session, untouchedUser);
-
- session.commit();
-
- underTest.cleanHomepage(session, new OrganizationDto().setUuid("dummy-organization-UUID"));
-
- UserDto userWithAHomepageReloaded = underTest.selectByUuid(session, userUnderTest.getUuid());
- assertThat(userWithAHomepageReloaded.getUpdatedAt()).isEqualTo(NOW);
- assertThat(userWithAHomepageReloaded.getHomepageType()).isNull();
- assertThat(userWithAHomepageReloaded.getHomepageParameter()).isNull();
-
- UserDto untouchedUserReloaded = underTest.selectByUuid(session, untouchedUser.getUuid());
- assertThat(untouchedUserReloaded.getUpdatedAt()).isEqualTo(untouchedUser.getUpdatedAt());
- assertThat(untouchedUserReloaded.getHomepageType()).isEqualTo(untouchedUser.getHomepageType());
- assertThat(untouchedUserReloaded.getHomepageParameter()).isEqualTo(untouchedUser.getHomepageParameter());
- }
-
- @Test
public void clean_users_homepage_when_deleting_project() {
UserDto userUnderTest = newUserDto().setHomepageType("PROJECT").setHomepageParameter("dummy-project-UUID");
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoTest.java
index 5d96fd79332..c9484b6a205 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoTest.java
@@ -32,7 +32,6 @@ import org.sonar.db.component.ComponentDbTester;
import org.sonar.db.project.ProjectDto;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class WebhookDaoTest {
@@ -110,7 +109,6 @@ public class WebhookDaoTest {
assertThat(stored.getUuid()).isEqualTo(dto.getUuid());
assertThat(stored.getName()).isEqualTo(dto.getName());
assertThat(stored.getUrl()).isEqualTo(dto.getUrl());
- assertThat(stored.getOrganizationUuid()).isEqualTo(dbTester.getDefaultOrganization().getUuid());
assertThat(stored.getProjectUuid()).isNull();
assertThat(stored.getSecret()).isEqualTo(dto.getSecret());
assertThat(new Date(stored.getCreatedAt())).isInSameMinuteWindowAs(new Date(system2.now()));
@@ -133,7 +131,6 @@ public class WebhookDaoTest {
assertThat(reloaded.getUuid()).isEqualTo(dto.getUuid());
assertThat(reloaded.getName()).isEqualTo(dto.getName());
assertThat(reloaded.getUrl()).isEqualTo(dto.getUrl());
- assertThat(reloaded.getOrganizationUuid()).isNull();
assertThat(reloaded.getProjectUuid()).isEqualTo(dto.getProjectUuid());
assertThat(reloaded.getSecret()).isEqualTo(dto.getSecret());
assertThat(new Date(reloaded.getCreatedAt())).isInSameMinuteWindowAs(new Date(system2.now()));
@@ -156,7 +153,6 @@ public class WebhookDaoTest {
assertThat(reloaded.getName()).isEqualTo("a-fancy-webhook");
assertThat(reloaded.getUrl()).isEqualTo("http://www.fancy-webhook.io");
assertThat(reloaded.getProjectUuid()).isNull();
- assertThat(reloaded.getOrganizationUuid()).isEqualTo(dto.getOrganizationUuid());
assertThat(reloaded.getSecret()).isNull();
assertThat(reloaded.getCreatedAt()).isEqualTo(dto.getCreatedAt());
assertThat(new Date(reloaded.getUpdatedAt())).isInSameMinuteWindowAs(new Date(system2.now()));
@@ -178,7 +174,6 @@ public class WebhookDaoTest {
assertThat(reloaded.getName()).isEqualTo("a-fancy-webhook");
assertThat(reloaded.getUrl()).isEqualTo("http://www.fancy-webhook.io");
assertThat(reloaded.getProjectUuid()).isNull();
- assertThat(reloaded.getOrganizationUuid()).isEqualTo(dto.getOrganizationUuid());
assertThat(reloaded.getSecret()).isEqualTo("a_new_secret");
assertThat(reloaded.getCreatedAt()).isEqualTo(dto.getCreatedAt());
assertThat(new Date(reloaded.getUpdatedAt())).isInSameMinuteWindowAs(new Date(system2.now()));
@@ -209,7 +204,7 @@ public class WebhookDaoTest {
}
@Test
- public void set_default_org_if_webhook_does_not_have_a_project_nor_organization() {
+ public void set_default_org_if_webhook_does_not_have_a_project() {
WebhookDto dto = new WebhookDto()
.setUuid("UUID_1")
.setName("NAME_1")
@@ -219,21 +214,6 @@ public class WebhookDaoTest {
Optional<WebhookDto> reloaded = underTest.selectByUuid(dbSession, dto.getUuid());
assertThat(reloaded).isPresent();
- assertThat(reloaded.get().getOrganizationUuid()).isEqualTo(dbTester.getDefaultOrganization().getUuid());
- }
-
- @Test
- public void fail_if_webhook_have_both_an_organization_nor_a_project() {
- WebhookDto dto = new WebhookDto()
- .setUuid("UUID_1")
- .setName("NAME_1")
- .setUrl("URL_1")
- .setOrganizationUuid("UUID_2")
- .setProjectUuid("UUID_3");
-
- assertThatThrownBy(() -> underTest.insert(dbSession, dto))
- .isInstanceOf(IllegalStateException.class)
- .hasMessage("A webhook can not be linked to both an organization and a project.");
}
private WebhookDto selectByUuid(String uuid) {
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java
index bfd9fcdd4de..738fe67b75f 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java
@@ -40,7 +40,7 @@ public class WebhookDeliveryDaoTest {
private static final long BEFORE = NOW - 1_000L;
@Rule
- public final DbTester dbTester = DbTester.create(System2.INSTANCE).setDisableDefaultOrganization(true);
+ public final DbTester dbTester = DbTester.create(System2.INSTANCE);
@Rule
public ExpectedException expectedException = ExpectedException.none();
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java
index 122983323e3..c71125da615 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java
@@ -42,7 +42,6 @@ import org.sonar.db.issue.IssueDbTester;
import org.sonar.db.measure.MeasureDbTester;
import org.sonar.db.newcodeperiod.NewCodePeriodDbTester;
import org.sonar.db.notification.NotificationDbTester;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.permission.template.PermissionTemplateDbTester;
import org.sonar.db.plugin.PluginDbTester;
import org.sonar.db.property.InternalComponentPropertyDbTester;
@@ -56,10 +55,6 @@ import org.sonar.db.user.UserDbTester;
import org.sonar.db.webhook.WebhookDbTester;
import org.sonar.db.webhook.WebhookDeliveryDbTester;
-import static com.google.common.base.Preconditions.checkState;
-import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
-import static org.sonar.db.organization.OrganizationDto.Subscription.FREE;
-
/**
* This class should be called using @Rule.
* Data is truncated between each tests. The schema is created between each test.
@@ -70,12 +65,6 @@ public class DbTester extends AbstractDbTester<TestDbImpl> {
private final System2 system2;
private DbClient client;
private DbSession session = null;
- private boolean disableDefaultOrganization = false;
- private boolean started = false;
- private String defaultOrganizationUuid = randomAlphanumeric(40);
- private String defaultOrganizationKey = randomAlphanumeric(40);
- private OrganizationDto defaultOrganization;
-
private final UserDbTester userTester;
private final ComponentDbTester componentTester;
private final ProjectLinkDbTester componentLinkTester;
@@ -136,10 +125,6 @@ public class DbTester extends AbstractDbTester<TestDbImpl> {
return new DbTester(system2, null);
}
- public static DbTester createWithExtensionMappers(Class<?> firstMapperClass, Class<?>... otherMapperClasses) {
- return new DbTester(System2.INSTANCE, null, new DbTesterMyBatisConfExtension(firstMapperClass, otherMapperClasses));
- }
-
public static DbTester createWithExtensionMappers(System2 system2, Class<?> firstMapperClass, Class<?>... otherMapperClasses) {
return new DbTester(system2, null, new DbTesterMyBatisConfExtension(firstMapperClass, otherMapperClasses));
}
@@ -156,67 +141,11 @@ public class DbTester extends AbstractDbTester<TestDbImpl> {
client = new DbClient(db.getDatabase(), db.getMyBatis(), new TestDBSessions(db.getMyBatis()), daos.toArray(new Dao[daos.size()]));
}
- // TODO remove
- @Deprecated
- public DbTester setDisableDefaultOrganization(boolean b) {
- checkState(!started, "DbTester is already started");
- this.disableDefaultOrganization = b;
- return this;
- }
-
- // TODO remove
- @Deprecated
- public DbTester setDefaultOrganizationUuid(String uuid) {
- checkState(!started, "DbTester is already started");
- this.defaultOrganizationUuid = uuid;
- return this;
- }
-
- // TODO remove
- @Deprecated
- public DbTester setDefaultOrganizationKey(String key) {
- checkState(!started, "DbTester is already started");
- this.defaultOrganizationKey = key;
- return this;
- }
-
@Override
protected void before() {
db.start();
db.truncateTables();
initDbClient();
- if (!disableDefaultOrganization) {
- insertDefaultOrganization();
- }
- started = true;
- }
-
- // TODO remove
- @Deprecated
- private void insertDefaultOrganization() {
- defaultOrganization = new OrganizationDto()
- .setName(randomAlphanumeric(64))
- .setDescription(randomAlphanumeric(256))
- .setAvatarUrl(randomAlphanumeric(256))
- // Default quality gate should be set explicitly when needed in tests
- .setDefaultQualityGateUuid("_NOT_SET_")
- .setSubscription(FREE)
- .setUrl(randomAlphanumeric(256))
- .setUuid(defaultOrganizationUuid)
- .setKey(defaultOrganizationKey);
-
- try (DbSession dbSession = db.getMyBatis().openSession(false)) {
- client.organizationDao().insert(dbSession, defaultOrganization, false);
- client.internalPropertiesDao().save(dbSession, "organization.default", defaultOrganization.getUuid());
- dbSession.commit();
- }
- }
-
- // TODO remove
- @Deprecated
- public OrganizationDto getDefaultOrganization() {
- checkState(defaultOrganization != null, "Default organization has not been created");
- return defaultOrganization;
}
public UserDbTester users() {
@@ -314,7 +243,6 @@ public class DbTester extends AbstractDbTester<TestDbImpl> {
session.close();
}
db.stop();
- started = false;
}
public DbSession getSession() {
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
index 0310bf77239..2a5b1680f7b 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
@@ -51,10 +51,6 @@ public class ComponentDbTester {
}
public SnapshotDto insertViewAndSnapshot(ComponentDto component) {
- if (component.getOrganizationUuid() == null) {
- component.setOrganizationUuid(db.getDefaultOrganization().getUuid());
- }
-
dbClient.componentDao().insert(dbSession, component);
return insertSnapshot(component);
}
@@ -282,27 +278,13 @@ public class ComponentDbTester {
private ComponentDto insertComponentImpl(ComponentDto component, @Nullable Boolean isPrivate, Consumer<ComponentDto> dtoPopulator) {
dtoPopulator.accept(component);
checkState(isPrivate == null || component.isPrivate() == isPrivate, "Illegal modification of private flag");
- if (component.getOrganizationUuid() == null) {
- component.setOrganizationUuid(db.getDefaultOrganization().getUuid());
- }
dbClient.componentDao().insert(dbSession, component);
db.commit();
return component;
}
- private ComponentDto insertComponentImpl(ComponentDto component, @Nullable Boolean isPrivate) {
- return insertComponentImpl(component, isPrivate, defaults());
- }
-
public void insertComponents(ComponentDto... components) {
- String defaultOrgUuid = db.getDefaultOrganization().getUuid();
- Arrays.stream(components).forEach(c -> {
- if (c.getOrganizationUuid() == null) {
- c.setOrganizationUuid(defaultOrgUuid);
- }
- });
-
dbClient.componentDao().insert(dbSession, asList(components));
db.commit();
}
@@ -397,8 +379,7 @@ public class ComponentDbTester {
.setUpdatedAt(createTime)
.setPrivate(componentDto.isPrivate())
.setDescription(componentDto.description())
- .setName(componentDto.name())
- .setOrganizationUuid(componentDto.getOrganizationUuid());
+ .setName(componentDto.name());
}
private static <T> Consumer<T> defaults() {
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
index 579cc484b49..922794a3f5c 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
@@ -24,7 +24,6 @@ import javax.annotation.Nullable;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
import org.sonar.core.util.Uuids;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.project.ProjectDto;
import static com.google.common.base.Preconditions.checkArgument;
@@ -125,42 +124,18 @@ public class ComponentTesting {
return newProjectDto(Uuids.createFast(), true);
}
- // TODO remove after getting rid of organization code
- @Deprecated
- public static ComponentDto newPrivateProjectDto(OrganizationDto organizationDto) {
- return newProjectDto(organizationDto.getUuid(), Uuids.createFast(), true);
- }
-
public static ComponentDto newPrivateProjectDto(String uuid) {
return newProjectDto(uuid, true);
}
- // TODO remove after getting rid of organization code
- @Deprecated
- public static ComponentDto newPrivateProjectDto(OrganizationDto organizationDto, String uuid) {
- return newProjectDto(organizationDto.getUuid(), uuid, true);
- }
-
public static ComponentDto newPublicProjectDto() {
return newProjectDto(Uuids.createFast(), false);
}
- // TODO remove after getting rid of organization code
- @Deprecated
- public static ComponentDto newPublicProjectDto(OrganizationDto organizationDto) {
- return newProjectDto(organizationDto.getUuid(), Uuids.createFast(), false);
- }
-
public static ComponentDto newPublicProjectDto(String uuid) {
return newProjectDto(uuid, false);
}
- // TODO remove after getting rid of organization code
- @Deprecated
- public static ComponentDto newPublicProjectDto(OrganizationDto organizationDto, String uuid) {
- return newProjectDto(organizationDto.getUuid(), uuid, false);
- }
-
private static ComponentDto newProjectDto(String uuid, boolean isPrivate) {
return new ComponentDto()
.setUuid(uuid)
@@ -180,31 +155,6 @@ public class ComponentTesting {
.setPrivate(isPrivate);
}
- /**
- * use {@link org.sonar.db.component.ComponentTesting#newProjectDto(java.lang.String, boolean)} instead
- */
- // TODO remove after getting rid of organization code
- @Deprecated
- private static ComponentDto newProjectDto(String organizationUuid, String uuid, boolean isPrivate) {
- return new ComponentDto()
- .setOrganizationUuid(organizationUuid)
- .setUuid(uuid)
- .setUuidPath(UUID_PATH_OF_ROOT)
- .setProjectUuid(uuid)
- .setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
- .setRootUuid(uuid)
- .setDbKey("KEY_" + uuid)
- .setName("NAME_" + uuid)
- .setLongName("LONG_NAME_" + uuid)
- .setDescription("DESCRIPTION_" + uuid)
- .setScope(Scopes.PROJECT)
- .setQualifier(Qualifiers.PROJECT)
- .setPath(null)
- .setLanguage(null)
- .setEnabled(true)
- .setPrivate(isPrivate);
- }
-
public static ComponentDto newView() {
return newView(Uuids.createFast());
}
@@ -228,7 +178,6 @@ public class ComponentTesting {
public static ComponentDto newProjectCopy(String uuid, ComponentDto project, ComponentDto view) {
return newChildComponent(uuid, view, view)
.setDbKey(view.getDbKey() + project.getDbKey())
- .setOrganizationUuid(project.getOrganizationUuid())
.setName(project.name())
.setLongName(project.longName())
.setCopyComponentUuid(project.uuid())
@@ -243,7 +192,6 @@ public class ComponentTesting {
"private flag inconsistent between moduleOrProject (%s) and parent (%s)",
moduleOrProject.isPrivate(), parent.isPrivate());
return new ComponentDto()
- .setOrganizationUuid(parent.getOrganizationUuid())
.setUuid(uuid)
.setUuidPath(formatUuidPathFromParent(parent))
.setProjectUuid(moduleOrProject.projectUuid())
@@ -288,7 +236,6 @@ public class ComponentTesting {
String uuid = branchDto.getUuid();
return new ComponentDto()
.setUuid(uuid)
- .setOrganizationUuid(project.getOrganizationUuid())
.setUuidPath(UUID_PATH_OF_ROOT)
.setProjectUuid(uuid)
.setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
@@ -315,7 +262,6 @@ public class ComponentTesting {
String uuid = branchDto.getUuid();
return new ComponentDto()
.setUuid(uuid)
- .setOrganizationUuid(project.getOrganizationUuid())
.setUuidPath(UUID_PATH_OF_ROOT)
.setProjectUuid(uuid)
.setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/qualityprofile/QualityProfileDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/qualityprofile/QualityProfileDbTester.java
index 337be6f2cfa..45f859a97c2 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/qualityprofile/QualityProfileDbTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/qualityprofile/QualityProfileDbTester.java
@@ -40,12 +40,10 @@ import static org.sonar.db.qualityprofile.ActiveRuleDto.createFor;
public class QualityProfileDbTester {
private final DbClient dbClient;
private final DbSession dbSession;
- private final DbTester dbTester;
public QualityProfileDbTester(DbTester dbTester) {
this.dbClient = dbTester.getDbClient();
this.dbSession = dbTester.getSession();
- this.dbTester = dbTester;
}
public Optional<QProfileDto> selectByUuid(String uuid) {
@@ -53,7 +51,7 @@ public class QualityProfileDbTester {
}
/**
- * Create a profile with random field values on the specified organization.
+ * Create a profile with random field values.
*/
public QProfileDto insert() {
return insert(c -> {
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleDbTester.java
index 4dbaafda1bd..37812dc6ad7 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleDbTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleDbTester.java
@@ -27,7 +27,6 @@ import org.sonar.api.rules.RuleType;
import org.sonar.api.server.rule.RuleParamType;
import org.sonar.core.util.Uuids;
import org.sonar.db.DbTester;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.user.UserDto;
import static java.util.Arrays.asList;
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java
index 7abee4129f2..85c552ab5b6 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java
@@ -32,7 +32,6 @@ import org.sonar.api.server.rule.RuleParamType;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.core.util.Uuids;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.rule.RuleDto.Format;
import org.sonar.db.rule.RuleDto.Scope;
import org.sonar.db.user.UserDto;
@@ -40,7 +39,6 @@ import org.sonar.db.user.UserDto;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.ImmutableSet.copyOf;
import static com.google.common.collect.Sets.newHashSet;
-import static java.util.Objects.requireNonNull;
import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
import static org.apache.commons.lang.math.RandomUtils.nextInt;
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java
index 112e74c7ef9..73bc44da23c 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java
@@ -321,7 +321,7 @@ public class UserDbTester {
}
public List<GlobalPermission> selectPermissionsOfUser(UserDto user) {
- return toListOfOrganizationPermissions(db.getDbClient().userPermissionDao()
+ return toListOfGlobalPermissions(db.getDbClient().userPermissionDao()
.selectGlobalPermissionsOfUser(db.getSession(), user.getUuid()));
}
@@ -329,7 +329,7 @@ public class UserDbTester {
return db.getDbClient().userPermissionDao().selectProjectPermissionsOfUser(db.getSession(), user.getUuid(), project.uuid());
}
- private static List<GlobalPermission> toListOfOrganizationPermissions(List<String> keys) {
+ private static List<GlobalPermission> toListOfGlobalPermissions(List<String> keys) {
return keys
.stream()
.map(GlobalPermission::fromKey)
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/webhook/WebhookDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/webhook/WebhookDbTester.java
index f47961850dc..8da90478b94 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/webhook/WebhookDbTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/webhook/WebhookDbTester.java
@@ -45,9 +45,6 @@ public class WebhookDbTester {
public WebhookDto insert(WebhookDto dto) {
DbSession dbSession = dbTester.getSession();
- if (dto.getProjectUuid() == null && dto.getOrganizationUuid() == null) {
- dto.setOrganizationUuid(dbTester.getDefaultOrganization().getUuid());
- }
dbTester.getDbClient().webhookDao().insert(dbSession, dto);
dbSession.commit();
return dto;