]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17706 Remove root_uuid in Components and all its uses
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Thu, 26 Jan 2023 21:06:06 +0000 (15:06 -0600)
committersonartech <sonartech@sonarsource.com>
Thu, 2 Feb 2023 20:03:40 +0000 (20:03 +0000)
54 files changed:
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/EnableAnalysisStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistDuplicationDataStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistLiveMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportLinksStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportMeasuresStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepTest.java
server/sonar-ce/src/test/java/org/sonar/ce/queue/NextPendingTaskPickerTest.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentKeyUpdaterMapper.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/ResourceDto.java
server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentKeyUpdaterMapper.xml
server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
server/sonar-db-dao/src/schema/schema-sq.ddl
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
server/sonar-db-dao/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date-result.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/issue/IssueDaoTest/shared.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/measure/MeasureDaoTest/select_by_snapshot_and_metric_keys.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/measure/MeasureDaoTest/shared.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/permission/AuthorizationDaoTest/should_return_root_project_keys_for_anonymous.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/permission/AuthorizationDaoTest/should_return_root_project_keys_for_group.xml
server/sonar-db-dao/src/test/resources/org/sonar/db/permission/AuthorizationDaoTest/should_return_root_project_keys_for_user.xml
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DbVersion100.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsRootUuidInComponents.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropRootUuidInComponents.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsRootUuidInComponentsTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropRootUuidInComponentsTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsRootUuidInComponentsTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropRootUuidInComponentsTest/schema.sql [new file with mode: 0644]
server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java
server/sonar-server-common/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml
server/sonar-server-common/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index_project.xml
server/sonar-webserver-auth/src/test/java/org/sonar/server/user/ServerUserSessionTest.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentUpdater.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/UpdateVisibilityAction.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/batch/ProjectDataLoaderTest.java
sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java

index edcf3d9d60b43ad1676ee8cebc754f216a6e5215..c59894f568d1d8411bb59f67b69a67760b3e02e4 100644 (file)
@@ -43,7 +43,7 @@ public class EnableAnalysisStep implements ComputationStep {
     try (DbSession dbSession = dbClient.openSession(false)) {
       Component project = treeRootHolder.getRoot();
       dbClient.snapshotDao().switchIsLastFlagAndSetProcessedStatus(dbSession, project.getUuid(), analysisMetadataHolder.getUuid());
-      dbClient.componentDao().applyBChangesForRootComponentUuid(dbSession, project.getUuid());
+      dbClient.componentDao().applyBChangesForBranchUuid(dbSession, project.getUuid());
       dbSession.commit();
     }
   }
index f120c211950f6753d5273d79c6a3667bec9efc5c..8e591b95e8168e8def24024a974b9c6aa9a3d979 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.function.Function;
 import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.apache.commons.lang.StringUtils;
@@ -94,7 +93,7 @@ public class PersistComponentsStep implements ComputationStep {
       String projectUuid = treeRootHolder.getRoot().getUuid();
 
       // safeguard, reset all rows to b-changed=false
-      dbClient.componentDao().resetBChangedForRootComponentUuid(dbSession, projectUuid);
+      dbClient.componentDao().resetBChangedForBranchUuid(dbSession, projectUuid);
 
       Map<String, ComponentDto> existingDtosByUuids = indexExistingDtosByUuids(dbSession);
       boolean isRootPrivate = isRootPrivate(treeRootHolder.getRoot(), existingDtosByUuids);
@@ -106,7 +105,7 @@ public class PersistComponentsStep implements ComputationStep {
         .visit(treeRootHolder.getRoot());
 
       disableRemainingComponents(dbSession, existingDtosByUuids.values());
-      dbClient.componentDao().setPrivateForRootComponentUuidWithoutAudit(dbSession, projectUuid, isRootPrivate);
+      dbClient.componentDao().setPrivateForBranchUuidWithoutAudit(dbSession, projectUuid, isRootPrivate);
       dbSession.commit();
     }
   }
@@ -262,7 +261,6 @@ public class PersistComponentsStep implements ComputationStep {
       res.setDescription(project.getDescription());
 
       res.setBranchUuid(res.uuid());
-      res.setRootUuid(res.uuid());
       res.setUuidPath(UUID_PATH_OF_ROOT);
 
       return res;
@@ -277,7 +275,7 @@ public class PersistComponentsStep implements ComputationStep {
       res.setLongName(directory.getName());
       res.setPath(directory.getName());
 
-      setParentProperties(res, path);
+      setUuids(res, path);
 
       return res;
     }
@@ -292,7 +290,7 @@ public class PersistComponentsStep implements ComputationStep {
       res.setPath(file.getName());
       res.setLanguage(file.getFileAttributes().getLanguageKey());
 
-      setParentProperties(res, path);
+      setUuids(res, path);
 
       return res;
     }
@@ -307,7 +305,6 @@ public class PersistComponentsStep implements ComputationStep {
       res.setLongName(res.name());
 
       res.setBranchUuid(res.uuid());
-      res.setRootUuid(res.uuid());
       res.setUuidPath(UUID_PATH_OF_ROOT);
 
       return res;
@@ -361,7 +358,6 @@ public class PersistComponentsStep implements ComputationStep {
      */
     private void setRootAndParentModule(ComponentDto res, PathAwareVisitor.Path<ComponentDtoHolder> path) {
       ComponentDto rootDto = path.root().getDto();
-      res.setRootUuid(rootDto.uuid());
       res.setBranchUuid(rootDto.uuid());
 
       ComponentDto parent = path.parent().getDto();
@@ -372,17 +368,9 @@ public class PersistComponentsStep implements ComputationStep {
   /**
    * Applies to a node of type either DIRECTORY or FILE
    */
-  private static void setParentProperties(ComponentDto componentDto, PathAwareVisitor.Path<ComponentDtoHolder> path) {
+  private static void setUuids(ComponentDto componentDto, PathAwareVisitor.Path<ComponentDtoHolder> path) {
     componentDto.setBranchUuid(path.root().getDto().uuid());
-
-    ComponentDto parent = StreamSupport.stream(path.getCurrentPath().spliterator(), false)
-      .filter(p -> p.component().getType() == Component.Type.PROJECT)
-      .findFirst()
-      .get()
-      .element().getDto();
     componentDto.setUuidPath(formatUuidPathFromParent(path.parent().getDto()));
-    componentDto.setRootUuid(parent.uuid());
-
   }
 
   private static Optional<ComponentUpdateDto> compareForUpdate(ComponentDto existing, ComponentDto target) {
index 708fea9df3aa9b7e97de85820477e4b837ee84e0..3488d4fc4417bdaf272b391a9d7a355312f22928 100644 (file)
@@ -178,7 +178,6 @@ public class PersistDuplicationDataStepTest extends BaseStepTest {
       .setKey(key)
       .setUuid(uuid)
       .setUuidPath(uuid + ".")
-      .setRootUuid(uuid)
       .setBranchUuid(uuid);
     db.components().insertComponent(componentDto);
     return componentDto;
index da3bc80b038d60981ccb794cb6f544c3093f8ba7..1620edc22e529dfe28e629a24b7ca1bc47748772 100644 (file)
@@ -306,7 +306,6 @@ public class PersistLiveMeasuresStepTest extends BaseStepTest {
       .setKey(key)
       .setUuid(uuid)
       .setUuidPath(uuid + ".")
-      .setRootUuid(uuid)
       .setBranchUuid(uuid);
     db.components().insertComponent(componentDto);
     return componentDto;
index a6542410c70c6fc78ee7bd988f1b365f6706d51b..f1db84273db00ea1ba56479ac49e30e740003236 100644 (file)
@@ -225,7 +225,6 @@ public class PersistMeasuresStepTest extends BaseStepTest {
       .setKey(key)
       .setUuid(uuid)
       .setUuidPath(uuid + ".")
-      .setRootUuid(uuid)
       .setBranchUuid(uuid);
     db.components().insertComponent(componentDto);
     return componentDto;
index 28bb7d9be16ec43f39f94943579a98c658db0ae8..c47def416d8a0771476832e3c1712ed6af04ff21 100644 (file)
@@ -126,7 +126,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(directoryDto.branchUuid()).isEqualTo(projectDto.uuid());
     assertThat(directoryDto.qualifier()).isEqualTo("DIR");
     assertThat(directoryDto.scope()).isEqualTo("DIR");
-    assertThat(directoryDto.getRootUuid()).isEqualTo(projectDto.uuid());
     assertThat(directoryDto.getCreatedAt()).isEqualTo(now);
 
     ComponentDto fileDto = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
@@ -141,7 +140,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileDto.branchUuid()).isEqualTo(projectDto.uuid());
     assertThat(fileDto.qualifier()).isEqualTo("FIL");
     assertThat(fileDto.scope()).isEqualTo("FIL");
-    assertThat(fileDto.getRootUuid()).isEqualTo(projectDto.uuid());
     assertThat(fileDto.getCreatedAt()).isEqualTo(now);
   }
 
@@ -180,7 +178,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(directoryDto.branchUuid()).isEqualTo(branch.uuid());
     assertThat(directoryDto.qualifier()).isEqualTo("DIR");
     assertThat(directoryDto.scope()).isEqualTo("DIR");
-    assertThat(directoryDto.getRootUuid()).isEqualTo(branch.uuid());
     assertThat(directoryDto.getCreatedAt()).isEqualTo(now);
 
     ComponentDto fileDto = dbClient.componentDao().selectByKeyAndBranch(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java", "feature/foo").get();
@@ -195,7 +192,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileDto.branchUuid()).isEqualTo(branch.uuid());
     assertThat(fileDto.qualifier()).isEqualTo("FIL");
     assertThat(fileDto.scope()).isEqualTo("FIL");
-    assertThat(fileDto.getRootUuid()).isEqualTo(branch.uuid());
     assertThat(fileDto.getCreatedAt()).isEqualTo(now);
   }
 
@@ -278,7 +274,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     underTest.execute(new TestComputationStepContext());
 
     // commit the functional transaction
-    dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
+    dbClient.componentDao().applyBChangesForBranchUuid(db.getSession(), project.uuid());
     db.commit();
 
     assertThat(dbClient.componentDao().selectByKey(db.getSession(), PROJECT_KEY + ":src/foo").get().scope()).isEqualTo("DIR");
@@ -316,13 +312,11 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     ComponentDto directory = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directory.getUuidPath()).isEqualTo(directory.getUuidPath());
     assertThat(directory.branchUuid()).isEqualTo(project.uuid());
-    assertThat(directory.getRootUuid()).isEqualTo(project.uuid());
     assertThat(directory.getMainBranchProjectUuid()).isNull();
 
     ComponentDto file = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir/Foo.java").get();
     assertThat(file.getUuidPath()).isEqualTo(file.getUuidPath());
     assertThat(file.branchUuid()).isEqualTo(project.uuid());
-    assertThat(file.getRootUuid()).isEqualTo(project.uuid());
     assertThat(file.getMainBranchProjectUuid()).isNull();
   }
 
@@ -358,13 +352,11 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getKey()).get();
     assertThat(projectReloaded.uuid()).isEqualTo(project.uuid());
     assertThat(projectReloaded.branchUuid()).isEqualTo(project.branchUuid());
-    assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid());
 
     ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directoryReloaded.uuid()).isEqualTo(directory.uuid());
     assertThat(directoryReloaded.getUuidPath()).isEqualTo(directory.getUuidPath());
     assertThat(directoryReloaded.branchUuid()).isEqualTo(directory.branchUuid());
-    assertThat(directoryReloaded.getRootUuid()).isEqualTo(directory.getRootUuid());
     assertThat(directoryReloaded.name()).isEqualTo(directory.name());
     assertThat(directoryReloaded.path()).isEqualTo(directory.path());
 
@@ -372,7 +364,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileReloaded.uuid()).isEqualTo(file.uuid());
     assertThat(fileReloaded.getUuidPath()).isEqualTo(file.getUuidPath());
     assertThat(fileReloaded.branchUuid()).isEqualTo(file.branchUuid());
-    assertThat(fileReloaded.getRootUuid()).isEqualTo(file.getRootUuid());
     assertThat(fileReloaded.name()).isEqualTo(file.name());
     assertThat(fileReloaded.path()).isEqualTo(file.path());
   }
