aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task-projectanalysis/src
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2024-10-24 10:54:15 +0200
committersonartech <sonartech@sonarsource.com>2024-10-24 20:02:44 +0000
commite0a940902f37156757e84544d0a876f47f69040f (patch)
tree988c74e5242ad1bb349148601bb207b7cf515b09 /server/sonar-ce-task-projectanalysis/src
parentc11922595bf67a70a38588a6f7763fb6f6c14501 (diff)
downloadsonarqube-e0a940902f37156757e84544d0a876f47f69040f.tar.gz
sonarqube-e0a940902f37156757e84544d0a876f47f69040f.zip
SONAR-23427 Stop relying on Qualifiers, Scopes and ResourceType from the plugin API
Diffstat (limited to 'server/sonar-ce-task-projectanalysis/src')
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java20
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java16
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java16
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java8
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/LoadProjectStepIT.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImpl.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectPersister.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ViewAttributes.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java24
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ComponentRepository.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewAttributesTest.java12
14 files changed, 64 insertions, 63 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java
index 1215f3d873f..03fe0f434c0 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java
@@ -27,8 +27,8 @@ import javax.annotation.Nullable;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Scopes;
+import org.sonar.db.component.ComponentQualifiers;
+import org.sonar.db.component.ComponentScopes;
import org.sonar.api.utils.System2;
import org.sonar.ce.task.projectanalysis.component.BranchPersister;
import org.sonar.ce.task.projectanalysis.component.Component;
@@ -512,8 +512,8 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest {
assertThat(dto.path()).isNull();
assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
- assertThat(dto.qualifier()).isEqualTo(Qualifiers.VIEW);
- assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
+ assertThat(dto.qualifier()).isEqualTo(ComponentQualifiers.VIEW);
+ assertThat(dto.scope()).isEqualTo(ComponentScopes.PROJECT);
assertThat(dto.getCopyComponentUuid()).isNull();
assertThat(dto.getCreatedAt()).isEqualTo(now);
}
@@ -528,8 +528,8 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest {
assertThat(dto.path()).isNull();
assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
- assertThat(dto.qualifier()).isEqualTo(Qualifiers.APP);
- assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
+ assertThat(dto.qualifier()).isEqualTo(ComponentQualifiers.APP);
+ assertThat(dto.scope()).isEqualTo(ComponentScopes.PROJECT);
assertThat(dto.getCopyComponentUuid()).isNull();
assertThat(dto.getCreatedAt()).isEqualTo(now);
}
@@ -544,8 +544,8 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest {
assertThat(sv1Dto.path()).isNull();
assertThat(sv1Dto.uuid()).isEqualTo(SUBVIEW_1_UUID);
assertThat(sv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
- assertThat(sv1Dto.qualifier()).isEqualTo(Qualifiers.SUBVIEW);
- assertThat(sv1Dto.scope()).isEqualTo(Scopes.PROJECT);
+ assertThat(sv1Dto.qualifier()).isEqualTo(ComponentQualifiers.SUBVIEW);
+ assertThat(sv1Dto.scope()).isEqualTo(ComponentScopes.PROJECT);
assertThat(sv1Dto.getCopyComponentUuid()).isNull();
assertThat(sv1Dto.getCreatedAt()).isEqualTo(now);
}
@@ -557,8 +557,8 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest {
assertThat(pv1Dto.path()).isNull();
assertThat(pv1Dto.uuid()).isEqualTo(PROJECT_VIEW_1_UUID);
assertThat(pv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
- assertThat(pv1Dto.qualifier()).isEqualTo(Qualifiers.PROJECT);
- assertThat(pv1Dto.scope()).isEqualTo(Scopes.FILE);
+ assertThat(pv1Dto.qualifier()).isEqualTo(ComponentQualifiers.PROJECT);
+ assertThat(pv1Dto.scope()).isEqualTo(ComponentScopes.FILE);
assertThat(pv1Dto.getCopyComponentUuid()).isEqualTo(project.uuid());
assertThat(pv1Dto.getCreatedAt()).isEqualTo(now);
}
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java
index 808091735f0..35cd86f06c4 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java
@@ -31,8 +31,8 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.event.Level;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Scopes;
+import org.sonar.db.component.ComponentQualifiers;
+import org.sonar.db.component.ComponentScopes;
import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.utils.System2;
import org.sonar.ce.task.projectexport.component.ComponentRepositoryImpl;
@@ -59,8 +59,8 @@ public class ExportAnalysesStepIT {
private static final String PROJECT_UUID = "PROJECT_UUID";
private static final ComponentDto PROJECT = new ComponentDto()
// no id yet
- .setScope(Scopes.PROJECT)
- .setQualifier(Qualifiers.PROJECT)
+ .setScope(ComponentScopes.PROJECT)
+ .setQualifier(ComponentQualifiers.PROJECT)
.setKey("the_project")
.setName("The Project")
.setDescription("The project description")
@@ -73,8 +73,8 @@ public class ExportAnalysesStepIT {
private static final String UUID_PATH = UUID_PATH_OF_ROOT + UUID_PATH_SEPARATOR + DIR_UUID;
private static final ComponentDto DIR = new ComponentDto()
// no id yet
- .setScope(Scopes.PROJECT)
- .setQualifier(Qualifiers.DIRECTORY)
+ .setScope(ComponentScopes.PROJECT)
+ .setQualifier(ComponentQualifiers.DIRECTORY)
.setKey("the_dir")
.setName("The Dir")
.setDescription("description of dir")
@@ -86,8 +86,8 @@ public class ExportAnalysesStepIT {
private static final String FILE_UUID = "FILE_UUID";
private static final ComponentDto FILE = new ComponentDto()
// no id yet
- .setScope(Scopes.FILE)
- .setQualifier(Qualifiers.FILE)
+ .setScope(ComponentScopes.FILE)
+ .setQualifier(ComponentQualifiers.FILE)
.setKey("the_file")
.setName("The File")
.setUuid(FILE_UUID)
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java
index feff1fc7794..8240de0c652 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java
@@ -28,8 +28,8 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.event.Level;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Scopes;
+import org.sonar.db.component.ComponentQualifiers;
+import org.sonar.db.component.ComponentScopes;
import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.utils.System2;
import org.sonar.ce.task.projectexport.steps.DumpElement;
@@ -52,8 +52,8 @@ public class ExportComponentsStepIT {
private static final String PROJECT_UUID = "PROJECT_UUID";
private static final ComponentDto PROJECT = new ComponentDto()
// no id yet
- .setScope(Scopes.PROJECT)
- .setQualifier(Qualifiers.PROJECT)
+ .setScope(ComponentScopes.PROJECT)
+ .setQualifier(ComponentQualifiers.PROJECT)
.setKey("the_project")
.setName("The Project")
.setDescription("The project description")
@@ -67,8 +67,8 @@ public class ExportComponentsStepIT {
private static final String FILE_UUID_PATH = PROJECT_UUID + FILE_UUID + UUID_PATH_SEPARATOR;
private static final ComponentDto FILE = new ComponentDto()
// no id yet
- .setScope(Scopes.FILE)
- .setQualifier(Qualifiers.FILE)
+ .setScope(ComponentScopes.FILE)
+ .setQualifier(ComponentQualifiers.FILE)
.setKey("the_file")
.setName("The File")
.setUuid(FILE_UUID)
@@ -110,8 +110,8 @@ public class ExportComponentsStepIT {
List<ProjectDump.Component> components = dumpWriter.getWrittenMessagesOf(DumpElement.COMPONENTS);
assertThat(components).extracting(ProjectDump.Component::getQualifier, ProjectDump.Component::getUuid, ProjectDump.Component::getUuidPath)
.containsExactlyInAnyOrder(
- tuple(Qualifiers.FILE, FILE_UUID, FILE_UUID_PATH),
- tuple(Qualifiers.PROJECT, PROJECT_UUID, UUID_PATH_OF_ROOT));
+ tuple(ComponentQualifiers.FILE, FILE_UUID, FILE_UUID_PATH),
+ tuple(ComponentQualifiers.PROJECT, PROJECT_UUID, UUID_PATH_OF_ROOT));
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java
index 90aced92047..4f8fc259ba3 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java
@@ -25,8 +25,8 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.event.Level;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Scopes;
+import org.sonar.db.component.ComponentQualifiers;
+import org.sonar.db.component.ComponentScopes;
import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.utils.System2;
import org.sonar.ce.task.projectexport.component.ComponentRepositoryImpl;
@@ -51,8 +51,8 @@ public class ExportEventsStepIT {
.setUuid(PROJECT_UUID)
.setUuidPath(UUID_PATH_OF_ROOT)
.setBranchUuid(PROJECT_UUID)
- .setScope(Scopes.PROJECT)
- .setQualifier(Qualifiers.PROJECT)
+ .setScope(ComponentScopes.PROJECT)
+ .setQualifier(ComponentQualifiers.PROJECT)
.setKey("the_project")
.setEnabled(true);
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java
index 15a6526ea3e..09ede9a7f07 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java
@@ -28,7 +28,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.event.Level;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.utils.System2;
import org.sonar.ce.task.step.TestComputationStepContext;
@@ -55,7 +55,7 @@ public class ExportNewCodePeriodsStepIT {
.setUuid(ANOTHER_PROJECT_UUID)
.setUuidPath(UUID_PATH_OF_ROOT)
.setBranchUuid(ANOTHER_PROJECT_UUID)
- .setQualifier(Qualifiers.PROJECT)
+ .setQualifier(ComponentQualifiers.PROJECT)
.setName("another_project")
.setKey("another_project");
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java
index 2ddd1ed7f9b..bea0ef4cdd0 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java
@@ -26,7 +26,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.event.Level;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.utils.System2;
import org.sonar.ce.task.step.TestComputationStepContext;
@@ -159,7 +159,7 @@ public class ExportSettingsStepIT {
private void insertProperties(@Nullable String entityKey, @Nullable String entityName, PropertyDto... dtos) {
for (PropertyDto dto : dtos) {
- dbTester.getDbClient().propertiesDao().saveProperty(dbTester.getSession(), dto, null, entityKey, entityName, Qualifiers.VIEW);
+ dbTester.getDbClient().propertiesDao().saveProperty(dbTester.getSession(), dto, null, entityKey, entityName, ComponentQualifiers.VIEW);
}
dbTester.commit();
}
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/LoadProjectStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/LoadProjectStepIT.java
index a63e3216cc6..39d9dc36b45 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/LoadProjectStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/LoadProjectStepIT.java
@@ -21,7 +21,7 @@ package org.sonar.ce.task.projectexport.steps;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.System2;
import org.sonar.ce.task.projectexport.taskprocessor.ProjectDescriptor;
@@ -56,7 +56,7 @@ public class LoadProjectStepIT {
// insert a module, but not a project
dbTester.executeInsert("projects",
"kee", PROJECT_KEY,
- "qualifier", Qualifiers.APP,
+ "qualifier", ComponentQualifiers.APP,
"uuid", "not_used",
"private", false,
"creation_method", CreationMethod.LOCAL_API.name(),
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImpl.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImpl.java
index 02b5e1e7524..b0bc14401b0 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImpl.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImpl.java
@@ -22,7 +22,7 @@ package org.sonar.ce.task.projectanalysis.component;
import java.util.Arrays;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
import org.sonar.ce.task.projectanalysis.analysis.Branch;
import org.sonar.db.DbClient;
@@ -88,7 +88,7 @@ public class BranchPersisterImpl implements BranchPersister {
dto.setExcludeFromPurge(excludeFromPurge);
// merge branch is only present if it's not a main branch and not an application
- if (!branch.isMain() && !Qualifiers.APP.equals(componentDto.qualifier())) {
+ if (!branch.isMain() && !ComponentQualifiers.APP.equals(componentDto.qualifier())) {
dto.setMergeBranchUuid(branch.getReferenceBranchUuid());
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectPersister.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectPersister.java
index ff151d68f42..ecff782131d 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectPersister.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ProjectPersister.java
@@ -20,7 +20,7 @@
package org.sonar.ce.task.projectanalysis.component;
import org.apache.commons.lang3.StringUtils;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
@@ -72,7 +72,7 @@ public class ProjectPersister {
projectDto.setDescription(root.getDescription());
projectDto.setUpdatedAt(system2.now());
projectDto.setKey(root.getKey());
- projectDto.setQualifier(root.getType().equals(Component.Type.PROJECT) ? Qualifiers.PROJECT : Qualifiers.APP);
+ projectDto.setQualifier(root.getType().equals(Component.Type.PROJECT) ? ComponentQualifiers.PROJECT : ComponentQualifiers.APP);
return projectDto;
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ViewAttributes.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ViewAttributes.java
index 333640658a9..b3736cca32c 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ViewAttributes.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ViewAttributes.java
@@ -21,7 +21,7 @@ package org.sonar.ce.task.projectanalysis.component;
import java.util.Arrays;
import javax.annotation.concurrent.Immutable;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.db.component.ComponentQualifiers;
import static java.util.Objects.requireNonNull;
@@ -29,7 +29,7 @@ import static java.util.Objects.requireNonNull;
public class ViewAttributes {
public enum Type {
- PORTFOLIO(Qualifiers.VIEW), APPLICATION(Qualifiers.APP);
+ PORTFOLIO(ComponentQualifiers.VIEW), APPLICATION(ComponentQualifiers.APP);
private final String qualifier;
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
index fd8af1dacfd..0c9d8313300 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
@@ -27,8 +27,8 @@ import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Scopes;
+import org.sonar.db.component.ComponentQualifiers;
+import org.sonar.db.component.ComponentScopes;
import org.sonar.api.utils.System2;
import org.sonar.ce.task.projectanalysis.component.BranchPersister;
import org.sonar.ce.task.projectanalysis.component.Component;
@@ -48,7 +48,7 @@ import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentUpdateDto;
import static java.util.Optional.ofNullable;
-import static org.sonar.api.resources.Qualifiers.PROJECT;
+import static org.sonar.db.component.ComponentQualifiers.PROJECT;
import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER;
import static org.sonar.db.component.ComponentDto.UUID_PATH_OF_ROOT;
import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
@@ -254,7 +254,7 @@ public class PersistComponentsStep implements ComputationStep {
public ComponentDto createForProject(Component project) {
ComponentDto res = createBase(project);
- res.setScope(Scopes.PROJECT);
+ res.setScope(ComponentScopes.PROJECT);
res.setQualifier(PROJECT);
res.setName(project.getName());
res.setLongName(res.name());
@@ -269,8 +269,8 @@ public class PersistComponentsStep implements ComputationStep {
public ComponentDto createForDirectory(Component directory, PathAwareVisitor.Path<ComponentDtoHolder> path) {
ComponentDto res = createBase(directory);
- res.setScope(Scopes.DIRECTORY);
- res.setQualifier(Qualifiers.DIRECTORY);
+ res.setScope(ComponentScopes.DIRECTORY);
+ res.setQualifier(ComponentQualifiers.DIRECTORY);
res.setName(directory.getShortName());
res.setLongName(directory.getName());
res.setPath(directory.getName());
@@ -283,7 +283,7 @@ public class PersistComponentsStep implements ComputationStep {
public ComponentDto createForFile(Component file, PathAwareVisitor.Path<ComponentDtoHolder> path) {
ComponentDto res = createBase(file);
- res.setScope(Scopes.FILE);
+ res.setScope(ComponentScopes.FILE);
res.setQualifier(getFileQualifier(file));
res.setName(file.getShortName());
res.setLongName(file.getName());
@@ -298,7 +298,7 @@ public class PersistComponentsStep implements ComputationStep {
private ComponentDto createForView(Component view) {
ComponentDto res = createBase(view);
- res.setScope(Scopes.PROJECT);
+ res.setScope(ComponentScopes.PROJECT);
res.setQualifier(view.getViewAttributes().getType().getQualifier());
res.setName(view.getName());
res.setDescription(view.getDescription());
@@ -313,8 +313,8 @@ public class PersistComponentsStep implements ComputationStep {
private ComponentDto createForSubView(Component subView, PathAwareVisitor.Path<ComponentDtoHolder> path) {
ComponentDto res = createBase(subView);
- res.setScope(Scopes.PROJECT);
- res.setQualifier(Qualifiers.SUBVIEW);
+ res.setScope(ComponentScopes.PROJECT);
+ res.setQualifier(ComponentQualifiers.SUBVIEW);
res.setName(subView.getName());
res.setDescription(subView.getDescription());
res.setLongName(res.name());
@@ -328,7 +328,7 @@ public class PersistComponentsStep implements ComputationStep {
private ComponentDto createForProjectView(Component projectView, PathAwareVisitor.Path<ComponentDtoHolder> path) {
ComponentDto res = createBase(projectView);
- res.setScope(Scopes.FILE);
+ res.setScope(ComponentScopes.FILE);
res.setQualifier(PROJECT);
res.setName(projectView.getName());
res.setLongName(res.name());
@@ -415,7 +415,7 @@ public class PersistComponentsStep implements ComputationStep {
}
private static String getFileQualifier(Component component) {
- return component.getFileAttributes().isUnitTest() ? Qualifiers.UNIT_TEST_FILE : Qualifiers.FILE;
+ return component.getFileAttributes().isUnitTest() ? ComponentQualifiers.UNIT_TEST_FILE : ComponentQualifiers.FILE;
}
private static class ComponentDtoHolder {
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ComponentRepository.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ComponentRepository.java
index 338ac71c110..2394328b5a9 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ComponentRepository.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ComponentRepository.java
@@ -20,6 +20,7 @@
package org.sonar.ce.task.projectexport.component;
import java.util.Set;
+import org.sonar.db.component.ComponentQualifiers;
/**
* Holds the references of components which are present in the dump.
@@ -32,7 +33,7 @@ public interface ComponentRepository {
long getRef(String uuid);
/**
- * Uuids of the components of type FILE (ie. Qualifiers = {@link org.sonar.api.resources.Qualifiers#FILE}) known to
+ * Uuids of the components of type FILE (ie. Qualifiers = {@link ComponentQualifiers#FILE}) known to
* the repository.
*/
Set<String> getFileUuids();
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java
index 562c9a8c088..ea73e622dfd 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/component/ExportComponentsStep.java
@@ -24,7 +24,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.slf4j.LoggerFactory;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.ce.task.projectexport.steps.DumpElement;
import org.sonar.ce.task.projectexport.steps.DumpWriter;
import org.sonar.ce.task.projectexport.steps.ProjectHolder;
@@ -77,7 +77,7 @@ public class ExportComponentsStep implements ComputationStep {
String qualifier = getString(rs, 2);
String uuidPath = getString(rs, 3);
componentBuilder.clear();
- componentRepository.register(ref, uuid, Qualifiers.FILE.equals(qualifier));
+ componentRepository.register(ref, uuid, ComponentQualifiers.FILE.equals(qualifier));
ProjectDump.Component component = componentBuilder
.setRef(ref)
.setUuid(uuid)
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewAttributesTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewAttributesTest.java
index 5ea223634c5..9b81fadfbf2 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewAttributesTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ViewAttributesTest.java
@@ -20,7 +20,7 @@
package org.sonar.ce.task.projectanalysis.component;
import org.junit.Test;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.db.component.ComponentQualifiers;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -36,7 +36,7 @@ public class ViewAttributesTest {
underTest = new ViewAttributes(PORTFOLIO);
assertThat(underTest.getType()).isEqualTo(PORTFOLIO);
- assertThat(underTest.getType().getQualifier()).isEqualTo(Qualifiers.VIEW);
+ assertThat(underTest.getType().getQualifier()).isEqualTo(ComponentQualifiers.VIEW);
}
@Test
@@ -44,18 +44,18 @@ public class ViewAttributesTest {
underTest = new ViewAttributes(APPLICATION);
assertThat(underTest.getType()).isEqualTo(APPLICATION);
- assertThat(underTest.getType().getQualifier()).isEqualTo(Qualifiers.APP);
+ assertThat(underTest.getType().getQualifier()).isEqualTo(ComponentQualifiers.APP);
}
@Test
public void type_from_qualifier() {
- assertThat(ViewAttributes.Type.fromQualifier(Qualifiers.VIEW)).isEqualTo(PORTFOLIO);
- assertThat(ViewAttributes.Type.fromQualifier(Qualifiers.APP)).isEqualTo(APPLICATION);
+ assertThat(ViewAttributes.Type.fromQualifier(ComponentQualifiers.VIEW)).isEqualTo(PORTFOLIO);
+ assertThat(ViewAttributes.Type.fromQualifier(ComponentQualifiers.APP)).isEqualTo(APPLICATION);
}
@Test
public void fail_if_unknown_view_qualifier() {
- assertThatThrownBy(() -> ViewAttributes.Type.fromQualifier(Qualifiers.PROJECT))
+ assertThatThrownBy(() -> ViewAttributes.Type.fromQualifier(ComponentQualifiers.PROJECT))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Qualifier 'TRK' is not supported");
}