@@ -435,20 +426,18 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertExistButDisabled(removedDirectory.getKey(), removedFile.getKey());
 
     // commit the functional transaction
-    dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
+    dbClient.componentDao().applyBChangesForBranchUuid(db.getSession(), project.uuid());
 
     ComponentDto projectReloaded = dbClient.componentDao().selectByKey(db.getSession(), project.getKey()).get();
     assertThat(projectReloaded.uuid()).isEqualTo(project.uuid());
     assertThat(projectReloaded.getUuidPath()).isEqualTo(project.getUuidPath());
     assertThat(projectReloaded.branchUuid()).isEqualTo(project.branchUuid());
-    assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid());
     assertThat(projectReloaded.isEnabled()).isTrue();
 
     ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(db.getSession(), "PROJECT_KEY:src/main/java/dir").get();
     assertThat(directoryReloaded.uuid()).isEqualTo(removedDirectory.uuid());
     assertThat(directoryReloaded.getUuidPath()).isEqualTo(removedDirectory.getUuidPath());
     assertThat(directoryReloaded.branchUuid()).isEqualTo(removedDirectory.branchUuid());
-    assertThat(directoryReloaded.getRootUuid()).isEqualTo(removedDirectory.getRootUuid());
     assertThat(directoryReloaded.name()).isEqualTo(removedDirectory.name());
     assertThat(directoryReloaded.longName()).isEqualTo(removedDirectory.longName());
     assertThat(directoryReloaded.path()).isEqualTo(removedDirectory.path());
@@ -458,7 +447,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
     assertThat(fileReloaded.uuid()).isEqualTo(removedFile.uuid());
     assertThat(fileReloaded.getUuidPath()).isEqualTo(removedFile.getUuidPath());
     assertThat(fileReloaded.branchUuid()).isEqualTo(removedFile.branchUuid());
-    assertThat(fileReloaded.getRootUuid()).isEqualTo(removedFile.getRootUuid());
     assertThat(fileReloaded.name()).isEqualTo(removedFile.name());
     assertThat(fileReloaded.path()).isEqualTo(removedFile.path());
     assertThat(fileReloaded.isEnabled()).isTrue();
index 60023e2e68caf606f537d80dda891a4f1c05a947..5a8adb1a8021de6053f0de039f20635746e89680 100644 (file)
@@ -285,7 +285,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     underTest.execute(new TestComputationStepContext());
 
     // commit functional transaction -> copies B-fields to A-fields
-    dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), viewDto.uuid());
+    dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), viewDto.uuid());
     dbTester.commit();
 
     assertRowsCountInTableProjects(1);
@@ -312,7 +312,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     underTest.execute(new TestComputationStepContext());
 
     // commit functional transaction -> copies B-fields to A-fields
-    dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid());
+    dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid());
     dbTester.commit();
 
     assertRowsCountInTableProjects(3);
@@ -342,7 +342,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     underTest.execute(new TestComputationStepContext());
 
     // commit functional transaction -> copies B-fields to A-fields
-    dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid());
+    dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid());
     dbTester.commit();
 
     ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY);
@@ -365,7 +365,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     underTest.execute(new TestComputationStepContext());
 
     // commit functional transaction -> copies B-fields to A-fields
-    dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid());
+    dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid());
     dbTester.commit();
 
     ComponentDto subViewReloaded = getComponentFromDb(SUBVIEW_1_KEY);
@@ -500,7 +500,6 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(dto.path()).isNull();
     assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
     assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
-    assertThat(dto.getRootUuid()).isEqualTo(VIEW_UUID);
     assertThat(dto.qualifier()).isEqualTo(Qualifiers.VIEW);
     assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
     assertThat(dto.getCopyComponentUuid()).isNull();
@@ -517,7 +516,6 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(dto.path()).isNull();
     assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
     assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
-    assertThat(dto.getRootUuid()).isEqualTo(VIEW_UUID);
     assertThat(dto.qualifier()).isEqualTo(Qualifiers.APP);
     assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
     assertThat(dto.getCopyComponentUuid()).isNull();
@@ -534,7 +532,6 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(sv1Dto.path()).isNull();
     assertThat(sv1Dto.uuid()).isEqualTo(SUBVIEW_1_UUID);
     assertThat(sv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
-    assertThat(sv1Dto.getRootUuid()).isEqualTo(viewDto.uuid());
     assertThat(sv1Dto.qualifier()).isEqualTo(Qualifiers.SUBVIEW);
     assertThat(sv1Dto.scope()).isEqualTo(Scopes.PROJECT);
     assertThat(sv1Dto.getCopyComponentUuid()).isNull();
@@ -548,7 +545,6 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(pv1Dto.path()).isNull();
     assertThat(pv1Dto.uuid()).isEqualTo(PROJECT_VIEW_1_UUID);
     assertThat(pv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
-    assertThat(pv1Dto.getRootUuid()).isEqualTo(viewDto.uuid());
     assertThat(pv1Dto.qualifier()).isEqualTo(Qualifiers.PROJECT);
     assertThat(pv1Dto.scope()).isEqualTo(Scopes.FILE);
     assertThat(pv1Dto.getCopyComponentUuid()).isEqualTo(project.uuid());
index 9d55733efa0411984d2a202b1c23be8b93d12157..2c345e7db6d415364bc6acb2eb2c7034cc508336 100644 (file)
@@ -66,7 +66,6 @@ public class ExportAnalysesStepTest {
     .setEnabled(true)
     .setUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
-    .setRootUuid(PROJECT_UUID)
     .setBranchUuid(PROJECT_UUID);
 
   private static final String DIR_UUID = "DIR_UUID";
@@ -81,7 +80,6 @@ public class ExportAnalysesStepTest {
     .setEnabled(true)
     .setUuid(DIR_UUID)
     .setUuidPath(UUID_PATH)
-    .setRootUuid(PROJECT_UUID)
     .setBranchUuid(PROJECT_UUID);
 
   private static final String FILE_UUID = "FILE_UUID";
@@ -93,7 +91,6 @@ public class ExportAnalysesStepTest {
     .setName("The File")
     .setUuid(FILE_UUID)
     .setUuidPath(UUID_PATH + UUID_PATH_SEPARATOR + FILE_UUID)
-    .setRootUuid(PROJECT_UUID)
     .setEnabled(true)
     .setBranchUuid(PROJECT_UUID);
 
index 6b30e38f8bc46fabe815d6beb6e243de9408ed36..9c8ae3124ac98aa01bf31be9c408724e5d20a6fd 100644 (file)
@@ -63,7 +63,6 @@ public class ExportBranchesStepTest {
     .setEnabled(true)
     .setUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
-    .setRootUuid(PROJECT_UUID)
     .setBranchUuid(PROJECT_UUID);
 
   @Rule
index 2ffca9921e56f096c6cc34e565d987c2fb4a9e50..52bb309160c4eb432dd8e82bf8a3b771262ed5be 100644 (file)
@@ -58,7 +58,6 @@ public class ExportComponentsStepTest {
     .setDescription("The project description")
     .setEnabled(true)
     .setUuid(PROJECT_UUID)
-    .setRootUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setCreatedAt(new Date(1596749115856L))
     .setBranchUuid(PROJECT_UUID);
@@ -72,7 +71,6 @@ public class ExportComponentsStepTest {
     .setKey("the_file")
     .setName("The File")
     .setUuid(FILE_UUID)
-    .setRootUuid(PROJECT_UUID)
     .setUuidPath(FILE_UUID_PATH)
     .setEnabled(true)
     .setCreatedAt(new Date(1596749148406L))
index 04e42d903a9ce9d68b28264a3b420fafaee623b6..04d1f1f6ecef966bc2f355c2869f3932de1dc839 100644 (file)
@@ -67,7 +67,6 @@ public class ExportAdHocRulesStepTest {
     .setEnabled(true)
     .setUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
-    .setRootUuid(PROJECT_UUID)
     .setBranchUuid(PROJECT_UUID);
 
   private static final List<BranchDto> BRANCHES = ImmutableList.of(
index ce2be44b06a11cb3a8c3879979d9c33ae6aa91d4..7dc28f6fb468feb0a43e422ee144db2b30794018 100644 (file)
@@ -50,7 +50,6 @@ public class ExportEventsStepTest {
   private static final ComponentDto PROJECT = new ComponentDto()
     .setUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
-    .setRootUuid(PROJECT_UUID)
     .setBranchUuid(PROJECT_UUID)
     .setScope(Scopes.PROJECT)
     .setQualifier(Qualifiers.PROJECT)
index 9ebb1558a658d8c05daeb12a47847c3dd52d9bdf..4c0ddf07f65964ff2f4060781da5d81903f9a362 100644 (file)
@@ -54,7 +54,6 @@ public class ExportLinksStepTest {
     .setDescription("The project description")
     .setEnabled(true)
     .setUuid(PROJECT_UUID)
-    .setRootUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setBranchUuid(PROJECT_UUID);
 
index 154b2a100f26bb3feee24445ae695cf0ad07be3f..5ad64414c2c2512034a4239f9fcbef38b3cc9435 100644 (file)
@@ -51,21 +51,18 @@ public class ExportMeasuresStepTest {
   private static final ComponentDto PROJECT = new ComponentDto()
     .setKey("project_key")
     .setUuid("project_uuid")
-    .setRootUuid("project_uuid")
     .setBranchUuid("project_uuid")
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setEnabled(true);
   private static final ComponentDto FILE = new ComponentDto()
     .setKey("file_key")
     .setUuid("file_uuid")
-    .setRootUuid("project_uuid")
     .setBranchUuid("project_uuid")
     .setUuidPath(UUID_PATH_OF_ROOT + PROJECT.uuid() + UUID_PATH_SEPARATOR)
     .setEnabled(true);
   private static final ComponentDto ANOTHER_PROJECT = new ComponentDto()
     .setKey("another_project_key")
     .setUuid("another_project_uuid")
-    .setRootUuid("another_project_uuid")
     .setBranchUuid("another_project_uuid")
     .setUuidPath(UUID_PATH_OF_ROOT)
     .setEnabled(true);
index 0dc08af77a4e93ec26d42dedfcae77ae01e54019..0540a66a417ddbf058d2efa0c44d85d65210943e 100644 (file)
@@ -53,7 +53,6 @@ public class ExportNewCodePeriodsStepTest {
   private static final ComponentDto PROJECT = new ComponentDto()
     .setUuid(PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
-    .setRootUuid(PROJECT_UUID)
     .setBranchUuid(PROJECT_UUID)
     .setQualifier(Qualifiers.PROJECT)
     .setName("project")
@@ -61,7 +60,6 @@ public class ExportNewCodePeriodsStepTest {
   private static final ComponentDto ANOTHER_PROJECT = new ComponentDto()
     .setUuid(ANOTHER_PROJECT_UUID)
     .setUuidPath(UUID_PATH_OF_ROOT)
-    .setRootUuid(ANOTHER_PROJECT_UUID)
     .setBranchUuid(ANOTHER_PROJECT_UUID)
     .setQualifier(Qualifiers.PROJECT)
     .setName("another_project")
index 946bc9c1af06beca555c378d6ff1fb93b4b6335d..d895bb92537e653adad6a179bcb1141d62f477f3 100644 (file)
@@ -47,13 +47,11 @@ public class ExportSettingsStepTest {
   private static final ComponentDto PROJECT = new ComponentDto()
     .setUuid("project_uuid")
     .setUuidPath(UUID_PATH_OF_ROOT)
-    .setRootUuid("project_uuid")
     .setBranchUuid("project_uuid")
     .setKey("the_project");
   private static final ComponentDto ANOTHER_PROJECT = new ComponentDto()
     .setUuid("another_project_uuid")
     .setUuidPath(UUID_PATH_OF_ROOT)
-    .setRootUuid("another_project_uuid")
     .setBranchUuid("another_project_uuid")
     .setKey("another_project");
 
index d66920eab76cd374d204b506720c7aaf6fc423f1..3fd745c8ea023474744c60be31a1b18ba5b2af12 100644 (file)
@@ -364,7 +364,6 @@ public class NextPendingTaskPickerTest {
     view.setKey(view_uuid + "_key");
     view.setUuid(view_uuid);
     view.setPrivate(false);
-    view.setRootUuid(view_uuid);
     view.setUuidPath("uuid_path");
     view.setBranchUuid(view_uuid);
     db.components().insertPortfolioAndSnapshot(view);
@@ -377,7 +376,6 @@ public class NextPendingTaskPickerTest {
     branch.setKey(uuid + "_key");
     branch.setUuid(uuid);
     branch.setPrivate(false);
-    branch.setRootUuid(uuid);
     branch.setUuidPath("uuid_path");
     branch.setBranchUuid(uuid);
     db.components().insertComponent(branch);
index 419dabee042c9e0713c5c83188f966b467e429ae..9044d64ad57056cd6d7066d5a81cbe5b9236021a 100644 (file)
@@ -348,22 +348,22 @@ public class ComponentDao implements Dao {
     executeLargeUpdates(uuids, mapper(session)::updateBEnabledToFalse);
   }
 
-  public void applyBChangesForRootComponentUuid(DbSession session, String branchUuid) {
-    mapper(session).applyBChangesForRootComponentUuid(branchUuid);
+  public void applyBChangesForBranchUuid(DbSession session, String branchUuid) {
+    mapper(session).applyBChangesForBranchUuid(branchUuid);
   }
 
-  public void resetBChangedForRootComponentUuid(DbSession session, String branchUuid) {
-    mapper(session).resetBChangedForRootComponentUuid(branchUuid);
+  public void resetBChangedForBranchUuid(DbSession session, String branchUuid) {
+    mapper(session).resetBChangedForBranchUuid(branchUuid);
   }
 
-  public void setPrivateForRootComponentUuidWithoutAudit(DbSession session, String branchUuid, boolean isPrivate) {
-    mapper(session).setPrivateForRootComponentUuid(branchUuid, isPrivate);
+  public void setPrivateForBranchUuidWithoutAudit(DbSession session, String branchUuid, boolean isPrivate) {
+    mapper(session).setPrivateForBranchUuid(branchUuid, isPrivate);
   }
 
-  public void setPrivateForRootComponentUuid(DbSession session, String branchUuid, boolean isPrivate, String qualifier, String componentKey, String componentName) {
+  public void setPrivateForBranchUuid(DbSession session, String branchUuid, boolean isPrivate, String qualifier, String componentKey, String componentName) {
     ComponentNewValue componentNewValue = new ComponentNewValue(branchUuid, componentName, componentKey, isPrivate, qualifier);
     auditPersister.updateComponentVisibility(session, componentNewValue);
-    mapper(session).setPrivateForRootComponentUuid(branchUuid, isPrivate);
+    mapper(session).setPrivateForBranchUuid(branchUuid, isPrivate);
   }
 
   /*
index a9a8bd3b63ff5ca4226a0f52e887651947828f4e..64717fb4a5b26d053534aa8a15796548246a90fe 100644 (file)
@@ -88,18 +88,6 @@ public class ComponentDto {
    */
   private String branchUuid;
 
-  /**
-   * Badly named, it is not the root !
-   * - on root: UUID="1" ROOT_UUID="1"
-   * - on directory, value is the closest module: UUID="3" ROOT_UUID="2"
-   * - on file, value is the closest module: UUID="4" ROOT_UUID="2"
-   * - on view: UUID="5" ROOT_UUID="5"
-   * - on sub-view: UUID="6" ROOT_UUID="5"
-   *
-   * @since 6.0
-   */
-  private String rootUuid;
-
   /**
    * On non-main branches only, {@link #uuid} of the main branch that represents
    * the project ({@link #qualifier}="TRK").
@@ -256,19 +244,6 @@ public class ComponentDto {
     return this;
   }
 
-  /**
-   * Use {@link #branchUuid()}
-   */
-  @Deprecated
-  public String getRootUuid() {
-    return rootUuid;
-  }
-
-  public ComponentDto setRootUuid(String rootUuid) {
-    this.rootUuid = rootUuid;
-    return this;
-  }
-
   @Nullable
   public String getMainBranchProjectUuid() {
     return mainBranchProjectUuid;
@@ -347,7 +322,6 @@ public class ComponentDto {
       .append("scope", scope)
       .append("qualifier", qualifier)
       .append("branchUuid", branchUuid)
-      .append("rootUuid", rootUuid)
       .append("mainBranchProjectUuid", mainBranchProjectUuid)
       .append("copyComponentUuid", copyComponentUuid)
       .append("path", path)
@@ -365,7 +339,6 @@ public class ComponentDto {
     copy.uuid = uuid;
     copy.uuidPath = uuidPath;
     copy.branchUuid = branchUuid;
-    copy.rootUuid = rootUuid;
     copy.mainBranchProjectUuid = mainBranchProjectUuid;
     copy.copyComponentUuid = copyComponentUuid;
     copy.scope = scope;
index 7f1ab30ae271eb1c5731155fd31fcc0cb4f17297..21c0fc86233a2d30afb663ed485964d3cf6fb120 100644 (file)
@@ -28,7 +28,7 @@ public interface ComponentKeyUpdaterMapper {
 
   ResourceDto selectComponentByUuid(@Param("uuid") String uuid);
 
-  List<ResourceDto> selectBranchResources(@Param("rootUuid") String rootUuid);
+  List<ResourceDto> selectBranchResources(@Param("branchUuid") String branchUuid);
 
   void updateComponent(ResourceDto resource);
 
index 3de18dbfde8b5496c795a712d8d0629a7cfd8bf2..f9a9b632e94c69201b6aea43ac0966f471d8d2a5 100644 (file)
@@ -109,11 +109,11 @@ public interface ComponentMapper {
 
   void updateBEnabledToFalse(@Param("uuids") List<String> uuids);
 
-  void applyBChangesForRootComponentUuid(@Param("branchUuid") String branchUuid);
+  void applyBChangesForBranchUuid(@Param("branchUuid") String branchUuid);
 
-  void resetBChangedForRootComponentUuid(@Param("branchUuid") String branchUuid);
+  void resetBChangedForBranchUuid(@Param("branchUuid") String branchUuid);
 
-  void setPrivateForRootComponentUuid(@Param("branchUuid") String branchUuid, @Param("isPrivate") boolean isPrivate);
+  void setPrivateForBranchUuid(@Param("branchUuid") String branchUuid, @Param("isPrivate") boolean isPrivate);
 
   List<KeyWithUuidDto> selectComponentsFromPullRequestsTargetingCurrentBranchThatHaveOpenIssues(@Param("referenceBranchUuid") String referenceBranchUuid,
     @Param("currentBranchUuid") String currentBranchUuid);
index 450f57712cb6956a7bf695fc2945bcfa37471988..368ea85447acdca2c618b514b63724f67f1fda99 100644 (file)
@@ -36,7 +36,6 @@ public class ResourceDto {
   private String deprecatedKey;
   private String name;
   private String longName;
-  private String rootUuid;
   private String path;
   private String scope;
   private String qualifier;
@@ -91,15 +90,6 @@ public class ResourceDto {
     return this;
   }
 
-  public String getRootUuid() {
-    return rootUuid;
-  }
-
-  public ResourceDto setRootUuid(String rootUuid) {
-    this.rootUuid = rootUuid;
-    return this;
-  }
-
   public String getPath() {
     return path;
   }
index e004a66d79a22379851667a7ef82f56c8f61d667..a7a4d1a85c4283adafee3fdb335e22196406e41d 100644 (file)
@@ -7,7 +7,6 @@
     <result property="key" column="kee"/>
     <result property="uuid" column="uuid"/>
     <result property="deprecatedKey" column="deprecated_kee"/>
-    <result property="rootUuid" column="root_uuid"/>
     <result property="scope" column="scope"/>
     <result property="enabled" column="enabled"/>
   </resultMap>
@@ -26,7 +25,7 @@
   <select id="selectBranchResources" parameterType="String" resultMap="resourceResultMap">
     select * from components
     where
-    root_uuid = #{rootUuid,jdbcType=VARCHAR}
+    branch_uuid = #{branchUuid,jdbcType=VARCHAR}
     and scope != 'PRJ'
   </select>
 
index 22b2c021e1e824fcfd339daa64d6d843fad276f5..996adb5462a58be203c5ac09696915415e96c6b8 100644 (file)
@@ -14,7 +14,6 @@
     p.qualifier as qualifier,
     p.scope as scope,
     p.language as language,
-    p.root_uuid as rootUuid,
     p.path as path,
     p.enabled as enabled,
     p.copy_component_uuid as copyComponentUuid,
@@ -72,7 +71,6 @@
           p.qualifier as qualifier,
           p.scope as scope,
           p.language as language,
-          p.root_uuid as rootUuid,
           p.path as path,
           p.enabled as enabled,
           p.copy_component_uuid as copyComponentUuid,
     <include refid="componentColumns"/>
     FROM components p
     INNER JOIN components child ON
-      child.root_uuid=p.uuid
+      child.branch_uuid=p.uuid
       and child.enabled=${_true}
     where
       p.enabled=${_true}
       language,
       description,
       private,
-      root_uuid,
       path,
       copy_component_uuid,
       enabled,
     #{language,jdbcType=VARCHAR},
     #{description,jdbcType=VARCHAR},
     #{isPrivate,jdbcType=BOOLEAN},
-    #{rootUuid,jdbcType=VARCHAR},
     #{path,jdbcType=VARCHAR},
     #{copyComponentUuid,jdbcType=VARCHAR},
     #{enabled,jdbcType=BOOLEAN},
     uuid in <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">#{uuid,jdbcType=VARCHAR}</foreach>
   </update>
 
-  <update id="applyBChangesForRootComponentUuid" parameterType="string" useGeneratedKeys="false">
+  <update id="applyBChangesForBranchUuid" parameterType="string" useGeneratedKeys="false">
     update components set
     <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
     kee = deprecated_kee,
     b_changed = ${_true}
   </update>
 
-  <update id="resetBChangedForRootComponentUuid" parameterType="map" >
+  <update id="resetBChangedForBranchUuid" parameterType="map" >
     update components
     set b_changed = ${_false},
     <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
     b_changed = ${_true}
   </update>
 
-  <update id="setPrivateForRootComponentUuid" parameterType="map" >
+  <update id="setPrivateForBranchUuid" parameterType="map" >
     update components set
       private = #{isPrivate,jdbcType=BOOLEAN}
     where
index cbafbb3785bb59b9ed9492efc7e4197afc03d6bc..ad8bc63ac84606cd75d12b099d48b5cfe8355328 100644 (file)
@@ -211,7 +211,6 @@ CREATE TABLE "COMPONENTS"(
     "SCOPE" CHARACTER VARYING(3),
     "QUALIFIER" CHARACTER VARYING(10),
     "PRIVATE" BOOLEAN NOT NULL,
-    "ROOT_UUID" CHARACTER VARYING(50) NOT NULL,
     "LANGUAGE" CHARACTER VARYING(20),
     "COPY_COMPONENT_UUID" CHARACTER VARYING(50),
     "PATH" CHARACTER VARYING(2000),
@@ -231,7 +230,6 @@ CREATE TABLE "COMPONENTS"(
     "CREATED_AT" TIMESTAMP
 );
 CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" NULLS FIRST);
-CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID" NULLS FIRST);
 CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
 CREATE UNIQUE INDEX "COMPONENTS_UUID" ON "COMPONENTS"("UUID" NULLS FIRST);
 CREATE INDEX "COMPONENTS_BRANCH_UUID" ON "COMPONENTS"("BRANCH_UUID" NULLS FIRST);
index f7f739e8820a6501bb25b94c8f3a6ff9d5c8206a..de315a06e37c977d27da7bffaa4adbea286f34d8 100644 (file)
@@ -272,7 +272,6 @@ public class ComponentDaoTest {
     assertThat(result.getKey()).isEqualTo(project.getKey());
     assertThat(result.uuid()).isEqualTo(project.uuid());
     assertThat(result.getUuidPath()).isEqualTo(project.getUuidPath());
-    assertThat(result.getRootUuid()).isEqualTo(project.uuid());
     assertThat(result.branchUuid()).isEqualTo(project.uuid());
   }
 
@@ -1640,7 +1639,7 @@ public class ComponentDaoTest {
   }
 
   @Test
-  public void setPrivateForRootComponentUuid_updates_private_column_to_specified_value_for_all_rows_with_specified_projectUuid() {
+  public void setPrivateForBranchUuid_updates_private_column_to_specified_value_for_all_rows_with_specified_projectUuid() {
     String uuid1 = "uuid1";
     String uuid2 = "uuid2";
 
@@ -1649,10 +1648,10 @@ public class ComponentDaoTest {
       db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid1).setPrivate(false)).uuid(),
       db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid2).setPrivate(true)).uuid(),
       db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid2).setPrivate(false)).uuid(),
-      db.components().insertComponent(newPrivateProjectDto().setRootUuid(uuid1).setBranchUuid("foo").setPrivate(false)).uuid(),
+      db.components().insertComponent(newPrivateProjectDto().setBranchUuid("foo").setPrivate(false)).uuid(),
     };
 
-    underTest.setPrivateForRootComponentUuidWithoutAudit(db.getSession(), uuid1, true);
+    underTest.setPrivateForBranchUuidWithoutAudit(db.getSession(), uuid1, true);
 
     assertThat(privateFlagOfUuid(uuids[0])).isTrue();
     assertThat(privateFlagOfUuid(uuids[1])).isTrue();
@@ -1660,7 +1659,7 @@ public class ComponentDaoTest {
     assertThat(privateFlagOfUuid(uuids[3])).isFalse();
     assertThat(privateFlagOfUuid(uuids[4])).isFalse();
 
-    underTest.setPrivateForRootComponentUuidWithoutAudit(db.getSession(), uuid1, false);
+    underTest.setPrivateForBranchUuidWithoutAudit(db.getSession(), uuid1, false);
 
     assertThat(privateFlagOfUuid(uuids[0])).isFalse();
     assertThat(privateFlagOfUuid(uuids[1])).isFalse();
@@ -1668,7 +1667,7 @@ public class ComponentDaoTest {
     assertThat(privateFlagOfUuid(uuids[3])).isFalse();
     assertThat(privateFlagOfUuid(uuids[4])).isFalse();
 
-    underTest.setPrivateForRootComponentUuidWithoutAudit(db.getSession(), uuid2, false);
+    underTest.setPrivateForBranchUuidWithoutAudit(db.getSession(), uuid2, false);
 
     assertThat(privateFlagOfUuid(uuids[0])).isFalse();
     assertThat(privateFlagOfUuid(uuids[1])).isFalse();
@@ -1676,7 +1675,7 @@ public class ComponentDaoTest {
     assertThat(privateFlagOfUuid(uuids[3])).isFalse();
     assertThat(privateFlagOfUuid(uuids[4])).isFalse();
 
-    underTest.setPrivateForRootComponentUuidWithoutAudit(db.getSession(), uuid2, true);
+    underTest.setPrivateForBranchUuidWithoutAudit(db.getSession(), uuid2, true);
 
     assertThat(privateFlagOfUuid(uuids[0])).isFalse();
     assertThat(privateFlagOfUuid(uuids[1])).isFalse();
@@ -1763,15 +1762,15 @@ public class ComponentDaoTest {
   }
 
   @Test
-  public void setPrivateForRootComponentUuid_auditPersisterIsCalled() {
-    underTestWithAuditPersister.setPrivateForRootComponentUuid(dbSession, "anyUuid", false, "key", APP, "appName");
+  public void setPrivateForBranchUuid_auditPersisterIsCalled() {
+    underTestWithAuditPersister.setPrivateForBranchUuid(dbSession, "anyUuid", false, "key", APP, "appName");
 
     verify(auditPersister).updateComponentVisibility(any(DbSession.class), any(ComponentNewValue.class));
   }
 
   @Test
-  public void setPrivateForRootComponentUuidWithoutAudit_auditPersisterIsNotCalled() {
-    underTestWithAuditPersister.setPrivateForRootComponentUuidWithoutAudit(dbSession, "anyUuid", false);
+  public void setPrivateForBranchUuidWithoutAudit_auditPersisterIsNotCalled() {
+    underTestWithAuditPersister.setPrivateForBranchUuidWithoutAudit(dbSession, "anyUuid", false);
 
     verifyNoInteractions(auditPersister);
   }
index 102931506c72b07cc3e720b65b77697592b3b590..e571ddcbc0f3d6b34819f320750f8bc8ee58fc1b 100644 (file)
@@ -37,8 +37,7 @@ public class ComponentDtoTest {
       .setLanguage("java")
       .setDescription("desc")
       .setPath("src/org/struts/RequestContext.java")
-      .setCopyComponentUuid("uuid_5")
-      .setRootUuid("uuid_3");
+      .setCopyComponentUuid("uuid_5");
 
     assertThat(componentDto.getKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
     assertThat(componentDto.name()).isEqualTo("RequestContext.java");
@@ -48,7 +47,6 @@ public class ComponentDtoTest {
     assertThat(componentDto.path()).isEqualTo("src/org/struts/RequestContext.java");
     assertThat(componentDto.language()).isEqualTo("java");
     assertThat(componentDto.description()).isEqualTo("desc");
-    assertThat(componentDto.getRootUuid()).isEqualTo("uuid_3");
     assertThat(componentDto.getCopyComponentUuid()).isEqualTo("uuid_5");
     assertThat(componentDto.isPrivate()).isFalse();
   }
index a1c28e8dc87b6d196a1dfc90ccf71de3a0caf697..5e2282d61ec315a7fc1208cde5aaeed8988ee97f 100644 (file)
@@ -184,7 +184,7 @@ public class ComponentKeyUpdaterDaoTest {
   }
 
   private void populateSomeData() {
-    ComponentDto project1 = db.components().insertPrivateProject(t -> t.setKey("org.struts:struts").setUuid("A"));
+    ComponentDto project1 = db.components().insertPrivateProject(t -> t.setKey("org.struts:struts").setUuid("A").setBranchUuid("A"));
     ComponentDto directory1 = db.components().insertComponent(newDirectory(project1, "/src/org/struts").setUuid("B"));
     db.components().insertComponent(ComponentTesting.newFileDto(project1, directory1).setKey("org.struts:struts:/src/org/struts/RequestContext.java").setUuid("C"));
     ComponentDto project2 = db.components().insertPublicProject(t -> t.setKey("foo:struts-core").setUuid("D"));
index 1c3e6e59276e73201b1bc797d54b7109d5bf9d26..637ab8ecaf967f59d6aa8ffcb22c1e42acae6949 100644 (file)
@@ -2,12 +2,9 @@
 
   <projects organization_uuid="org1"
             id="1"
-            root_uuid="uuid_200"
             uuid="ABCD"
             uuid_path="NOT_USED"
             project_uuid="ABCD"
-            module_uuid="[null]"
-            module_uuid_path="."
             main_branch_project_uuid="[null]"
             scope="PRJ"
             qualifier="TRK"
@@ -32,8 +29,6 @@
             b_uuid_path="[null]"
             b_language="[null]"
             b_long_name="[null]"
-            b_module_uuid="[null]"
-            b_module_uuid_path="[null]"
             b_name="[null]"
             b_path="[null]"
             b_qualifier="[null]"
index 1c3e6e59276e73201b1bc797d54b7109d5bf9d26..637ab8ecaf967f59d6aa8ffcb22c1e42acae6949 100644 (file)
@@ -2,12 +2,9 @@
 
   <projects organization_uuid="org1"
             id="1"
-            root_uuid="uuid_200"
             uuid="ABCD"
             uuid_path="NOT_USED"
             project_uuid="ABCD"
-            module_uuid="[null]"
-            module_uuid_path="."
             main_branch_project_uuid="[null]"
             scope="PRJ"
             qualifier="TRK"
@@ -32,8 +29,6 @@
             b_uuid_path="[null]"
             b_language="[null]"
             b_long_name="[null]"
-            b_module_uuid="[null]"
-            b_module_uuid_path="[null]"
             b_name="[null]"
             b_path="[null]"
             b_qualifier="[null]"
index 32a278ac094ac5235469304a62751cc40b084c26..583ec53880b14d2b9210c3ffdf15fc6b9f68d20c 100644 (file)
@@ -9,10 +9,7 @@
   <projects organization_uuid="org1"
             uuid="ABCD"
             uuid_path="NOT_USED"
-            root_uuid="ABCD"
             project_uuid="ABCD"
-            module_uuid="[null]"
-            module_uuid_path="."
             kee="struts"
             qualifier="TRK"
             scope="PRJ"
   <projects organization_uuid="org1"
             uuid="BCDE"
             uuid_path="NOT_USED"
-            root_uuid="ABCD"
             project_uuid="ABCD"
-            module_uuid="[null]"
-            module_uuid_path=".ABCD."
             kee="struts-core"
             qualifier="BRC"
             scope="PRJ"
   <projects organization_uuid="org1"
             uuid="CDEF"
             uuid_path="NOT_USED"
-            root_uuid="BCDE"
             project_uuid="ABCD"
-            module_uuid="BCDE"
-            module_uuid_path=".ABCD.BCDE."
             kee="Action.java"
             qualifier="CLA"
             scope="PRJ"
   <projects organization_uuid="org1"
             uuid="DEFG"
             uuid_path="NOT_USED"
-            root_uuid="CDEF"
             project_uuid="ABCD"
-            module_uuid="BCDE"
-            module_uuid_path=".ABCD.BCDE."
             kee="Filter.java"
             qualifier="CLA"
             scope="PRJ"
index f1640d1d48ee35251711c8eb0deb6ba0d705da2e..35a3f8823da73bdc53254ab339dc83174226081d 100644 (file)
             uuid="ABCD"
             uuid_path="NOT_USED"
             project_uuid="ABCD"
-            module_uuid="[null]"
-            module_uuid_path=".ABCD."
             enabled="[true]"
             long_name="[null]"
             id="1"
             scope="PRJ"
             qualifier="TRK"
             kee="project"
-            name="project"
-            root_uuid="ABCD"/>
+            name="project"/>
 
   <!-- package -->
   <projects organization_uuid="org1"
             uuid="BCDE"
             uuid_path="NOT_USED"
             project_uuid="ABCD"
-            module_uuid="ABCD"
-            module_uuid_path=".ABCD."
             enabled="[true]"
             long_name="[null]"
             id="2"
             scope="DIR"
             qualifier="PAC"
             kee="project:org.foo"
-            name="org.foo"
-            root_uuid="ABCD"/>
+            name="org.foo"/>
 
   <!-- file -->
   <projects organization_uuid="org1"
             uuid="CDEF"
             uuid_path="NOT_USED"
             project_uuid="ABCD"
-            module_uuid="ABCD"
-            module_uuid_path=".ABCD."
             enabled="[true]"
             long_name="org.foo.Bar"
             id="3"
             scope="FIL"
             qualifier="CLA"
             kee="project:org.foo.Bar"
-            name="Bar"
-            root_uuid="ABCD"/>
+            name="Bar"/>
 
 
   <!-- snapshots -->
index 2c00644180fb0f9b179546e7646683dfeb91e457..81544d11094b2e3a4faaecab0fce499193d50951 100644 (file)
@@ -10,7 +10,6 @@
   <projects organization_uuid="org1"
             uuid="FILE1"
             uuid_path="NOT_USED"
-            root_uuid="ABCD"
             id="1"
             kee="org.struts:struts-core:src/org/struts/RequestContext.java"
             enabled="[true]"/>
index 3ef039a19d8da7f0e6001f2dc59985d660cede19..2255cf96ee27a14bc2112dc39097508e1a99a17c 100644 (file)
@@ -10,7 +10,6 @@
   <projects organization_uuid="org1"
             uuid="ABCD"
             uuid_path="NOT_USED"
-            root_uuid="ABCD"
             id="1"
             kee="org.struts:struts-core:src/org/struts/RequestContext.java"
             enabled="[true]"/>
index 811a4ec4fe3d1c9ba26eb017631418abdd73b775..64b5561d60574c5f26293ed7824cbd4f112c9b68 100644 (file)
@@ -17,9 +17,7 @@
             id="300"
             uuid="ABCD"
             uuid_path="NOT_USED"
-            root_uuid="ABCD"
             project_uuid="ABCD"
-            module_uuid="[null]"
             kee="pj-w-snapshot"
             scope="PRJ"
             qualifier="TRK"
@@ -29,9 +27,7 @@
             id="301"
             uuid="BCDE"
             uuid_path="NOT_USED"
-            root_uuid="BCDE"
             project_uuid="BCDE"
-            module_uuid="[null]"
             kee="pj-w-snapshot1"
             scope="PRJ"
             qualifier="TRK"
@@ -41,9 +37,7 @@
             id="302"
             uuid="CDEF"
             uuid_path="NOT_USED"
-            root_uuid="CDEF"
             project_uuid="CDEF"
-            module_uuid="[null]"
             kee="pj-w-snapshot2"
             scope="PRJ"
             qualifier="TRK"
@@ -54,9 +48,7 @@
             id="303"
             uuid="DEFG"
             uuid_path="NOT_USED"
-            root_uuid="DEFG"
             project_uuid="DEFG"
-            module_uuid="[null]"
             kee="pj-w-snapshot3"
             scope="PRJ"
             qualifier="TRK"
index 92784c88940215068e2bcf550cafc63697d556a1..4a73fb1ea280ed25108b7597654c3022dad9af26 100644 (file)
@@ -19,9 +19,7 @@
             id="300"
             uuid="ABCD"
             uuid_path="NOT_USED"
-            root_uuid="ABCD"
             project_uuid="ABCD"
-            module_uuid="[null]"
             kee="pj-w-snapshot"
             scope="PRJ"
             qualifier="TRK"
@@ -31,9 +29,7 @@
             id="301"
             uuid="BCDE"
             uuid_path="NOT_USED"
-            root_uuid="BCDE"
             project_uuid="BCDE"
-            module_uuid="[null]"
             kee="pj-w-snapshot1"
             scope="PRJ"
             qualifier="TRK"
@@ -43,9 +39,7 @@
             id="302"
             uuid="CDEF"
             uuid_path="NOT_USED"
-            root_uuid="CDEF"
             project_uuid="CDEF"
-            module_uuid="[null]"
             kee="pj-w-snapshot2"
             scope="PRJ"
             qualifier="TRK"
@@ -56,9 +50,7 @@
             id="303"
             uuid="DEFG"
             uuid_path="NOT_USED"
-            root_uuid="DEFG"
             project_uuid="DEFG"
-            module_uuid="[null]"
             kee="pj-w-snapshot3"
             scope="PRJ"
             qualifier="TRK"
index 58270a7655b03880b21d2d0c2f61af26d99f8e55..31404170f71bf7a7811c970690557dee15aea956 100644 (file)
@@ -18,9 +18,7 @@
             id="300"
             uuid="ABCD"
             uuid_path="NOT_USED"
-            root_uuid="ABCD"
             project_uuid="ABCD"
-            module_uuid="[null]"
             kee="pj-w-snapshot"
             scope="PRJ"
             qualifier="TRK"
@@ -30,9 +28,7 @@
             id="301"
             uuid="BCDE"
             uuid_path="NOT_USED"
-            root_uuid="BCDE"
             project_uuid="BCDE"
-            module_uuid="[null]"
             kee="pj-w-snapshot1"
             scope="PRJ"
             qualifier="TRK"
@@ -42,9 +38,7 @@
             id="302"
             uuid="CDEF"
             uuid_path="NOT_USED"
-            root_uuid="CDEF"
             project_uuid="CDEF"
-            module_uuid="[null]"
             kee="pj-w-snapshot2"
             scope="PRJ"
             qualifier="TRK"
@@ -55,9 +49,7 @@
             id="303"
             uuid="DEFG"
             uuid_path="NOT_USED"
-            root_uuid="DEFG"
             project_uuid="DEFG"
-            module_uuid="[null]"
             kee="pj-w-snapshot3"
             scope="PRJ"
             qualifier="TRK"
index 65f91d21f701715f0b425258ddb0e00a62f57cb9..37631297384818f92d47a70af42416bfe3b7c7f8 100644 (file)
@@ -51,6 +51,7 @@ public class ComponentTesting {
       .setName(filename)
       .setLongName(path)
       .setScope(Scopes.FILE)
+      .setBranchUuid(project.branchUuid())
       .setQualifier(Qualifiers.FILE)
       .setPath(path)
       .setCreatedAt(new Date())
@@ -67,6 +68,7 @@ public class ComponentTesting {
       .setKey(key)
       .setName(path)
       .setLongName(path)
+      .setBranchUuid(project.branchUuid())
       .setPath(path)
       .setScope(Scopes.DIRECTORY)
       .setQualifier(Qualifiers.DIRECTORY);
@@ -108,7 +110,6 @@ public class ComponentTesting {
       .setUuid(uuid)
       .setUuidPath(UUID_PATH_OF_ROOT)
       .setBranchUuid(uuid)
-      .setRootUuid(uuid)
       .setKey("KEY_" + uuid)
       .setName("NAME_" + uuid)
       .setLongName("LONG_NAME_" + uuid)
@@ -174,7 +175,6 @@ public class ComponentTesting {
       .setUuidPath(formatUuidPathFromParent(parent))
       .setKey(uuid)
       .setBranchUuid(project.branchUuid())
-      .setRootUuid(project.uuid())
       .setMainBranchProjectUuid(project.getMainBranchProjectUuid())
       .setCreatedAt(new Date())
       .setEnabled(true)
@@ -213,7 +213,6 @@ public class ComponentTesting {
       .setUuid(uuid)
       .setUuidPath(UUID_PATH_OF_ROOT)
       .setBranchUuid(uuid)
-      .setRootUuid(uuid)
       .setKey(project.getKey())
       .setMainBranchProjectUuid(project.getUuid())
       .setName(project.getName())
@@ -235,7 +234,6 @@ public class ComponentTesting {
       .setUuid(uuid)
       .setUuidPath(UUID_PATH_OF_ROOT)
       .setBranchUuid(uuid)
-      .setRootUuid(uuid)
       .setKey(project.getKey())
       .setMainBranchProjectUuid(project.uuid())
       .setName(project.name())
index e5c07c0a073c91c9bd86d925b44b3f3f2bb3cb66..727d281b2b98a179148ec0c9f15b39c3e7270b91 100644 (file)
@@ -47,6 +47,10 @@ public class DbVersion100 implements DbVersion {
       .add(10_0_003, "Drop column 'module_uuid_path' in the 'Components' table", DropModuleUuidPathInComponents.class)
       .add(10_0_004, "Drop column 'b_module_uuid' in the 'Components' table", DropBModuleUuidInComponents.class)
       .add(10_0_005, "Drop column 'b_module_uuid_path' in the 'Components' table", DropBModuleUuidPathInComponents.class)
+      .add(10_0_006, "Drop index 'projects_root_uuid' in the 'Components' table", DropIndexProjectsRootUuidInComponents.class)
+      .add(10_0_007, "Drop column 'root_uuid' in the 'Components' table", DropRootUuidInComponents.class)
+
+
     ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsRootUuidInComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsRootUuidInComponents.java
new file mode 100644 (file)
index 0000000..8d4570d
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v100;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropIndexChange;
+
+public class DropIndexProjectsRootUuidInComponents extends DropIndexChange {
+  private static final String INDEX_NAME = "projects_root_uuid";
+  private static final String TABLE_NAME = "components";
+
+  public DropIndexProjectsRootUuidInComponents(Database db) {
+    super(db, INDEX_NAME, TABLE_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropRootUuidInComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v100/DropRootUuidInComponents.java
new file mode 100644 (file)
index 0000000..b8f583b
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v100;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropColumnChange;
+
+public class DropRootUuidInComponents extends DropColumnChange {
+  private static final String COLUMN_NAME = "root_uuid";
+  private static final String TABLE_NAME = "components";
+
+  protected DropRootUuidInComponents(Database db) {
+    super(db, TABLE_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsRootUuidInComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsRootUuidInComponentsTest.java
new file mode 100644 (file)
index 0000000..86029da
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v100;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropIndexProjectsRootUuidInComponentsTest {
+  private static final String TABLE_NAME = "components";
+  private static final String COLUMN_NAME = "root_uuid";
+  private static final String INDEX_NAME = "projects_root_uuid";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexProjectsRootUuidInComponentsTest.class, "schema.sql");
+  private final DdlChange underTest = new DropIndexProjectsRootUuidInComponents(db.database());
+
+  @Test
+  public void drops_index() throws SQLException {
+    db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+    underTest.execute();
+    db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
+  }
+
+  @Test
+  public void migration_is_reentrant() throws SQLException {
+    db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
+    underTest.execute();
+    underTest.execute();
+    db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropRootUuidInComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropRootUuidInComponentsTest.java
new file mode 100644 (file)
index 0000000..0206bc8
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v100;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropRootUuidInComponentsTest {
+  private static final String TABLE_NAME = "components";
+  private static final String COLUMN_NAME = "root_uuid";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(DropRootUuidInComponentsTest.class, "schema.sql");
+  private final DdlChange underTest = new DropRootUuidInComponents(db.database());
+
+  @Test
+  public void drops_column() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, false);
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+
+  @Test
+  public void migration_is_reentrant() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, false);
+    underTest.execute();
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsRootUuidInComponentsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsRootUuidInComponentsTest/schema.sql
new file mode 100644 (file)
index 0000000..00a2b78
--- /dev/null
@@ -0,0 +1,37 @@
+
+CREATE TABLE "COMPONENTS"(
+    "UUID" CHARACTER VARYING(50) NOT NULL,
+    "KEE" CHARACTER VARYING(1000),
+    "DEPRECATED_KEE" CHARACTER VARYING(400),
+    "NAME" CHARACTER VARYING(2000),
+    "LONG_NAME" CHARACTER VARYING(2000),
+    "DESCRIPTION" CHARACTER VARYING(2000),
+    "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL,
+    "SCOPE" CHARACTER VARYING(3),
+    "QUALIFIER" CHARACTER VARYING(10),
+    "PRIVATE" BOOLEAN NOT NULL,
+    "ROOT_UUID" CHARACTER VARYING(50) NOT NULL,
+    "LANGUAGE" CHARACTER VARYING(20),
+    "COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+    "PATH" CHARACTER VARYING(2000),
+    "UUID_PATH" CHARACTER VARYING(1500) NOT NULL,
+    "BRANCH_UUID" CHARACTER VARYING(50) NOT NULL,
+    "MAIN_BRANCH_PROJECT_UUID" CHARACTER VARYING(50),
+    "B_CHANGED" BOOLEAN,
+    "B_NAME" CHARACTER VARYING(500),
+    "B_LONG_NAME" CHARACTER VARYING(500),
+    "B_DESCRIPTION" CHARACTER VARYING(2000),
+    "B_ENABLED" BOOLEAN,
+    "B_QUALIFIER" CHARACTER VARYING(10),
+    "B_LANGUAGE" CHARACTER VARYING(20),
+    "B_COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+    "B_PATH" CHARACTER VARYING(2000),
+    "B_UUID_PATH" CHARACTER VARYING(1500),
+    "CREATED_AT" TIMESTAMP
+);
+CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" NULLS FIRST);
+CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID" NULLS FIRST);
+CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
+CREATE UNIQUE INDEX "COMPONENTS_UUID" ON "COMPONENTS"("UUID" NULLS FIRST);
+CREATE INDEX "COMPONENTS_BRANCH_UUID" ON "COMPONENTS"("BRANCH_UUID" NULLS FIRST);
+CREATE UNIQUE INDEX "COMPONENTS_KEE_BRANCH_UUID" ON "COMPONENTS"("KEE" NULLS FIRST, "BRANCH_UUID" NULLS FIRST);
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropRootUuidInComponentsTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v100/DropRootUuidInComponentsTest/schema.sql
new file mode 100644 (file)
index 0000000..00a2b78
--- /dev/null
@@ -0,0 +1,37 @@
+
+CREATE TABLE "COMPONENTS"(
+    "UUID" CHARACTER VARYING(50) NOT NULL,
+    "KEE" CHARACTER VARYING(1000),
+    "DEPRECATED_KEE" CHARACTER VARYING(400),
+    "NAME" CHARACTER VARYING(2000),
+    "LONG_NAME" CHARACTER VARYING(2000),
+    "DESCRIPTION" CHARACTER VARYING(2000),
+    "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL,
+    "SCOPE" CHARACTER VARYING(3),
+    "QUALIFIER" CHARACTER VARYING(10),
+    "PRIVATE" BOOLEAN NOT NULL,
+    "ROOT_UUID" CHARACTER VARYING(50) NOT NULL,
+    "LANGUAGE" CHARACTER VARYING(20),
+    "COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+    "PATH" CHARACTER VARYING(2000),
+    "UUID_PATH" CHARACTER VARYING(1500) NOT NULL,
+    "BRANCH_UUID" CHARACTER VARYING(50) NOT NULL,
+    "MAIN_BRANCH_PROJECT_UUID" CHARACTER VARYING(50),
+    "B_CHANGED" BOOLEAN,
+    "B_NAME" CHARACTER VARYING(500),
+    "B_LONG_NAME" CHARACTER VARYING(500),
+    "B_DESCRIPTION" CHARACTER VARYING(2000),
+    "B_ENABLED" BOOLEAN,
+    "B_QUALIFIER" CHARACTER VARYING(10),
+    "B_LANGUAGE" CHARACTER VARYING(20),
+    "B_COPY_COMPONENT_UUID" CHARACTER VARYING(50),
+    "B_PATH" CHARACTER VARYING(2000),
+    "B_UUID_PATH" CHARACTER VARYING(1500),
+    "CREATED_AT" TIMESTAMP
+);
+CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" NULLS FIRST);
+CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID" NULLS FIRST);
+CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
+CREATE UNIQUE INDEX "COMPONENTS_UUID" ON "COMPONENTS"("UUID" NULLS FIRST);
+CREATE INDEX "COMPONENTS_BRANCH_UUID" ON "COMPONENTS"("BRANCH_UUID" NULLS FIRST);
+CREATE UNIQUE INDEX "COMPONENTS_KEE_BRANCH_UUID" ON "COMPONENTS"("KEE" NULLS FIRST, "BRANCH_UUID" NULLS FIRST);
index fdc466f8237b08565331252f9726ff948ec9c671..9cbaeece04f12ee97c856492c487d5705925bc74 100644 (file)
@@ -247,7 +247,7 @@ public class ComponentIndexerTest {
     ComponentUpdateDto updateComponent = ComponentUpdateDto.copyFrom(component);
     updateComponent.setBChanged(true);
     dbClient.componentDao().update(dbSession, updateComponent, component.qualifier());
-    dbClient.componentDao().applyBChangesForRootComponentUuid(dbSession, component.getRootUuid());
+    dbClient.componentDao().applyBChangesForBranchUuid(dbSession, component.branchUuid());
     dbSession.commit();
   }
 
index 391706e80300e3f178e8c58fb87ccff7be6ef5fb..31b217d461ee4eec27ac97e1d7fffec98d4e514e 100644 (file)
@@ -9,10 +9,7 @@
   <projects organization_uuid="org1"
             uuid="THE_PROJECT"
             uuid_path="NOT_USED"
-            root_uuid="THE_PROJECT"
             project_uuid="THE_PROJECT"
-            module_uuid="[null]"
-            module_uuid_path="."
             path="[null]"
             id="10"
             scope="PRJ"
   <projects organization_uuid="org1"
             uuid="THE_FILE"
             uuid_path="NOT_USED"
-            root_uuid="THE_PROJECT"
             project_uuid="THE_PROJECT"
-            module_uuid="THE_PROJECT"
-            module_uuid_path=".THE_PROJECT."
             path="src/main/java/TheFile.java"
             id="11"
             scope="FIL"
index 48aa3d889f41346ab032f109753ae5ecb7e85365..2800fccb72bd8d2e9ddedc1b54b9910a220ae831 100644 (file)
   <projects organization_uuid="org1"
             uuid="THE_PROJECT_1"
             uuid_path="NOT_USED"
-            root_uuid="THE_PROJECT_1"
             project_uuid="THE_PROJECT_1"
-            module_uuid="[null]"
-            module_uuid_path="."
             path="[null]"
             id="10"
             scope="PRJ"
   <projects organization_uuid="org1"
             uuid="THE_FILE_1"
             uuid_path="NOT_USED"
-            root_uuid="THE_PROJECT_1"
             project_uuid="THE_PROJECT_1"
-            module_uuid="THE_PROJECT_1"
-            module_uuid_path=".THE_PROJECT_1."
             path="src/main/java/TheFile.java"
             id="11"
             scope="FIL"
@@ -68,9 +62,6 @@
   <projects organization_uuid="org1"
             uuid="THE_PROJECT_2"
             uuid_path="NOT_USED"
-            root_uuid="THE_PROJECT_2"
-            module_uuid="[null]"
-            module_uuid_path="."
             path="[null]"
             id="100"
             scope="PRJ"
@@ -81,9 +72,6 @@
   <projects organization_uuid="org1"
             uuid="THE_FILE_2"
             uuid_path="NOT_USED"
-            root_uuid="THE_PROJECT_2"
-            module_uuid="THE_PROJECT_2"
-            module_uuid_path=".THE_PROJECT_2."
             path="src/main/java/TheFile.java"
             id="111"
             scope="FIL"
index 70e0e9e92aa1b695be4a45775831d86d7fa37408..a5feb6627954ecdf83ac633e240db7a73bfa5999 100644 (file)
@@ -302,7 +302,7 @@ public class ServerUserSessionTest {
     assertThat(session.hasChildProjectsPermission(USER, application)).isTrue();
 
     // change privacy of the project without updating the cache
-    db.getDbClient().componentDao().setPrivateForRootComponentUuidWithoutAudit(db.getSession(), project.uuid(), true);
+    db.getDbClient().componentDao().setPrivateForBranchUuidWithoutAudit(db.getSession(), project.uuid(), true);
     assertThat(session.hasChildProjectsPermission(USER, application)).isTrue();
   }
 
@@ -387,7 +387,7 @@ public class ServerUserSessionTest {
     assertThat(session.hasChildProjectsPermission(USER, portfolio)).isTrue();
 
     // change privacy of the project without updating the cache
-    db.getDbClient().componentDao().setPrivateForRootComponentUuidWithoutAudit(db.getSession(), project.uuid(), true);
+    db.getDbClient().componentDao().setPrivateForBranchUuidWithoutAudit(db.getSession(), project.uuid(), true);
     assertThat(session.hasChildProjectsPermission(USER, portfolio)).isTrue();
   }
 
index e6efc5b96fb310bf7673a54aba54b883c6eb4a76..acf416b7ba236e1f21016fef17d7067e2fbe6202 100644 (file)
@@ -148,7 +148,6 @@ public class ComponentUpdater {
     ComponentDto component = new ComponentDto()
       .setUuid(uuid)
       .setUuidPath(ComponentDto.UUID_PATH_OF_ROOT)
-      .setRootUuid(uuid)
       .setBranchUuid(uuid)
       .setKey(newComponent.key())
       .setName(newComponent.name())
index 3310a26cbccc203d46163623a743574af457fae2..d0a5533d33eccc411a9bb84a99a9257ed2466f79 100644 (file)
@@ -133,7 +133,7 @@ public class UpdateVisibilityAction implements ProjectsWsAction {
 
   private void setPrivateForRootComponentUuid(DbSession dbSession, ComponentDto component, boolean isPrivate) {
     String uuid = component.uuid();
-    dbClient.componentDao().setPrivateForRootComponentUuid(dbSession, uuid, isPrivate, component.getKey(), component.qualifier(), component.name());
+    dbClient.componentDao().setPrivateForBranchUuid(dbSession, uuid, isPrivate, component.getKey(), component.qualifier(), component.name());
 
     if (component.qualifier().equals(Qualifiers.PROJECT) || component.qualifier().equals(Qualifiers.APP)) {
       dbClient.projectDao().updateVisibility(dbSession, uuid, isPrivate);
@@ -142,7 +142,7 @@ public class UpdateVisibilityAction implements ProjectsWsAction {
     ComponentMapper mapper = dbSession.getMapper(ComponentMapper.class);
     dbSession.getMapper(BranchMapper.class).selectByProjectUuid(uuid).stream()
       .filter(branch -> !uuid.equals(branch.getUuid()))
-      .forEach(branch -> mapper.setPrivateForRootComponentUuid(branch.getUuid(), isPrivate));
+      .forEach(branch -> mapper.setPrivateForBranchUuid(branch.getUuid(), isPrivate));
   }
 
   private boolean noPendingTask(DbSession dbSession, ComponentDto rootComponent) {
index d68b8866fa103e8aa6672c58412ce945f7c0e553..49458647741fb70610ca80a965984d64f65a235d 100644 (file)
@@ -134,7 +134,6 @@ public class ProjectDataLoaderTest {
     dbClient.componentDao().insert(dbSession, new ComponentDto()
       .setUuid(uuid)
       .setUuidPath(uuid + ".")
-      .setRootUuid(uuid)
       .setBranchUuid("branchUuid")
       .setScope(Scopes.PROJECT)
       .setKey("key"));
index b53d41fa78a252ad237c7c4ad2216ec2d293b78e..cf2e851af1ee10338b82897028d894a614fddc6e 100644 (file)
@@ -77,7 +77,8 @@ public class CorePropertyDefinitions {
       PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL)
         .name("Server base URL")
         .description(
-          "HTTP(S) URL of this SonarQube server, such as <i>https://yourhost.yourdomain/sonar</i>. This value is used outside SonarQube itself, e.g. for PR decoration, emails, etc.")
+          "HTTP(S) URL of this SonarQube server, such as <i>https://yourhost.yourdomain/sonar</i>. "
+            + "This value is used outside SonarQube itself, e.g. for PR decoration, emails, etc.")
         .category(CoreProperties.CATEGORY_GENERAL)
         .build(),
       PropertyDefinition.builder(SONAR_PROJECTCREATION_MAINBRANCHNAME)
index efe7d03ca38a547a38948dc0bc388978520d9d48..307c37874ace75e3b1f39aad0da5c488d0b683e0 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.core.config;
 
-import com.google.common.collect.ImmutableList;
 import java.util.List;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.PropertyType;
@@ -33,7 +32,7 @@ public class ExclusionProperties {
   }
 
   public static List<PropertyDefinition> all() {
-    return ImmutableList.of(
+    return List.of(
 
       // COVERAGE
       PropertyDefinition.builder(CoreProperties.PROJECT_COVERAGE_EXCLUSIONS_PROPERTY)